Remove unused OpenJPEG wasm fallback logic#19923
Remove unused OpenJPEG wasm fallback logic#19923Snuffleupagus merged 1 commit intomozilla:masterfrom
Conversation
|
Oh well, the unused code removal is working properly, so the tests for the transform need to be updated to actually use those functions :) |
b5f32ac to
c2ba80a
Compare
Snuffleupagus
left a comment
There was a problem hiding this comment.
Please also fix the typo in the commit message: OpenJPG -> OpenJPEG.
c2ba80a to
c979a8c
Compare
Emscripten generates code that allows the caller to provide the Wasm module (thorugh Module.instantiateWasm), with a fallback in case .instantiateWasm is not provided. We always define instantiateWasm, so we can hard-code the check and let our dead code elimination logic remove the unused fallback. This commit also improved the dead code elimination logic so that if a function declaration becomes unused as a result of removing dead code, the function itself is removed.
c979a8c to
aebe0cb
Compare
|
Rebased to include the changes that removed I couldn't find a nice way to test for this, instead I made the webpack build fail (after emitting the files) if the generated bundle contains |
|
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/8630af930651a96/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/f66c94119c82701/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/f66c94119c82701/output.txt Total script time: 30.56 mins
|
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/8630af930651a96/output.txt Total script time: 61.79 mins
|
|
This PR only removes unused code. It seems like you forgot to pass the |
|
The issue was solved by passing the wasmUrl parameter, the wasm folder can be found in the pdfjs-dist package or using a CDN: |
Thanks a lot. I was going to comment that I'd solved it. In my case, I copied the wasm from the pdfjsdist folder in Node Modules to a directory in my project. In a Vite project, I copy it directly to public. With Webpack, if there's no public folder, I use a plugin to configure the copy to the desired folder and have it compiled. This way, it'll be available at runtime (so it's a URL). Finally, as you've mentioned, I pass the wasmUrl parameter pointing to this folder, which is copied to the configured address. Thanks again for your response. |
Opening a PDF with JPEG 2000 images causes these warnings: Warning: JpxImage#instantiateWasm: UnknownErrorException: Ensure that the `wasmUrl` API parameter is provided. Warning: JpxImage#getJsModule: TypeError: Failed to resolve module specifier 'nullopenjpeg_nowasm_fallback.js' Warning: Unable to decode image "img_p0_2": "JpxError: OpenJPEG failed to initialize". In version 5.3.31 [1], the OpenJPEG wasm fallback logic was removed in PR mozilla/pdf.js#19923. The wasmUrl option is required since v5 [2] to decode JPEG 2000 images. There are two solutions to this: 1. Update Webpack config to copy the node_modules/pdfjs-dist/wasm folder to static folder. 2. Load the openjpeg.wasm file from a CDN like jsDelivr. Method 2 is preferred because jsDelivr CDN sets the Cache-Control header and these resources will be cached by the browser correctly. This commit fixes the bug by providing the wasmUrl to jsDelivr CDN. We also provide the cMapUrl and iccUrl to avoid similar warnings from happening in the future. [1]: https://github.com/mozilla/pdf.js/releases/tag/v5.3.31 [2]: https://github.com/mozilla/pdf.js/releases/tag/v5.0.375 Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
Opening a PDF with JPEG 2000 images causes these warnings: Warning: JpxImage#instantiateWasm: UnknownErrorException: Ensure that the `wasmUrl` API parameter is provided. Warning: JpxImage#getJsModule: TypeError: Failed to resolve module specifier 'nullopenjpeg_nowasm_fallback.js' Warning: Unable to decode image "img_p0_2": "JpxError: OpenJPEG failed to initialize". In version 5.3.31 [1], the OpenJPEG wasm fallback logic was removed in PR mozilla/pdf.js#19923. The wasmUrl option is required since v5 [2] to decode JPEG 2000 images. There are two solutions to this: 1. Update Webpack config to copy the node_modules/pdfjs-dist/wasm folder to static folder. 2. Load the openjpeg.wasm file from a CDN like jsDelivr. Method 2 is preferred because jsDelivr CDN sets the Cache-Control header and these resources will be cached by the browser correctly. This commit fixes the bug by providing the wasmUrl to jsDelivr CDN. We also provide the cMapUrl and iccUrl to avoid similar warnings from happening in the future. [1]: https://github.com/mozilla/pdf.js/releases/tag/v5.3.31 [2]: https://github.com/mozilla/pdf.js/releases/tag/v5.0.375 Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>


Closes #19921.
The diff for
pdf.worker.mjsin the generic build is now: