SkiaSharp
SkiaSharp copied to clipboard
[BUG] An ExecutionEngineException is thrown when an SKGLView is assigned to ContentView.Content
Description
When a class that is inherited from ContentView assigns an SKGLView to it's Content field this results in a ExecutionEngineException with the message "Exception of type 'System.ExecutionEngineException' was thrown.", there is no stack trace and the application shuts down.
It only occurs when creating a MAUI 9 project. Not when creating a MAUI 8 project.
Using SkiaSharp 3.116.1.
Steps to reproduce:
- Create a default MAUI 9 template (with everything updated to the latest to date).
- Add SkiaSharp reference
- Add the UseSkiaSharp in MauiProgram
- Create a class like the 'MapControl' below
- Assign that class to the MainWindow Content
- The application will crash.
Code
Here is a minimal sample to reproduce it:
https://github.com/pauldendulk/skiasharpcrash
Some snippets from that repo:
using SkiaSharp.Views.Maui.Controls;
namespace MauiApp1;
public class MapControl : ContentView
{
public MapControl()
{
Content = new SKGLView();
}
}
var mapControl = new MapControl();
Content = mapControl;
Expected Behavior
No crash
Actual Behavior
An ExecutionEngineException with the message "Exception of type 'System.ExecutionEngineException' was thrown." and the application shuts down.
Version of SkiaSharp
3.116.0 (Current)
Last Known Good Version of SkiaSharp
I did not test this.
IDE / Editor
Visual Studio (Windows)
Platform / Operating System
Windows
Platform / Operating System Version
Windows 11
Devices
Dell laptop
Relevant Screenshots
No response
Relevant Log Output
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
We've found some similar issues:
- #3113 , similarity score: 83%
- #2648 , similarity score: 82%
If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.
Note: You can give me feedback by 👍 or 👎 this comment.
We've found some similar issues:
- [BUG] .Net MAUI 9.0 Windows platform application crashes when using the SKGLView control #3113 , similarity score: 83%
This one is similar, maybe the same problem at heart, but in my bug report we don't need to do anything special with package mode. It is just a default template adding an SKGLView.
- [BUG] SKCanvasView control crashes in .NET 7 and 8 MAUI #2648 , similarity score: 82%
This one is different. It simply does not call UseSkiaSharp
This is probably the same issue: https://github.com/mono/SkiaSharp/issues/2968
If you are going to release your app in Microsoft Store only, you can fix this error by setting WindowsPackageType to MSIX, and creating a launch profile with commandName MsixPackage. This will create a packaged app (MSIX).