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

[BUG] [WinUI 3 / MAUI, 9.0 Preview 6, SkiaSharp 3.0-preview4.1] SKGLView crashes WinUI 3 MAUI App when the app is built in the unpackaged mode #2968

Open
1 task done
TommiGustafsson-HMP opened this issue Aug 13, 2024 · 2 comments
Labels

Comments

@TommiGustafsson-HMP
Copy link

Description

Technology stack

  • .NET 9.0 Preview 6
  • .NET MAUI 9.0 Preview 6
  • SkiaSharp 3.0-preview4.1
  • Windows / WinUI 3 1.5.x

Bug

SKGLView crashes the app at runtime when .NET MAUI App is built in the unpackaged mode (-p:WindowsPackageType=None).

Code

Steps to reproduce the bug

  1. Clone the public reproduction repository (link) 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.

Expected Behavior

The app would not crash at runtime.

Actual Behavior

The app crashes in the OnLoaded event of AngleSwapChainPanel at runtime.

Version of SkiaSharp

3.x (Alpha)

Last Known Good Version of SkiaSharp

Other (Please indicate in the description)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

Edition Windows 11 Pro
Version 23H2
OS build 22631.3958
Experience Windows Feature Experience Pack 1000.22700.1026.0

Devices

Processor 13th Gen Intel(R) Core(TM) i9-13980HX 2.20 GHz
Installed RAM 32,0 GB (31,6 GB usable)
System type 64-bit operating system, x64-based processor

Relevant Screenshots

No response

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>

Code of Conduct

  • I agree to follow this project's Code of Conduct
@TommiGustafsson-HMP
Copy link
Author

@mattleibow I ran analysis on the dump using WinDbg. It says the following:

0:000> !analyze -v
*******************************************************************************
*                                                                             *
*                        Exception Analysis                                   *
*                                                                             *
*******************************************************************************

Failed to request MethodData, not in JIT code range

KEY_VALUES_STRING: 1

    Key  : AV.Dereference
    Value: NullPtr

    Key  : AV.Fault
    Value: Read

    Key  : Analysis.CPU.mSec
    Value: 1890

    Key  : Analysis.Elapsed.mSec
    Value: 12794

    Key  : Analysis.IO.Other.Mb
    Value: 9

    Key  : Analysis.IO.Read.Mb
    Value: 2

    Key  : Analysis.IO.Write.Mb
    Value: 29

    Key  : Analysis.Init.CPU.mSec
    Value: 2781

    Key  : Analysis.Init.Elapsed.mSec
    Value: 19018

    Key  : Analysis.Memory.CommitPeak.Mb
    Value: 377

    Key  : Analysis.Version.DbgEng
    Value: 10.0.27725.1000

    Key  : Analysis.Version.Description
    Value: 10.2408.27.01 amd64fre

    Key  : Analysis.Version.Ext
    Value: 1.2408.27.1

    Key  : CLR.Engine
    Value: CORECLR

    Key  : CLR.Version
    Value: 9.0.24.47305

    Key  : Failure.Bucket
    Value: NULL_POINTER_READ_c0000005_coreclr.dll!ProcessCLRExceptionNew

    Key  : Failure.Hash
    Value: {c7c8b0e4-8662-6d89-0847-b939a6a3bc0f}

    Key  : Failure.Source.FileLine
    Value: 952

    Key  : Failure.Source.FilePath
    Value: D:\a\_work\1\s\src\coreclr\vm\exceptionhandling.cpp

    Key  : Failure.Source.SourceServerCommand
    Value: raw.githubusercontent.com/dotnet/runtime/990ebf52fc408ca45929fd176d2740675a67fab8/src/coreclr/vm/exceptionhandling.cpp

    Key  : Timeline.OS.Boot.DeltaSec
    Value: 923469

    Key  : Timeline.Process.Start.DeltaSec
    Value: 7

    Key  : WER.OS.Branch
    Value: ni_release

    Key  : WER.OS.Version
    Value: 10.0.22621.1

    Key  : WER.Process.Version
    Value: 1.0.0.0


