DO NOT MERGE: WebAssembly standalone support#103
Conversation
… a dummy version in the runtime
|
Hi @jerbob92, Thank you very much for sharing this! I didn't expect that we'd have to patch emscriptem and add a new features PDF. I'll try to cherry-pick the changes you recommend right away. Best regards, |
|
I think Emscripten is not going to accept the patch in this state because it only implements what PDFium uses, nothing else. And regarding extending PDFium: I don't think there is a way to work around this, to use function pointers in WebAssembly, the pointer needs to exist during compile time or you need to add the pointer to a method during runtime, which many runtimes don't support, that's why I had to implement various callbacks in the PDFium patch and then implement the callback logic on the runtime side. So I wouldn't really see it as extending PDFium, this is just a way to make all functionality work on in WebAssembly.
I think this was related to the memory allocator that has since been disabled. |
|
@bblanchon small warning, |
| cd emsdk | ||
| ./emsdk install ${EMSDK_VERSION:-latest} | ||
| ./emsdk activate ${EMSDK_VERSION:-latest} | ||
| ./emsdk install ${EMSDK_VERSION:-4.0.11} |
There was a problem hiding this comment.
I have changed this back to a static version, to make sure that emscripten.patch applies.
| echo "pdf_is_standalone = true" | ||
| echo "pdf_use_partition_alloc = false" | ||
| echo "target_cpu = \"$TARGET_CPU\"" | ||
| if [ "$TARGET_CPU" == "wasm-standalone" ]; then |
There was a problem hiding this comment.
This felt like the best solution to me right now to prevent a lot of patches, let me know what you think.
|
@bblanchon I have updated the MR to make it possible to have this next to the normal wasm build, this introduces the CPU target |
| if [ "$CPU" == "wasm-standalone" ]; then | ||
| pushd "$PWD/upstream/emscripten" | ||
| patch -p1 --forward < "$PATCHES/wasm/emscripten.patch" || true | ||
| rm -Rf cache |
There was a problem hiding this comment.
This is to make sure emscripten recreates "prebuilt" libraries.
|
Hi @jerbob92, I'm sorry for not getting back to you sooner. Best regards, |
|
Thanks for checking @bblanchon! The emscripten patch is actually from emscripten-core/emscripten#18285 |
|
I'd be more comfortable if we could wait for this PR to be merged. |
It's been moving forward really slowly since 2022, so probably not soon. |
5f9317d to
8af2e14
Compare
@bblanchon I promised to come back to you when I finished my WebAssembly implementation, so here it is! It's not ready to merge this in, since it will break support for the web build, but it is possible to use this as a base to create 2 WASM builds: web and standalone.
This contains the following changes:
The thing that I'm not really happy with is how the Emscripten patch is applied, but I couldn't get it to work in another way, since
emsdk/upstream/emscriptenis not a git repo.