Essentials: [Bug] Error: Attempting to JIT compile method:OrientationSensor.ReadingChanged Crash on IOS

Created on 18 Aug 2020  路  9Comments  路  Source: xamarin/Essentials

Description

I got an error while developing an app on ios using OrientationSensor.
System.ExecutionEngineException: Attempting to JIT compile method 'OrientationSensor.ReadingChanged

OrientationSensorTest.zip

public partial class PanoramaPage : ContentPage
{
    SphereApp sphereApp;
    public PanoramaPage()
    {
        InitializeComponent();

        /*Error: Attempting to JIT compile method: OrientationSensor.ReadingChanged*/
        OrientationSensor.ReadingChanged += (sender, args) =>
        {
            System.Numerics.Quaternion q = args.Reading.Orientation;

            // Convert to Urho Quaternion, and swap Y and Z values to
            // convert from right-hand to left-hand coordinates.
            sphereApp.Orientation = new Quaternion(q.X, q.Z, q.Y, q.W);
        };
    }
    protected override async void OnAppearing()
    {
        base.OnAppearing();
        // INITIALIZATION
        sphereApp = await UrhoSurface.Show<SphereApp>(new Urho.ApplicationOptions(assetsFolder: "Data"));

        try
        {
            OrientationSensor.Start(SensorSpeed.Default);
        }
        catch (Exception ex)
        {
            Content = new Label
            {
                //Text = "Sorry, the OrientationSensor is not supported on this device.",
                Text = ex.ToString(),
                VerticalOptions = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                Margin = new Thickness(50)
            };
        }
    }
    protected override void OnDisappearing()
    {
        base.OnDisappearing();
        OrientationSensor.Stop();
        UrhoSurface.OnDestroy();
    }
}

Basic Information

  • Version with issue: 1.5.3.2
  • Platform Target Frameworks: iOS: 13.6
  • Nuget Packages: Xamarin.Essentials 1.5.3.2
  • Affected Devices: iPad

Screenshots

OrientationSensor_Error
OrientationSensor_Error_2

bug

Most helpful comment

Moving the issue to mono/mono: https://github.com/mono/mono/issues/20272

All 9 comments

This is the project sample.
OrientationSensorTest.zip

Can you go into your iOS Build settings and check if you have this setting turned on:

image

sorry. I can't find the option: "Enable generic value type sharing" in visual studio for mac 2019. Can you show me the above option where?

image

@jamesmontemagno Rolf says this is a bug in the AOT compiler and should be moved to mono/mono.

I will have to find a workaround in the meantime. Will update as soon as I have anything.

Lovely thanks @mattleibow

Moving the issue to mono/mono: https://github.com/mono/mono/issues/20272

I discovered the cause of the error. My project was originally built using visual studio 2015, then I used visual studio 2019 to continue developing and got this error. I rebuilt the project using visual 2019 and it no longer has this error.

Thanks for the update! Closing now. Let us know if this happens again.

Was this page helpful?
0 / 5 - 0 ratings