.NET MAUI 8 + v200.3: App crashes on page change when location is active

827
2
12-27-2023 07:55 AM
Labels (3)
SokoFromNZ
Occasional Contributor

Hello,

Coming from this issue I have found an even more severe one with the current versions of MAUI & ArcGIS Runtime on Android which renders the whole runtime non-usable!

This is a standard .NET8 MAUI app with two pages:

Page 1: Plain ArcGIS Map with location enabled:

using System;
using System.Threading;
using System.Threading.Tasks;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.UI;
using Microsoft.Maui.Devices.Sensors;
using Map = Esri.ArcGISRuntime.Mapping.Map;

namespace ArcGISTry1;

public partial class MainPage
{
    public MainPage()
    {
        InitializeComponent();

        // Create the UI, setup the control references and execute initialization
        _ = Initialize();
    }

    private async Task Initialize()
    {
        // Just to ask for users permission
        await GetCurrentLocation();

        // Set map to mapview
        MyMapView.Map = new Map(BasemapStyle.OSMLightGray);
        MyMapView.Loaded += MyMapViewOnLoaded;
    }

    void MyMapViewOnLoaded(object? sender, EventArgs e)
    {
        MyMapView.LocationDisplay.IsEnabled = true;
        MyMapView.LocationDisplay.AutoPanMode = LocationDisplayAutoPanMode.Navigation;
    }

    public async Task GetCurrentLocation()
    {
        try
        {

            GeolocationRequest request = new GeolocationRequest(GeolocationAccuracy.Medium, TimeSpan.FromSeconds(10));

            var cancelTokenSource = new CancellationTokenSource();

            var location = await Geolocation.Default.GetLocationAsync(request, cancelTokenSource.Token);

            if (location != null)
                Console.WriteLine($"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}");
        }
        // Catch one of the following exceptions:
        //   FeatureNotSupportedException
        //   FeatureNotEnabledException
        //   PermissionException
        catch (Exception ex)
        {
            // Unable to get location
        }
    }
}

 

Page 2 is just a plain text input.

When changing pages to page 2 and back again the app crashes.

Only thing I get with attached Visual Studio 17.8.3 (see last line):

[EGL_emulation] app_time_stats: avg=228.13ms min=13.63ms max=4884.68ms count=23
[OnBackInvokedCallback] OnBackInvokedCallback is not enabled for the application.
[OnBackInvokedCallback] Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
[TabLayout] MODE_SCROLLABLE + GRAVITY_FILL is not supported, GRAVITY_START will be used instead
[TextureView] onSurfaceTextureAvailable
[TextureView] onSurfaceTextureAvailable done
[TextureView] Starting pulse
[libc] Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x40 in tid 11029 (Rendering threa), pid 10965 (name.arcgistry1)

 

Find the full solution attached.

Please help!

PS: It does not matter if the location moves between leaving and coming back to the map page.

2 Replies
PreetiMaske
Esri Contributor

Thanks for reporting it to us, I am able to reproduce the issue and have a logged a bug in our system. We will investigate it further next week. I will report back here if we find a way to workaround the crash.

pshearon
New Contributor II

The problem is the Ping Animation, whenever that tries to happen the system crashes. In order to get around this for now you can issue  MyMapView.LocationDisplay.ShowPingAnimationSymbol = false;

This will stop you from crashing but you will not get the ping animation.