From 166ac06e3e97b3cb3b695452e935fd9c74cd92fb Mon Sep 17 00:00:00 2001 From: Joseph Cloutier Date: Mon, 27 May 2024 12:10:00 -0400 Subject: [PATCH] Store images as data when in a web worker. More work may need to be done to transfer an image from a worker to the main thread, but this will at least prevent crashes. --- src/lime/graphics/Image.hx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lime/graphics/Image.hx b/src/lime/graphics/Image.hx index 1af941fe5..c825d9d84 100644 --- a/src/lime/graphics/Image.hx +++ b/src/lime/graphics/Image.hx @@ -32,10 +32,11 @@ import lime.utils.UInt8Array; #if !display import lime._internal.backend.html5.HTML5HTTPRequest; #end -import js.html.CanvasElement; -import js.html.ImageElement; -import js.html.Image as JSImage; import js.Browser; +import js.html.CanvasElement; +import js.html.Image as JSImage; +import js.html.ImageElement; +import lime._internal.backend.html5.HTML5Thread; #elseif flash import flash.display.Bitmap; import flash.display.BitmapData; @@ -230,6 +231,13 @@ class Image { #if (js && html5) type = CANVAS; + + #if lime_threads + if (HTML5Thread.current().isWorker()) + { + type = DATA; + } + #end #elseif flash type = FLASH; #else