mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-03 14:19:20 +00:00
Handle SharedArrayBuffer for PNG data
The Emscripten support for setting window icons introduced in #14490 does not work when using pthreads. Using `SetWindowIcon` will cause the program to crash. The reason for that is that the `Blob` constructor does not accept shared memory (`SharedArrayBuffer`). We need to create a local copy of the icon data if necessary.
This commit is contained in:
committed by
Sam Lantinga
parent
f173fd28f0
commit
7e78636e8e
@@ -812,6 +812,11 @@ static bool Emscripten_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window,
|
||||
// Pass PNG data to JavaScript
|
||||
MAIN_THREAD_EM_ASM({
|
||||
var pngData = HEAPU8.subarray($0, $0 + $1);
|
||||
if (pngData.buffer instanceof SharedArrayBuffer) {
|
||||
// explicitly create a copy
|
||||
pngData = new Uint8Array(pngData);
|
||||
}
|
||||
|
||||
var blob = new Blob([pngData], {type: 'image/png'});
|
||||
var url = URL.createObjectURL(blob);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user