Mapsui: [QUESTION] App crashes when deployed to iOS. Mapsui.Maui 4.0.0-beta.8

I have just created a .net MAUI app (net6.0) and installed the Mapsui.Maui from NuGet.

I just followed the instructions defined in “Mapsui MAUI getting started” guide.

The app builds and runs well on Windows and Android. It also builds for iOS but when I try to launch the app in iPad and iPhone, it crashes with the following error output :

[0:] An error occurred: '@rpath/libSkiaSharp.framework/libSkiaSharp'. Callstack: '   at SkiaSharp.SKPaint..ctor()
   at Mapsui.Rendering.Skia.LabelStyleRenderer..ctor()
   at Mapsui.Rendering.Skia.MapRenderer..ctor()
   at Mapsui.UI.Maui.MapControl..ctor()
   at MauiApp1_60.MainPage..ctor() in D:\Projeler\TEMP\MauiApp1-60\MainPage.xaml.cs:line 11
   at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, Object[] parameters, Boolean wrapExceptions)'
The app has been terminated.

It sounds like there is problem with SkiaSharp. When remove the construction of mapcontrol, it runs. So i think it is not related to any provisioning or certificate issue.

I also added the .UseSkiaSharp() command in MauiProgram class as :

public static MauiApp CreateMauiApp()
	{
		var builder = MauiApp.CreateBuilder();
		builder
			.UseMauiApp<App>()
			.UseSkiaSharp(true)
			.ConfigureFonts(fonts =>
			{
				fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
				fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
			});

		return builder.Build();
	}

What i am doing wrong ? According to documentation, everything looks ok.

Expected Behavior

Showing a basic map.

Actual Behavior

App crashes

Basic Information

  • Version with issue:
    Mapsui.Maui (4.0.0-beta.8)

  • IDE:
    Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.5.0 (Windows 11)

  • Platform Target Frameworks: iOS: 13.6

  • Target Devices:
    iPad 9. Generation, iPadOs : 16.3.1

Detailed IDE/OS information (click to expand)

Microsoft Visual Studio Enterprise 2022
Version 17.5.0
VisualStudio.17.Release/17.5.0+33414.496
Microsoft .NET Framework
Version 4.8.09032

Installed Version: Enterprise

ASP.NET and Web Tools   17.5.317.37931
ASP.NET and Web Tools

Azure App Service Tools v3.0.0   17.5.317.37931
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools   17.5.317.37931
Azure Functions and Web Jobs Tools

C# Tools   4.5.0-6.23109.5+6a5a63bbc9f4449d9bd1e95a8f9624939c3ccdc3
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus   1.4.3 (main@2a4517a)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Microsoft Azure Tools for Visual Studio   2.9
Support for Azure Cloud Services projects

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio   17.5.9 (11975e6)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   6.5.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Razor (ASP.NET Core)   17.5.2.2307502+8b3141d86b738daf2ca3ed9c15b12513071fc676
Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools   17.2.40118.0
Microsoft SQL Server Data Tools

TypeScript Tools   17.0.20105.2003
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   4.5.0-6.23109.5+6a5a63bbc9f4449d9bd1e95a8f9624939c3ccdc3
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   17.5.0-beta.23053.5+794b7c259d9646a7eb685dad865aa27da7940a21
Microsoft Visual F# Tools

Visual Studio IntelliCode   2.2
AI-assisted development for Visual Studio.

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

VSPackage Extension   1.0
VSPackage Visual Studio Extension Detailed Info

Xamarin   17.5.0.173 (d17-5@33e727c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   17.5.3.46 (remotes/origin/d17-5@e4dd80b2bb)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   17.5.41 (ba80d05)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   13.2.0.0 (d17-5/797e2e1)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: 6dd9def
    Java.Interop: xamarin/java.interop/main@149d70fe
    SQLite: xamarin/sqlite/3.40.0@fdc1e34
    Xamarin.Android Tools: xamarin/xamarin-android-tools/main@9f02d77


Xamarin.iOS and Xamarin.Mac SDK   16.2.0.5 (7738c90c9)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 22 (11 by maintainers)

Most upvoted comments

I am usually running on newest VS release (just recently updated to 17.6.3). I’ve not seen it work with Hot Reload at any time, so I can’t point to a regression of any kind. Version of .NET MAUI follows the installed version of Visual Studio. Running on iPad OS Version 16.5 More info/other reports can be found on the issue on the SkiaSharp repo I linked earlier (https://github.com/mono/SkiaSharp/issues/2410). I suppose it would make more sense to continue the discussion there.

@Inrego Thanks for that information. Although I am not sure if this will apply to all situations. SkiaSharp uses a native library, and if something is wrong with pointers to native memory this does not always result in the same behavior. If you point outside of allocated memory what happens depends on what data is on the outside. It could be harmless, it could result in incorrect behavior, or it could crash the app. So, in the end I think there is a real bug in there but it does not always show. This makes it such a hard issue.

I disagree. It’s always the same behavior as far as I’m aware (100% reproducible). As soon as you use any objects from the SkiaSharp namespace while using Hot Restart, the app crashes. I think it’s more an issue related to native libraries not being loaded correctly when using Hot Restart (not to be confused with Hot Reload).

Hot Restart is such a weird name for debugging using an iOS device connected directly to the Windows dev machine. But the name does hint at why there’s a difference between debugging one way versus another. Using Hot Restart, you don’t need a Mac build host. I assume they ship an empty ios app shell, and just load the compiled assemblies into it when debugging. For the same reasons, you can’t change the app icon among a few other metadata on Hot Restart. I guess there’s a limitation with this way of doing things, where you can’t load these native libraries. I’ve observed similar issues with SQLite.

I do think this issue is actually documented: https://learn.microsoft.com/en-us/dotnet/maui/ios/hot-restart#limitations

Static iOS libraries and frameworks aren’t supported and you may see runtime errors or crashes if your app attempts to load these.

When plugging your iOS device into the mac, and debugging through a Mac connection this way - the complete app is built, and this process includes native libraries properly.