Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor map control crashes when AOT compiled #2705

Open
p2pbsh opened this issue Jul 9, 2024 · 8 comments
Open

Blazor map control crashes when AOT compiled #2705

p2pbsh opened this issue Jul 9, 2024 · 8 comments

Comments

@p2pbsh
Copy link

p2pbsh commented Jul 9, 2024

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:

  1. Create a new blazor project using standard web app template, with wasm render mode configured.
  2. Add mapsui map control component to any wasm page, just attempting to render the basic component is all that is needed.
  3. Enable AOT option in project
  4. Publish and run app.

Expected behavior
Map control renders on page.

Screenshots
error

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.

@p2pbsh
Copy link
Author

p2pbsh commented Jul 9, 2024

@inforithmics

@inforithmics
Copy link
Contributor

inforithmics commented Jul 9, 2024

Have you tried targeting .NET 9 Preview (Has some AOT Improvements)

@p2pbsh
Copy link
Author

p2pbsh commented Jul 9, 2024

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?

@inforithmics
Copy link
Contributor

inforithmics commented Jul 9, 2024

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.

@p2pbsh
Copy link
Author

p2pbsh commented Jul 10, 2024

There you go boss

Two publish configs in MapAotTest.Client.csproj, config 1 works, config 2 produces the error I described.

MapAotTest.zip

@inforithmics
Copy link
Contributor

  1. 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
  2. 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.

@inforithmics
Copy link
Contributor

inforithmics commented Jul 13, 2024

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.

mono/SkiaSharp#2927

@p2pbsh
Copy link
Author

p2pbsh commented Jul 13, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants