When processing a HEIC/HEIF file on a Windows system that does not have the required WIC codec (e.g., a default Windows 10 installation), pipeline.WriteOutput(ms); causes the entire application to crash and terminate when the application is compiled with Native AOT.
In a standard JIT/.NET build, the same code path correctly throws a manageable exception, which can be caught and handled gracefully. The issue is specific to the Native AOT compilation target, where the process exits immediately, and the try...catch block is bypassed.
try
{
var settings = new ProcessImageSettings
{
Width = 800, Height = 800,
ResizeMode = CropScaleMode.Max,
HybridMode = HybridScaleMode.Turbo
};
using var pipeline = MagicImageProcessor.BuildPipeline(inputPath, settings);
using var ms = new MemoryStream();
pipeline.WriteOutput(ms);
// Do other things with ms
}
catch (Exception ex)
{
Logger.Error(ex);
// Do cleanup
}
Application type : WinUI3 - C# application
PhotoSauce.MagicScaler - Version=0.15.0
.NET Version: .NET 9.0
Operating System: Windows 10
Target Runtime / Build Configuration: Native AOT (win-x64)