You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I realize I'm probably operating in very unsupported territory here, but I was doing some experimenting with Sharp on WASM and wanted to report what I found in case the developers want to look at it in the future.
I am experimenting with using the WASM32 backend for Sharp in Deno, mostly to see if it works but also to reduce my use of native modules. Since Deno doesn't support fine-grained control of Node dependencies, I did this test by creating a modified Sharp package to remove all optional dependencies except the WASM32 backend, but the specific problem arises just from loading @img/sharp-wasm32/sharp.node.
Sharp correctly loads the WASM32 backend on Deno but the Enscripten-generated loader code assigns to global.Worker, overriding the Worker class with an incompatible one. The result is that code that uses web workers and loads @img/sharp-wasm32 will no longer work, as new Worker(...) creates an object that is not compatible with the Web Workers API.
Steps to reproduce:
Load @img/sharp-wasm32
Try to use Web Workers with new Worker (specifically, addEventListener is missing)
The text was updated successfully, but these errors were encountered:
The WebAssembly build of sharp is compiled using ENVIRONMENT_IS_NODE as emscripten currently requires this to generate a Node.js compatible binary (with a global Worker defined, as you've seen).
Closing as I don't think there's anything we can do - I've linked to a couple of upstream issues that you should subscribe to. Happy to re-open if we need to do anything to take advantage of any changes they introduce.
I realize I'm probably operating in very unsupported territory here, but I was doing some experimenting with Sharp on WASM and wanted to report what I found in case the developers want to look at it in the future.
I am experimenting with using the WASM32 backend for Sharp in Deno, mostly to see if it works but also to reduce my use of native modules. Since Deno doesn't support fine-grained control of Node dependencies, I did this test by creating a modified Sharp package to remove all optional dependencies except the WASM32 backend, but the specific problem arises just from loading
@img/sharp-wasm32/sharp.node
.Sharp correctly loads the WASM32 backend on Deno but the Enscripten-generated loader code assigns to
global.Worker
, overriding theWorker
class with an incompatible one. The result is that code that uses web workers and loads@img/sharp-wasm32
will no longer work, asnew Worker(...)
creates an object that is not compatible with the Web Workers API.Steps to reproduce:
@img/sharp-wasm32
new Worker
(specifically,addEventListener
is missing)The text was updated successfully, but these errors were encountered: