Mapsui
Mapsui copied to clipboard
Blazor map control crashes when AOT compiled
Mapsui Version 5 beta 1, 5 beta 2
Mapsui Platform Blazor
Device Windows 10, Microsoft Edge browser.
Describe the bug When publishing a blazor project with AOT disabled, mapsui map control works correctly. Publishing same project with AOT enabled, map control fails to render and throws an unhandled exception.
To Reproduce Steps to reproduce the behavior:
- Create a new blazor project using standard web app template, with wasm render mode configured.
- Add mapsui map control component to any wasm page, just attempting to render the basic component is all that is needed.
- Enable AOT option in project
- Publish and run app.
Expected behavior Map control renders on page.
Screenshots
Additional context Map control fails to render and I get the above exception in the browser developer console. Call stack is not particularly helpful, only thing that seems applicable are some references to skia canvas rendering, but don't really understand what I'm looking at.
@inforithmics
Have you tried targeting .NET 9 Preview (Has some AOT Improvements)
I have not, will give it a go. Was just curious or after some independent confirmation that the map control should AOT ok in mapsui 5?
Theoretically yes. But the publish for the Sample Page the AOT is currently disabled. For testing i enabled AOT and it still worked. So that's why I'm asking for a sample that reproduces the behavior.
There you go boss
- cd ..\MapAotTest\MapAotTest\MapAotTest
- dotnet publish -c Release -o ./pub
- http://localhost:5000
Two publish configs in MapAotTest.Client.csproj, config 1 works, config 2 produces the error I described.
- I compiled it with .NET 9 (SkiaSharp caused an AOT Compile Error) so it seems SkiaSharp in Version 2.88 is not AOT Comptible yet. So SkiaSharp needs to be updated to 3.0.0
- I reproduced the call stack for me it seems to be a tooling problem possible related to SkiaSharp see above.
So at the moment it seems not to be 100% compatible with AOT because of Third Party dependencies (SkiaSharp), So when SkiaSharp is released in Version 3.0.0 I could have a look at it again, Currently I cannot do so much.
With .Net 9 and SkiaSharp 3 (Beta) in AOT following Compilation Error occours MapAotTest.Client fehlerhaft mit 1 Fehler(n) (24.8s)
C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\9.0.0-preview.6.24327.7\Sdk\WasmApp.Common.targets(692,5): error :
Precompiling failed for D:\MapAotTest\MapAotTest\MapAotTest.Client\obj\Release\net9.0\wasm\for-publish\aot-in\Skia
Sharp.Views.Blazor.dll with exit code -1073741819.
Mono Ahead of Time compiler - compiling assembly D:\MapAotTest\MapAotTest\MapAotTest.Client\obj\Release\net9.0\was
m\for-publish\aot-in\SkiaSharp.Views.Blazor.dll
Could not load signature of SkiaSharp.Views.Blazor.Internal.JSModuleInterop:get_Module due to: Could not resolve t
ype with token 0100003b from typeref (expected class 'Microsoft.JSInterop.IJSUnmarshalledObjectReference' in assem
bly 'Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60') assembly:Microsoft.J
SInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 type:Microsoft.JSInterop.IJSUnmarshall
edObjectReference member:(null)
Could not load signature of SkiaSharp.Views.Blazor.Internal.JSModuleInterop:get_Module due to: Could not resolve t
ype with token 0100003b from typeref (expected class 'Microsoft.JSInterop.IJSUnmarshalledObjectReference' in assem
bly 'Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60') assembly:Microsoft.J
SInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 type:Microsoft.JSInterop.IJSUnmarshall
edObjectReference member:(null)
Failed to load methodspec 0x2b000009 due to Could not resolve type with token 0100003b from typeref (expected clas
s 'Microsoft.JSInterop.IJSUnmarshalledObjectReference' in assembly 'Microsoft.JSInterop, Version=6.0.0.0, Culture=
neutral, PublicKeyToken=adb9793829ddae60') assembly:Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicK
eyToken=adb9793829ddae60 type:Microsoft.JSInterop.IJSUnmarshalledObjectReference member:(null).
Run with MONO_LOG_LEVEL=debug for more information.
Failed to load methodspec 0x2b000018 due to Could not resolve type with token 0100003b from typeref (expected clas
s 'Microsoft.JSInterop.IJSUnmarshalledObjectReference' in assembly 'Microsoft.JSInterop, Version=6.0.0.0, Culture=
neutral, PublicKeyToken=adb9793829ddae60') assembly:Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicK
eyToken=adb9793829ddae60 type:Microsoft.JSInterop.IJSUnmarshalledObjectReference member:(null).
Run with MONO_LOG_LEVEL=debug for more information.
MapAotTest Fehlgeschlagen (1.2s) → bin\Release\net9.0\MapAotTest.dll
So I think this could be the problem why it doesn't start up because jsinterop is important for webassembly functionality, I think when SkiaSharp is updated to .NET 8 this sould be solved.
https://github.com/mono/SkiaSharp/pull/2927
Thanks for taking a look and shinning some light on the issue.
I have mapsui built into my blazor app now and its awesome, just this one issue blocking me giving the app the AOT perf boost it needs. Fingers crossed skia 3 resolves, cheers fella.
Working great now in beta 7.