Repository navigation
Load a png on IOS causes an "Attempting to JIT compile method while running in aot-only mode" #776
Copy link
Copy link
Closed
Labels
Description
Prerequisites
- I have written a descriptive issue title
- I have verified that I am running the latest version of ImageSharp
- I have verified if the problem exist in both
DEBUGandRELEASEmode - I have searched open and closed issues to ensure it has not already been reported
Description
When trying to load a PNG image on iOS 12 an unhandled exception is raised.
Steps to Reproduce
On an Xamarin.IOS project try to invoke:
var image = SixLabors.ImageSharp.Image.Load(stream);
The next exception will be raised:
System.ExecutionEngineException: Attempting to JIT compile method 'SixLabors.ImageSharp.Formats.Png.PngScanlineProcessor:ProcessRgbScanline<SixLabors.ImageSharp.PixelFormats.Rgba32> (SixLabors.ImageSharp.Configuration,SixLabors.ImageSharp.Formats.Png.PngHeader&,System.ReadOnlySpan`1<byte>,System.Span`1<SixLabors.ImageSharp.PixelFormats.Rgba32>,int,int,bool,SixLabors.ImageSharp.PixelFormats.Rgb48,SixLabors.ImageSharp.PixelFormats.Rgb24)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.
at SixLabors.ImageSharp.Formats.Png.PngDecoderCore.ProcessDefilteredScanline[TPixel] (System.ReadOnlySpan`1[T] defilteredScanline, SixLabors.ImageSharp.ImageFrame`1[TPixel] pixels) [0x000db] in <eb47c90af2ba451c9c07fe98c40e7810>:0
at (wrapper unknown) System.Object.gsharedvt_in()
at (wrapper unknown) System.Object.gsharedvt_out()
at SixLabors.ImageSharp.Formats.Png.
PngDecoderCore.DecodePixelData[TPixel] (System.IO.Stream compressedStream, SixLabors.ImageSharp.ImageFrame`1[TPixel] image) [0x000e5] in <eb47c90af2ba451c9c07fe98c40e7810>:0
at (wrapper unknown) System.Object.gsharedvt_in()
at (wrapper unknown) System.Object.gsharedvt_out()
at SixLabors.ImageSharp.Formats.Png.PngDecoderCore.ReadScanlines[TPixel] (System.IO.Stream dataStream, SixLabors.ImageSharp.ImageFrame`1[TPixel] image) [0x00017] in <eb47c90af2ba451c9c07fe98c40e7810>:0
at (wrapper unknown) System.Object.gsharedvt_in()
at (wrapper unknown) System.Object.gsharedvt_out()
at SixLabors.ImageSharp.Formats.Png.PngDecoderCore.Decode[TPixel] (System.IO.Stream stream) [0x00171] in <eb47c90af2ba451c9c07fe98c40e7810>:0
at (wrapper unknown) System.Object.gsharedvt_in()
at (wrapper unknown) System.Object.gsharedvt_out()
at SixLabors.ImageSharp.Formats.Png.PngDecoder.Decode[TPixel] (SixLabors.ImageSharp.Configuration configuration, System.IO.Stream stream) [0x00008] in <eb47c90af2ba451c9c07fe98c40e78
10>:0
at SixLabors.ImageSharp.Image.Decode[TPixel] (System.IO.Stream stream, SixLabors.ImageSharp.Configuration config) [0x00015] in <eb47c90af2ba451c9c07fe98c40e7810>:0
at SixLabors.ImageSharp.Image+<>c__DisplayClass55_0`1[TPixel].<Load>b__0 (System.IO.Stream s) [0x00000] in <eb47c90af2ba451c9c07fe98c40e7810>:0
at SixLabors.ImageSharp.Image.WithSeekableStream[T] (SixLabors.ImageSharp.Configuration config, System.IO.Stream stream, System.Func`2[T,TResult] action) [0x0002b] in <eb47c90af2ba451c9c07fe98c40e7810>:0
at SixLabors.ImageSharp.Image.Load[TPixel] (SixLabors.ImageSharp.Configuration config, System.IO.Stream stream, SixLabors.ImageSharp.Formats.IImageFormat& format) [0x00022] in <eb47c90af2ba451c9c07fe98c40e7810>:0
at SixLabors.ImageSharp.Image.Load[TPixel] (SixLabors.ImageSharp.Configuration config, System.IO.Stream stream) [0x00000] in <eb47c90af2ba451c9c07fe98c40e7810>:0
at SixLabors.ImageSharp.Image.Load[TPixel] (System.IO.Stream stream) [0x00000] in <eb47c90af2ba451c9c07fe98c40e78
10>:0
at SixLabors.ImageSharp.Image.Load (System.IO.Stream stream) [0x00000] in <eb47c90af2ba451c9c07fe98c40e7810>:0
System Configuration
- ImageSharp version: 1.0.0-beta0005
- Other ImageSharp packages and versions: (none)
- Environment (Operating system, version and so on): iOS 12
- .NET Framework version:
- Additional information:
=== Visual Studio Enterprise 2017 for Windows ===
Version 15.8.9
VisualStudio.15.Release/15.8.9+28010.2050
Xamarin 4.11.0.779 (d15-8@ff915e800)
Xamarin.iOS and Xamarin.Mac SDK 12.1.0.15 (cbfb047)
Reactions are currently unavailable
Activity
vicfergar commentedon Nov 14, 2018
This is related with #383 and #762
antonfirsov commentedon Nov 22, 2018
@vicfergar I wonder how should we extend the AOT seeding utility introduced in #767 to make this work.
We lack both the knowledge and the time to investigate this, so any hints from the community would be very helpful.
davilovick commentedon Jan 31, 2019
I've just tried to load a PNG in iOS with the latest Release (1.0.0-beta0006), and the issue is still happening.
The stacktrace is exatly the same that @vicfergar has described.
James-Jackson-South commentedon Jan 31, 2019
Did you use the seed utility method?
davilovick commentedon Feb 4, 2019
Sorry for the delay.
Yes, I've used the Seed method. Here is an example of how I've used this to reproduce the problem:
leonluc-dev commentedon Jul 11, 2019
I'm encountering a similar issue in my iOS app.
I use the following code in a .NET Standard project (referenced by an Xamarin.iOS and Xamarin.Android app) to load a PNG or JPEG image from a byte array.
This works fine for JPEG images (and on the Android app), but as soon as I try to load PNG image data on iOS the following exception occurs:
This exception seems close to identical to the one described in this issue. The major difference being the method name
ProcessRgbaScanlinevsProcessRgbScanlineI've already tried using the AotCompilerTools to seed the Rgba32 pixel type my code uses, but this did not solve the issue.
leonluc-dev commentedon Jul 12, 2019
Looking into it, it seems the following code is not properly seeded for some reason (possibly due to the inferred generics, but I'm not 100% sure):
ImageSharp/src/ImageSharp/Formats/Png/PngDecoderCore.cs
Lines 649 to 705 in 48bac7b
Since the code is marked assembly internal I cannot directly seed these methods without importing/modifying the source code.
antonfirsov commentedon Jul 14, 2019
@gameleon-dev thans for the investigations you made so far! 👍
I have just opened #946 to address this issue at a higher level. Let's continue the discussion there!