-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
call of writeToBuffer on huge png causing tab freeze #71
Comments
If your image processing logic doesn't require access to the DOM, you can offload the work from the UI thread to a web worker and thereby reducing DOM blocking. See for example: Note that image quantization is generally a time-consuming operation. You can control the CPU effort spent on improving lossy palette-based PNG output by passing the Lines 8739 to 8742 in 6b83b72
The default value is 7, with acceptable values ranging from 1 (fastest/largest) to 10 (slowest/smallest). |
Thanks, @kleisauke! I'll check web worker approach. And what do you think about writeToBuffer freezing problem? Can you reproduce it? (bug when it freezes when processing huge png) |
The UI freeze issue is because some pthread APIs in Emscripten uses a busy-wait on the main browser thread, which can make the browser tab unresponsive. This cannot be addressed; see for more details: This issue does not occur when wasm-vips is initialized on a web worker. However, the playground cannot utilize web workers because it requires access to the DOM. |
@kleisauke, got it, thanks for the explanation |
@kleisauke, so I created a worker and the freezing was gone, but I still have the same issue with the huge files, it just never ends up processing. Thanks |
The reproduction works perfectly for me on both Chrome and Firefox. I cloned the repository, ran Additionally, I performed a sanity check using this gist: Which browser are you testing this on? And what does this line print in the JavaScript console? |
Hmm. I'm using Chrome 127.0.6533.89 (arm64), mac os 13.0, m1 16 ram |
It appears that This specific Chromium bug is being tracked here: Furthermore, it has been noticed that These implementation bugs are being tracked at: I just pushed commit 5c7d274 that will reduce concurrency by default to 1 on the web. This will be in v0.0.10, thanks for reporting this! In the meantime, you can get workaround this issue by manually lowering concurrency to 1, by calling Lines 68 to 74 in 5c7d274
|
@kleisauke, thanks for your help, with concurrency set to 1 now it works |
v0.0.10 is now available. |
Hey, thanks once again for your library.
I believe I'm facing a bug. Specifically, library doesn't finish command if I call writeToBuffer for a PNG file with parameters palette and Q.
Example of the same command but via vips CLI (works well)
vips pngsave sample_5184×3456.png worked.png --Q 50 --vips-progress
Example of code that's freezing on the playground
Link to the file that's causing the problem, can't attach here because it has 35+mb in size
Also, the UI is totally freezing when writeToBuffer processes any images, but for bigger images, it's more visible, I understand it's basically CPU calculations, but I can't even add a loader because it won't spin as the UI is freezing, if it's possible to do something with this behavior would really appreciate suggestions, thanks
The text was updated successfully, but these errors were encountered: