AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.45k stars 2.21k forks source link

[WebAssembly] .NET 7 RC1 - Unhandled exception rendering component: GL is not defined #8965

Closed wieslawsoltes closed 2 years ago

wieslawsoltes commented 2 years ago

Describe the bug

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: GL is not defined
      ReferenceError: GL is not defined
          at SKHtmlCanvas.createWebGLContext (https://localhost:5001/_content/Avalonia.Web.Blazor/SKHtmlCanvas.js:174:19)
          at new SKHtmlCanvas (https://localhost:5001/_content/Avalonia.Web.Blazor/SKHtmlCanvas.js:8:38)
          at SKHtmlCanvas.init (https://localhost:5001/_content/Avalonia.Web.Blazor/SKHtmlCanvas.js:47:22)
          at SKHtmlCanvas.initGL (https://localhost:5001/_content/Avalonia.Web.Blazor/SKHtmlCanvas.js:27:33)
          at Object.invokeJSFromDotNet (https://localhost:5001/_framework/blazor.webassembly.js:1:3219)
          at Object.Dt [as invokeJSFromDotNet] (https://localhost:5001/_framework/blazor.webassembly.js:1:60823)
          at Object.Ii (https://localhost:5001/_framework/dotnet..1g6d4ircqv.js:5:70880)
          at _mono_wasm_invoke_js_blazor (https://localhost:5001/_framework/dotnet..1g6d4ircqv.js:7683:71)
          at do_icall (wasm://wasm/053a4952:wasm-function[15936]:0x5b6634)
          at do_icall_wrapper (wasm://wasm/053a4952:wasm-function[15883]:0x5b550e)
Microsoft.JSInterop.JSException: GL is not defined
ReferenceError: GL is not defined
    at SKHtmlCanvas.createWebGLContext (https://localhost:5001/_content/Avalonia.Web.Blazor/SKHtmlCanvas.js:174:19)
    at new SKHtmlCanvas (https://localhost:5001/_content/Avalonia.Web.Blazor/SKHtmlCanvas.js:8:38)
    at SKHtmlCanvas.init (https://localhost:5001/_content/Avalonia.Web.Blazor/SKHtmlCanvas.js:47:22)
    at SKHtmlCanvas.initGL (https://localhost:5001/_content/Avalonia.Web.Blazor/SKHtmlCanvas.js:27:33)
    at Object.invokeJSFromDotNet (https://localhost:5001/_framework/blazor.webassembly.js:1:3219)
    at Object.Dt [as invokeJSFromDotNet] (https://localhost:5001/_framework/blazor.webassembly.js:1:60823)
    at Object.Ii (https://localhost:5001/_framework/dotnet..1g6d4ircqv.js:5:70880)
    at _mono_wasm_invoke_js_blazor (https://localhost:5001/_framework/dotnet..1g6d4ircqv.js:7683:71)
    at do_icall (wasm://wasm/053a4952:wasm-function[15936]:0x5b6634)
    at do_icall_wrapper (wasm://wasm/053a4952:wasm-function[15883]:0x5b550e)
   at Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.InvokeJS(String identifier, String argsJson, JSCallResultType resultType, Int64 targetInstanceId)
   at Microsoft.JSInterop.JSInProcessRuntime.Invoke[GLInfo](String identifier, Int64 targetInstanceId, Object[] args)
   at Microsoft.JSInterop.Implementation.JSInProcessObjectReference.Invoke[GLInfo](String identifier, Object[] args)
   at Avalonia.Web.Blazor.Interop.JSModuleInterop.Invoke[GLInfo](String identifier, Object[] args) in /_/src/Web/Avalonia.Web.Blazor/Interop/JSModuleInterop.cs:line 38
   at Avalonia.Web.Blazor.Interop.SKHtmlCanvasInterop.InitGL() in /_/src/Web/Avalonia.Web.Blazor/Interop/SKHtmlCanvasInterop.cs:line 49
   at Avalonia.Web.Blazor.AvaloniaView.OnAfterRenderAsync(Boolean firstRender) in /_/src/Web/Avalonia.Web.Blazor/AvaloniaView.razor.cs:line 268
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

ShadowMarker789 commented 2 years ago

Possibly related dotnet-runtime issue

https://github.com/dotnet/runtime/issues/76077

mattleibow commented 2 years ago

I know the Avalonia team did it first, but this is my PR that seems to work on net6 and net7 - without using any copied values from runtime source: https://github.com/mono/SkiaSharp/pull/2268

maxkatz6 commented 2 years ago

Closing as it seems to not be an issue with new SkiaSharp