mono / SkiaSharp

SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
MIT License
4.14k stars 522 forks source link

[BUG] SkiaSharp crashes in WebAssembly if building with non-Release/Debug build config #2847

Closed RPGillespie6 closed 3 weeks ago

RPGillespie6 commented 3 weeks ago

Description

Not actually sure if this is specifically a dotnet issue or a Skia issue, but since everything was working until adding Skia, I'm opening an issue in both places.

Essentially the problem is that you cannot use custom build configurations if using SkiaSharp + WASM or it will mysteriously crash at runtime on SKPaint dispose (after a using block). But it usually doesn't crash right away, it takes around 79 dispose calls in the repro code before the crash:

image

Code

Repro repo: https://github.com/RPGillespie6/dotnet_skia_wasm_crash

Build with Release build configuration and observe that the code runs to completion. Build with Release_WASM build configuration and observe that the code crashes on SKPaint dispose after 79 iterations. Confirmed this repo reproduces the problem on 2 different PCs (one with Intel i9, one with AMD Ryzen 7).

We use custom build configurations to set different #if flags, so it's kind of annoying to work around.

Expected Behavior

I expected SkiaSharp not to crash at runtime if using a build config other than Debug or Release in conjunction with webassembly build

Actual Behavior

SkiaSharp crashes at runtime when using a build config other than Debug or Release in conjunction with webassembly build

Version of SkiaSharp

2.88.3 (Current)

Last Known Good Version of SkiaSharp

2.88.2 (Previous)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Other (Please indicate in the description)

Platform / Operating System Version

Windows 11 + Chrome or Firefox

Devices

Desktop PC

Relevant Screenshots

No response

Relevant Log Output

No response

Code of Conduct

RPGillespie6 commented 3 weeks ago

Issue is a dotnet toolchain issue: