dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.98k stars 1.71k forks source link

[Windows, .NET 9.0 Preview 6, SkiaSharp 3.0-preview4.1] SKGLView crashes the app when .NET MAUI App is built in the unpackaged mode #23737

Open TommiGustafsson-HMP opened 1 month ago

TommiGustafsson-HMP commented 1 month ago

Description

Using .NET 9.0 Preview 6, .NET MAUI 9.0 Preview 6, and SkiaSharp 3.0-preview4.1, on the Windows platform, including SkiaSharp's SKGLView in a page crashes the app at run time, when the app is built in the unpackaged mode (-p:WindowsPackageType=None). It works in the packaged mode, though. Application event log messages in Event Viewer hint at that it is an ANGLE or GLES problem in the unpackaged mode.

Steps to Reproduce

  1. Clone the public reproduction repository (see below) and open the solution in Visual Studio 2022 Preview (latest).
  2. First, let's check that things work in the packaged mode.
  3. Select Windows Machine and click the green Debug button.
  4. The app should start.
  5. Click the Click Me button. A new page with some text should open. The app will not crash.
  6. Close the app and go back to Visual Studio 2022 Preview.
  7. Open the Developer PowerShell and check that you are in the solution folder.
  8. Delete bin and obj folders. (Otherwise the unpackaged app will not start.)
  9. Build the unpackaged app with dotnet build -f:net9.0-windows10.0.19041.0 -c:Debug -p:WindowsPackageType=None -p:RuntimeIdentifierOverride=win10-x64 -p:WindowsAppSDKSelfContained=true
  10. Open File Explorer and go to bin\Debug\net9.0-windows10.0.19041.0\win10-x64. The unpackaged app should be there.
  11. Click on WindowsMauiUnpackagedSKGLViewError.exe.
  12. The app will start.
  13. Click on the Click me button.
  14. The app will crash.
  15. Now, open Event Viewer and see the Windows Logs → Application error messages.

Link to public reproduction project repository

https://github.com/hyvanmielenpelit/WindowsMauiUnpackagedSKGLViewError

Version with bug

9.0.0-preview.6.24327.7

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

No. The unpackaged app does not work. (Some services require us to use the unpackaged app.)

Relevant log output

Log Name:      Application
Source:        .NET Runtime
Date:          20.7.2024 21.57.32
Event ID:      1026
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Description:
Application: WindowsMauiUnpackagedSKGLViewError.exe
CoreCLR Version: 9.0.24.32707
.NET Version: 9.0.0-preview.6.24327.7
Description: The process was terminated due to an unhandled exception.
Stack:
   at SkiaSharp.Views.GlesInterop.Egl.eglGetPlatformDisplayEXT(UInt32, IntPtr, Int32[])
   at SkiaSharp.Views.GlesInterop.Egl.eglGetPlatformDisplayEXT(UInt32, IntPtr, Int32[])
   at SkiaSharp.Views.GlesInterop.GlesContext.InitializeDisplay()
   at SkiaSharp.Views.GlesInterop.GlesContext..ctor()
   at SkiaSharp.Views.Windows.AngleSwapChainPanel.OnLoaded(System.Object, Microsoft.UI.Xaml.RoutedEventArgs)
   at WinRT._EventSource_global__Microsoft_UI_Xaml_RoutedEventHandler+EventState.<GetEventInvoke>b__1_0(System.Object, Microsoft.UI.Xaml.RoutedEventArgs)
   at ABI.Microsoft.UI.Xaml.RoutedEventHandler.Do_Abi_Invoke(IntPtr, IntPtr, IntPtr)
   at ABI.Microsoft.UI.Xaml.IApplicationStaticsMethods.Start(WinRT.IObjectReference, Microsoft.UI.Xaml.ApplicationInitializationCallback)
   at Microsoft.UI.Xaml.Application.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback)
   at WindowsMauiUnpackagedSKGLViewError.WinUI.Program.Main(System.String[])

Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name=".NET Runtime" />
    <EventID Qualifiers="0">1026</EventID>
    <Version>0</Version>
    <Level>2</Level>
    <Task>0</Task>
    <Opcode>0</Opcode>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2024-07-20T18:57:32.8237381Z" />
    <EventRecordID>82274</EventRecordID>
    <Correlation />
    <Execution ProcessID="2176" ThreadID="0" />
    <Channel>Application</Channel>
  </System>
  <EventData>
    <Data>Application: WindowsMauiUnpackagedSKGLViewError.exe
