-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebAssembly build #3522
Closed
Closed
WebAssembly build #3522
Commits on Jan 9, 2023
-
This is a WebAssembly build of sharp usable in Node.js and Stackblitz environments. There is quite a lot going on here to make it work, so I won't list all the implementation details I had to make it in the PR description, but instead would ask you to refer to the comments which hopefully explains the individual hacks, and feel free to ask any questions in the review. The build script itself piggy-backs on the excellent work done by @kleisauke in [wasm-vips](https://github.com/kleisauke/wasm-vips) with some modifications to use it only for building libvips rather than custom bindings. One thing I'll emphasise is that this is a build made specifically for Node.js / Stackblitz with the intention of being 1:1 API-compatible - among other things, it means that Wasm instantiation is intentionally synchronous, and that it will use the native filesystem via Node.js raw filesystem. I had / have a separate branch with an almost working browser build of sharp, but that requires some API changes to be usable in a browser without locking the main thread and with accepting e.g. `File` object instead of using virtual filesystem, so for now keeping it out of scope. The concurrency is currently limited to a fixed-size threadpool. While I made it possible to create threads on-demand in recent versions of Emscripten, there are still some issues and bugs when trying to use it with internal libvips threadpool, so for now keeping a fixed-size threadpool is a safer and time-tested option. Among other things, this will run only one concurrent sharp operation at a time. Also, in Stackblitz environment libvips will be limited to only 2 threads to keep memory usage under control - this is done because libvips already always needs +3 extra threads, and async emnapi operation will need yet another +1 thread per async operation, so the number of Workers quickly adds up. Additionally, some formats and operations - namely, SVG, DZI and text operations - are currently unsupported just like they're in wasm-vips. Text (both on its own and in SVG) is notoriously difficult due to lots of questions around font loading (Local Font Access API, remote fonts, etc.), but other formats might come in time. For now, though, this Wasm build should already cover most common use-cases. Finally, for now I committed the build script together with prebuilt binaries as part of the PR, as it made testing easiest, but I'd ask the maintainers to integrate it properly into their "prebuilt addon" system somehow - I can't do that from my end, as I neither know how it works nor have access to the storage.
Configuration menu - View commit details
-
Copy full SHA for 65e504a - Browse repository at this point
Copy the full SHA 65e504aView commit details -
Simple CI test integration for Wasm
Intentionally skipping coverage here, as Wasm doesn't cover everything.
Configuration menu - View commit details
-
Copy full SHA for b9e340c - Browse repository at this point
Copy the full SHA b9e340cView commit details
Commits on Jan 10, 2023
-
Configuration menu - View commit details
-
Copy full SHA for fd821e8 - Browse repository at this point
Copy the full SHA fd821e8View commit details
Commits on Jan 11, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 14bc120 - Browse repository at this point
Copy the full SHA 14bc120View commit details
Commits on Jan 12, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 5185b7d - Browse repository at this point
Copy the full SHA 5185b7dView commit details
Commits on Feb 9, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 295d478 - Browse repository at this point
Copy the full SHA 295d478View commit details
Commits on Feb 14, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 77c6ced - Browse repository at this point
Copy the full SHA 77c6cedView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3671432 - Browse repository at this point
Copy the full SHA 3671432View commit details
Commits on Feb 17, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 1c9356d - Browse repository at this point
Copy the full SHA 1c9356dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4e4eab1 - Browse repository at this point
Copy the full SHA 4e4eab1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 707341d - Browse repository at this point
Copy the full SHA 707341dView commit details -
Configuration menu - View commit details
-
Copy full SHA for af35596 - Browse repository at this point
Copy the full SHA af35596View commit details -
Upstream now does .ref/.unref automatically.
Configuration menu - View commit details
-
Copy full SHA for d5fe5e8 - Browse repository at this point
Copy the full SHA d5fe5e8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9e81ee7 - Browse repository at this point
Copy the full SHA 9e81ee7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 514198f - Browse repository at this point
Copy the full SHA 514198fView commit details
Commits on Aug 5, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 292d2a3 - Browse repository at this point
Copy the full SHA 292d2a3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 32a6c07 - Browse repository at this point
Copy the full SHA 32a6c07View commit details -
Configuration menu - View commit details
-
Copy full SHA for 574f7d9 - Browse repository at this point
Copy the full SHA 574f7d9View commit details -
Configuration menu - View commit details
-
Copy full SHA for fce6988 - Browse repository at this point
Copy the full SHA fce6988View commit details -
Another attempt to fix npm install
Little tricky but now this should work both for rebuilds and for normal installation as a dependency.
Configuration menu - View commit details
-
Copy full SHA for 294edf3 - Browse repository at this point
Copy the full SHA 294edf3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 06fa41f - Browse repository at this point
Copy the full SHA 06fa41fView commit details -
Configuration menu - View commit details
-
Copy full SHA for e110f06 - Browse repository at this point
Copy the full SHA e110f06View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8642459 - Browse repository at this point
Copy the full SHA 8642459View commit details -
Configuration menu - View commit details
-
Copy full SHA for a840ba4 - Browse repository at this point
Copy the full SHA a840ba4View commit details -
Configuration menu - View commit details
-
Copy full SHA for aecf736 - Browse repository at this point
Copy the full SHA aecf736View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.