ImageSharp
ImageSharp copied to clipboard
ImageFormatException when loading GIF image on Android with Hybrid AOT mode
Description
When enabling Hybrid AOT mode on Android, GIF images cannot be loaded by ImageSharp (ImageFormatException).
Steps to Reproduce
Load GIF image in a Xamarin app on android. Make sure to enable hybrid aot mode in csproj (requires VS 2019 16.8 preview because of a regression in 16.7.*).
System Configuration
- ImageSharp version: 1.0.1
- Environment : Xamarin Android
Do you have a stacktrace?
The Gif would be also very helpful.
Any gif. For example, base_1x4.gif from the test suite.
Here is the stacktrace:
SixLabors.ImageSharp.UnknownImageFormatException: Image cannot be loaded. Available decoders:
- GIF : GifDecoder
- JPEG : JpegDecoder
- BMP : BmpDecoder
- PNG : PngDecoder
- TGA : TgaDecoder
at SixLabors.ImageSharp.Image.Load(SixLabors.ImageSharp.Configuration configuration, System.IO.Stream stream, SixLabors.ImageSharp.Formats.IImageFormat& format)
at SixLabors.ImageSharp.Image.Load(System.IO.Stream stream, SixLabors.ImageSharp.Formats.IImageFormat& format)
at ....
And it's only Gifs yeah?
All other image formats work ok and use the same stream loading pipeline?
Yes ,this exception is only happening for GIF images. With PNG files I'm also having an issue when enabling Hybrid AOT, but it's probably something else and I'm working on it to provide more details.
About PNG files: Image.Load does not throw any exception The loaded image object has correct width and height. However, the loaded image is totally blank !
@tranb3r i have just tried to reproduce this, but i was able to load the base_1x4.gif
fine.
I have just added to the project file:
<AotAssemblies>true</AotAssemblies>
<AndroidAotMode>Hybrid</AndroidAotMode>
Is that all what's needed or do i miss something? Maybe you could you share your project file?
Im using VS Version 16.8.0 Preview 2.1
@brianpopow Thank you for testing. Yes, that's all you need to add to the project file (in the Release section of course).
@tranb3r i really did placed it in the debug section instead of the Release one 😬
Unfortunately i still cannot reproduce the issue. The app now crashes immediately when started. My experience with app's is very limited, so im not sure why that's happening. I have just added the two lines mentioned above to a blank xamarin project.
I think hybrid aot is limited to 64bit arch. Which device are you testing on ?
ok so that may be the reason then, my device has a ARMv7, so its 32bit. Is it possible to reproduce this with an emulator?
I'm not sure it'll work on the emulator. I think it's only for arm64-v8a devices.
We need someone to raise an issue upstream here for us to track. We can't fix issues with the AOT compiler.
I'm going to close this. It's been several years without any update on upstream issues raised..