Imagesharp: Xamarin AOT compiler error for 32 bit

Created on 22 Apr 2020  路  9Comments  路  Source: SixLabors/ImageSharp

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have verified that I am running the latest version of ImageSharp
  • [X] I have verified if the problem exist in both DEBUG and RELEASE mode
  • [X] I have searched open and closed issues to ensure it has not already been reported

Description

This may sound crazy but I'm trying to use this library within a Xamarin.iOS app that targets iOS 9.3 minimum on an iPhone 4s.

I have the following error:
The assembly 'SixLabors.ImageSharp.dll' can't be AOT-compiled for 32-bit architectures because the native code is too big for the 32-bit ARM architecture

Steps to Reproduce

You will need a 32 bit iPhone.

Create a new Xamarin.iOS project, Add the SixLabors.ImageSharp nuget beta-0007

System Configuration

  • ImageSharp version: SixLabors.ImageSharp nuget beta-0007
  • Other ImageSharp packages and versions:
  • Environment (Operating system, version and so on): iOS 9.3
  • .NET Framework version:
  • Additional information:

=== Visual Studio Community 2019 for Mac (Preview) ===

Version 8.6 Preview (8.6 build 4243)
Installation UUID: 044fc49d-ee45-4736-9dc5-fcb04c42c8b1
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

Package version: 610000101

=== Mono Framework MDK ===

Runtime:
Mono 6.10.0.101 (2019-12/6f0bf73005d) (64-bit)
Package version: 610000101

=== Roslyn (Language Service) ===

3.6.0-3.20209.3+34fad56309fc96f2af1171df6ea012cbf991c27d

=== NuGet ===

Version: 5.5.0.6473

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.200/Sdks
SDK Versions:
3.1.200
3.1.102
3.1.100
3.1.100-preview3-014645
3.1.100-preview2-014569
3.0.100
3.0.100-rc1-014190
3.0.100-preview9-014004
3.0.100-preview8-013656
2.1.701
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.1.2
3.1.0
3.1.0-preview3.19553.2
3.1.0-preview2.19525.6
3.0.0
3.0.0-rc1-19456-20
3.0.0-preview9-19423-09
2.1.17
2.1.16
2.1.14
2.1.13
2.1.12

=== Xamarin.Profiler ===

Version: 1.6.12.29
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.4.1 (16137)
Build 11E503a

=== Xamarin.Mac ===

Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

=== Xamarin.iOS ===

Version: 13.18.1.31 (Visual Studio Community)
Hash: b3eedfed9
Branch: d16-6
Build date: 2020-04-09 10:22:36-0400

=== Xamarin Designer ===

Version: 16.6.0.320
Hash: dcc2cd183
Branch: remotes/origin/d16-6
Build date: 2020-04-10 18:49:40 UTC

=== Xamarin.Android ===

Version: 10.3.0.74 (Visual Studio Community)
Commit: xamarin-android/d16-6/964ac42
Android SDK: /Users/omatrot/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
6.0 (API level 23)
8.0 (API level 26)
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.5
SDK Build Tools Version: 29.0.2

Build Information:
Mono: 165f4b0
Java.Interop: xamarin/java.interop/d16-6@2cab35c
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.31.1@49232bc
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-6@bfb66f3

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/omatrot/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.6.0.46
Hash: f6bfa7b
Branch: remotes/origin/dev/joe/d16-6~2
Build date: 2020-04-09 20:14:24 UTC

=== Android Device Manager ===

Version: 16.6.0.75
Hash: 4509c53
Branch: remotes/origin/d16-6~6
Build date: 2020-04-09 20:14:50 UTC

=== Build Information ===

Release ID: 806004243
Git revision: dda82db2458288a91a58f44d24abe41cf0d25bb6
Build date: 2020-04-14 16:13:25-04
Build branch: release-8.6
Xamarin extensions: dda82db2458288a91a58f44d24abe41cf0d25bb6

=== Operating System ===

Mac OS X 10.15.5
Darwin 19.5.0 Darwin Kernel Version 19.5.0
Sun Apr 5 21:30:12 PDT 2020
root:xnu-6153.120.27~16/RELEASE_X86_64 x86_64

aot

Most helpful comment

I'm currently evaluating the following workaround.

The build error has gone, hope that everything will be fine at runtime.

All 9 comments

I'm afraid we can't do anything about this:
there's no Xamarin dev / Apple expert on the board, and we won't be able to reduce the code size of the lib.

A quick google search gives me several hits resolving this on configuration / IDE side. Any chance those can help you?

I've also reported the problem to Microsoft.
Wait and see what they think about it.