FILE_IN_CAB:  WindowsMauiUnpackagedSKGLViewError.exe.31924.dmp

NTGLOBALFLAG:  0

APPLICATION_VERIFIER_FLAGS:  0

CONTEXT:  000001d80dfd45b8 -- (.cxr 0x1d80dfd45b8)
rax=0000000000000000 rbx=0000000000000000 rcx=0000000000000000
rdx=0000000000000000 rsi=0000000000000000 rdi=0000000100000000
rip=3f80000000000000 rsp=0000000000000000 rbp=0000000000000000
 r8=0000000000000000  r9=0000000000000000 r10=0000000000000000
r11=0000000000000000 r12=0000000000000000 r13=3f8000003f800000
r14=3f8000003f800000 r15=0000000000000000
iopl=0         nv up di pl nz na pe nc
cs=4df1  ss=0000  ds=0e08  es=01d8  fs=0000  gs=0001             efl=00000000
3f800000`00000000 ??              ???
Resetting default scope

EXCEPTION_RECORD:  000001d819de2c70 -- (.exr 0x1d819de2c70)
ExceptionAddress: 0000000000000000
   ExceptionCode: 7fb4fd98
  ExceptionFlags: 00007ffd
NumberParameters: 0

PROCESS_NAME:  WindowsMauiUnpackagedSKGLViewError.dll

READ_ADDRESS:  0000000000000000 

ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%p referenced memory at 0x%p. The memory could not be %s.

EXCEPTION_CODE_STR:  c0000005

FAULTING_THREAD:  ffffffff

STACK_TEXT:  
00007ffe`6e67be7f 00007ffe`6e67be7f coreclr!ProcessCLRExceptionNew+0xfb


STACK_COMMAND:  ** Pseudo Context ** Pseudo ** Value: 3 ** ; kb

FAULTING_SOURCE_LINE:  D:\a\_work\1\s\src\coreclr\vm\exceptionhandling.cpp

FAULTING_SOURCE_FILE:  D:\a\_work\1\s\src\coreclr\vm\exceptionhandling.cpp

FAULTING_SOURCE_LINE_NUMBER:  952

FAULTING_SOURCE_SRV_COMMAND:  https://raw.githubusercontent.com/dotnet/runtime/990ebf52fc408ca45929fd176d2740675a67fab8/src/coreclr/vm/exceptionhandling.cpp

FAULTING_SOURCE_CODE:  
No source found for 'D:\a\_work\1\s\src\coreclr\vm\exceptionhandling.cpp'


SYMBOL_NAME:  coreclr!ProcessCLRExceptionNew+fb

MODULE_NAME: coreclr

IMAGE_NAME:  coreclr.dll

FAILURE_BUCKET_ID:  NULL_POINTER_READ_c0000005_coreclr.dll!ProcessCLRExceptionNew

OS_VERSION:  10.0.22621.1

BUILDLAB_STR:  ni_release

OSPLATFORM_TYPE:  x64

OSNAME:  Windows 10

IMAGE_VERSION:  9.0.24.47305

FAILURE_ID_HASH:  {c7c8b0e4-8662-6d89-0847-b939a6a3bc0f}

Followup:     MachineOwner
---------

At this point, I am using Visual Studio 2022 Community Preview 17.12.0 Preview 5.0, .NET MAUI 9.0 RC2, SkiaSharp 3.118.0-Preview1.2. I have also activated Full Dump (2) in Registry Editor for the test app.

@taublast
Copy link
Contributor

A quick guess: before net9 we would never expect an unpackaged mode on Windows, seems it was implemented to speed up development (no idea why, windows was already the fastest platform to debug a MAUI app haha).
Anyway it may be that skiasharp is calling some code present in packaged mode only, resulting in this crash.
https://x.com/dotMorten/status/1849193454414573679

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

No branches or pull requests

2 participants