Skip to content

"Aborted(Module.asm has been replaced by wasmExports ..." error in WASM bundle example #128

Closed

Description

@liammcdermott

Using rustc 1.74.0 (79e9716c9 2023-11-13), the latest release of pdfium-lib (6183), and an up-to-date clone of pdfium-render, this error is printed to the browser console (Firefox 120.0.1 and Chrome 120.0.6099.109):

Aborted(`Module.asm` has been replaced by `wasmExports` (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)) [pdfium.js:8:24592](http://localhost:4000/pdfium.js?v=chromium/6183)

Steps to reproduce

I followed the instructions at Bundling for WASM closely, but I'll recreate what I did here.

From within a clone of the pdfium-render repo:

$ mkdir release
$ cargo install wasm-pack && wasm-pack build examples/ --target no-modules
    Updating crates.io index
     Ignored package `wasm-pack v0.12.1` is already installed, use --force to override
[INFO]: 🎯  Checking for the Wasm target...
[INFO]: 🌀  Compiling to Wasm...
   Compiling pdfium-render v0.8.16 (/home/liam/code/pdfium-render)
   Compiling pdfium-render-wasm-example v1.0.0 (/home/liam/code/pdfium-render/examples)
    Finished release [optimized] target(s) in 7.32s
[INFO]: ⬇️  Installing wasm-bindgen...
[INFO]: Optimizing wasm binaries with `wasm-opt`...
[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended
[INFO]: ✨   Done in 28.83s
[INFO]: 📦   Your wasm pkg is ready to publish at examples/pkg.
$ cp examples/pkg/{pdfium_render_wasm_example.js,pdfium_render_wasm_example_bg.wasm} release/
$ wget https://github.com/paulocoutinhox/pdfium-lib/releases/download/6183/wasm.tgz
[...]
$ mkdir pdfium-lib
$ mv wasm.tgz pdfium-lib/
$ cd pdfium-lib/
$ tar -xzf wasm.tgz 
$ cp release/node/{pdfium.js,pdfium.wasm} ../release/
$ cd ..
$ cp examples/index.html release/
$ cp test/form-test.pdf release/test.pdf
$ cp examples/serve.sh release/
$ cd release/
$ chmod +x serve.sh
$ ./serve.sh

Then visiting http://localhost:4000 yields this result:
image

Activity

  1. liammcdermott commented on Dec 15, 2023

    @liammcdermott
    ContributorAuthor

    I'm assuming the issue is in pdfium-render, as running this:

    cp ../pdfium-lib/release/node/index.html .
    

    which swaps in pdfium-lib's example PDF viewer, works. I was able to upload a PDF into that sample app, and view it, as expected. That assumption may be wrong, of course!

  2. ajrcarey commented on Dec 18, 2023

    @ajrcarey
    Owner

    Hi @liammcdermott , thank you for reporting the issue and my apologies for the delay in replying - I've been away.

    At first glance the problem is likely caused by a packaging change upstream in the WASM build of Pdfium. You may find that using an older version (from, say, a couple of months ago) may work perfectly. Upstream does from time to time change their packaging, e.g. #95.

    I've set aside some time this week to look at this for you.

  3. self-assigned this
    on Dec 18, 2023
  4. ajrcarey commented on Dec 19, 2023

    @ajrcarey
    Owner

    Likely related to upstream emscripten change emscripten-core/emscripten#19816

  5. ajrcarey commented on Dec 20, 2023

    @ajrcarey
    Owner

    Upstream emscripten change introduced into pdfium-lib as part of paulocoutinhox/pdfium-lib#98

  6. added a commit that references this issue on Dec 20, 2023
  7. ajrcarey commented on Dec 20, 2023

    @ajrcarey
    Owner

    Added fall-backs for Module['wasmExports'] for _malloc and _free in response to upstream packaging changes. Confirmed WASM example now runs correctly using pdfium-lib 6183.

    You can test the changes by taking pdfium-render as a git dependency in your project's Cargo.toml.

  8. ajrcarey commented on Dec 28, 2023

    @ajrcarey
    Owner

    As there have been no further comments, and I believe the issue is resolved, I am closing the issue. Feel free to re-open if you believe the issue has not been resolved.

    Confirmed no unexpected regression impact when using pdfium-lib pre-6183. Corrected a typo. Updated README. Scheduled for release in crate version 0.8.17.

  9. liammcdermott commented on Jan 10, 2024

    @liammcdermott
    ContributorAuthor

    @ajrcarey Just wanted to drop a note to say thank you very much for fixing this so quickly!

    I ended up finding a different way to solve my problem, and the way I would test is the same you already did, so I don't think I can add anything useful. Thanks again!

  10. added a commit that references this issue on Apr 27, 2024
    8bb00e8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions