fix: move compression and resize to web worker (#41)#42
Merged
leerob merged 6 commits intoleerob:mainfrom Dec 31, 2025
Merged
Conversation
|
@esau-morais is attempting to deploy a commit to the leerob-site Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Author
|
@leerob notice that this fixes the root cause, however does not prevent a long compression time when selecting lossy, as it is already expected and commented in https://github.com/leerob/pixo/blob/main/src/png/mod.rs#L63-L65 EDIT: |
Owner
|
bugbot run |
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot.
You can kick off a cloud agent using @cursor - e.g. @cursor fix the bug in compress-client.ts.
leerob
reviewed
Dec 30, 2025
esau-morais
commented
Dec 30, 2025
Owner
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Root Cause: WASM compression was running synchronously on the main thread, blocking the browser UI for several seconds when processing large images (especially at high zoom levels). Chrome shows "unresponsive page" dialog when main thread is blocked for too long.
Fix: Moved compression and resize operations to a Web Worker, allowing:
Note
Moves heavy WASM image processing off the main thread and wires the UI to the worker-backed APIs.
lib/compress.worker.tsto handlecompress/resizemessages usingwasmfunctions, returning results viapostMessageand transferring ArrayBufferslib/compress-client.tsto manage a singleton worker, request/response correlation with timeouts, crash handling, and reconstruction ofImageData; exposescompressImage/resizeImageroutes/+page.svelteto import fromcompress-client, route all compression/resize operations through the worker, and simplify the flow (e.g., recompress on resize/apply)vite.config.ts) withworker.format = "es"for module workersWritten by Cursor Bugbot for commit 0cd81d8. This will update automatically on new commits. Configure here.