CoreCLR Version: 9.0.24.32707
.NET Version: 9.0.0-preview.6.24327.7
Description: The process was terminated due to an unhandled exception.
Stack:
   at SkiaSharp.Views.GlesInterop.Egl.eglGetPlatformDisplayEXT(UInt32, IntPtr, Int32[])
   at SkiaSharp.Views.GlesInterop.Egl.eglGetPlatformDisplayEXT(UInt32, IntPtr, Int32[])
   at SkiaSharp.Views.GlesInterop.GlesContext.InitializeDisplay()
   at SkiaSharp.Views.GlesInterop.GlesContext..ctor()
   at SkiaSharp.Views.Windows.AngleSwapChainPanel.OnLoaded(System.Object, Microsoft.UI.Xaml.RoutedEventArgs)
   at WinRT._EventSource_global__Microsoft_UI_Xaml_RoutedEventHandler+EventState.&lt;GetEventInvoke&gt;b__1_0(System.Object, Microsoft.UI.Xaml.RoutedEventArgs)
   at ABI.Microsoft.UI.Xaml.RoutedEventHandler.Do_Abi_Invoke(IntPtr, IntPtr, IntPtr)
   at ABI.Microsoft.UI.Xaml.IApplicationStaticsMethods.Start(WinRT.IObjectReference, Microsoft.UI.Xaml.ApplicationInitializationCallback)
   at Microsoft.UI.Xaml.Application.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback)
   at WindowsMauiUnpackagedSKGLViewError.WinUI.Program.Main(System.String[])
</Data>
  </EventData>
</Event>

Log Name:      Application
Source:        Application Error
Date:          20.7.2024 21.57.33
Event ID:      1000
Task Category: Application Crashing Events
Level:         Error
Keywords:      
Description:
Faulting application name: WindowsMauiUnpackagedSKGLViewError.exe, version: 1.0.0.0, time stamp: 0x667d0000
Faulting module name: coreclr.dll, version: 9.0.24.32707, time stamp: 0x667de227
Exception code: 0xc0000005
Fault offset: 0x00000000002de54e
Faulting process ID: 0x0x880
Faulting application start time: 0x0x1DADAD6AC829340
Faulting application path: C:\hmp\WindowsMauiUnpackagedSKGLViewError\WindowsMauiUnpackagedSKGLViewError\WindowsMauiUnpackagedSKGLViewError\bin\Debug\net9.0-windows10.0.19041.0\win10-x64\WindowsMauiUnpackagedSKGLViewError.exe
Faulting module path: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\9.0.0-preview.6.24327.7\coreclr.dll
Report ID: 3e1585be-c9dd-41c0-aa20-9933b81efeae
Faulting package full name: 
Faulting package-relative application ID: 
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Application Error" Guid="{a0e9b465-b939-57d7-b27d-95d8e925ff57}" />
    <EventID>1000</EventID>
    <Version>0</Version>
    <Level>2</Level>
    <Task>100</Task>
    <Opcode>0</Opcode>
    <Keywords>0x8000000000000000</Keywords>
    <TimeCreated SystemTime="2024-07-20T18:57:33.1772821Z" />
    <EventRecordID>82275</EventRecordID>
    <Correlation />
    <Execution ProcessID="52744" ThreadID="31284" />
    <Channel>Application</Channel>
  </System>
  <EventData>
    <Data Name="AppName">WindowsMauiUnpackagedSKGLViewError.exe</Data>
    <Data Name="AppVersion">1.0.0.0</Data>
    <Data Name="AppTimeStamp">667d0000</Data>
    <Data Name="ModuleName">coreclr.dll</Data>
    <Data Name="ModuleVersion">9.0.24.32707</Data>
    <Data Name="ModuleTimeStamp">667de227</Data>
    <Data Name="ExceptionCode">c0000005</Data>
    <Data Name="FaultingOffset">00000000002de54e</Data>
    <Data Name="ProcessId">0x880</Data>
    <Data Name="ProcessCreationTime">0x1dadad6ac829340</Data>
    <Data Name="AppPath">C:\hmp\WindowsMauiUnpackagedSKGLViewError\WindowsMauiUnpackagedSKGLViewError\WindowsMauiUnpackagedSKGLViewError\bin\Debug\net9.0-windows10.0.19041.0\win10-x64\WindowsMauiUnpackagedSKGLViewError.exe</Data>
    <Data Name="ModulePath">C:\Program Files\dotnet\shared\Microsoft.NETCore.App\9.0.0-preview.6.24327.7\coreclr.dll</Data>
    <Data Name="IntegratorReportId">3e1585be-c9dd-41c0-aa20-9933b81efeae</Data>
    <Data Name="PackageFullName">
    </Data>
    <Data Name="PackageRelativeAppId">
    </Data>
  </EventData>
</Event>
github-actions[bot] commented 1 month ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

kevinxufei commented 1 month ago

This issue has been verified using Visual Studio 17.11.0 Preview 5.0(9.0.0-preview.6.24327.7). Can repro it with sample project.