@omatrot I don't think the Visual Studio tracker is the best place to report the issue. I would recommend going straight to the source.

https://github.com/xamarin/xamarin-macios/issues/6925#issuecomment-556040544

I'm currently evaluating the following workaround.

The build error has gone, hope that everything will be fine at runtime.

@omatrot please let us know if there are runtime issues. We can try to ensure that all the used code is detected properly via https://github.com/SixLabors/ImageSharp/blob/2320f16274fe126acc560a8d331a9eeb870bc540/src/ImageSharp/Advanced/AotCompilerTools.cs#L26

So far so good :)

Ok... Closing this for now then. Any other issues please let us know.

I encountered this issue today:

{System.ExecutionEngineException: Attempting to JIT compile method 'void 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://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

  at SixLabors.ImageSharp.Formats.Png.PngDecoderCore.ProcessDefilteredScanline[TPixel] (System.ReadOnlySpan`1[T] defilteredScanline, SixLabors.ImageSharp.ImageFrame`1[TPixel] pixels, SixLabors.ImageSharp.Formats.Png.PngMetadata pngMetadata) [0x0012e] in <b4c830224da44f688c8103ec7950ce90>:0 
  at SixLabors.ImageSharp.Formats.Png.PngDecoderCore.DecodePixelData[TPixel] (System.IO.Stream compressedStream, SixLabors.ImageSharp.ImageFrame`1[TPixel] image, SixLabors.ImageSharp.Formats.Png.PngMetadata pngMetadata) [0x000e5] in <b4c830224da44f688c8103ec7950ce90>:0 
  at SixLabors.ImageSharp.Formats.Png.PngDecoderCore.ReadScanlines[TPixel] (System.IO.Stream dataStream, SixLabors.ImageSharp.ImageFrame`1[TPixel] image, SixLabors.ImageSharp.Formats.Png.PngMetadata pngMetadata) [0x00018] in <b4c830224da44f688c8103ec7950ce90>:0 
  at SixLabors.ImageSharp.Formats.Png.PngDecoderCore.Decode[TPixel] (System.IO.Stream stream) [0x00189] in <b4c830224da44f688c8103ec7950ce90>:0 
  at SixLabors.ImageSharp.Formats.Png.PngDecoder.Decode[TPixel] (SixLabors.ImageSharp.Configuration configuration, System.IO.Stream stream) [0x00007] in <b4c830224da44f688c8103ec7950ce90>:0 
  at SixLabors.ImageSharp.Image.Decode[TPixel] (System.IO.Stream stream, SixLabors.ImageSharp.Configuration config) [0x00015] in <b4c830224da44f688c8103ec7950ce90>:0 
  at SixLabors.ImageSharp.Image+<>c__DisplayClass96_0`1[TPixel].<Load>b__0 (System.IO.Stream s) [0x00000] in <b4c830224da44f688c8103ec7950ce90>:0 
  at SixLabors.ImageSharp.Image.WithSeekableStream[T] (SixLabors.ImageSharp.Configuration config, System.IO.Stream stream, System.Func`2[T,TResult] action) [0x0002b] in <b4c830224da44f688c8103ec7950ce90>:0 
  at SixLabors.ImageSharp.Image.Load[TPixel] (SixLabors.ImageSharp.Configuration config, System.IO.Stream stream, SixLabors.ImageSharp.Formats.IImageFormat& format) [0x00022] in <b4c830224da44f688c8103ec7950ce90>:0 
  at SixLabors.ImageSharp.Image.Load[TPixel] (SixLabors.ImageSharp.Configuration config, System.IO.Stream stream) [0x00000] in <b4c830224da44f688c8103ec7950ce90>:0 
  at SixLabors.ImageSharp.Image.Load[TPixel] (SixLabors.ImageSharp.Configuration config, System.Byte[] data) [0x00007] in <b4c830224da44f688c8103ec7950ce90>:0 
  at SixLabors.ImageSharp.Image.Load (System.Byte[] data) [0x00005] in <b4c830224da44f688c8103ec7950ce90>:0 
  at yaka_business.Profile.SetPic (System.Byte[] _data) [0x00002] in /Users/omatrot/Documents/hygeex/etp/etp_proto/yaka_business/Profile.cs:64 }

@omatrot looks like a subcase of #946, so it's better to move further conversation to that issue. If you used beta7, can you try RC1?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Inumedia picture Inumedia  路  3Comments

agoretsky picture agoretsky  路  4Comments

Sergio0694 picture Sergio0694  路  3Comments

marcpabst picture marcpabst  路  3Comments

devedse picture devedse  路  3Comments