-
-
Notifications
You must be signed in to change notification settings - Fork 302
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
JavaScript build broken (online demo page) #1304
Comments
This has been an issue in the past that has been solved by reloading the page (#1174 (comment)) I think it's caused by the libheif object getting called before it finishes loading - I don't have much time to work on this but can probably get a fix in before next week |
Ah, thanks, I didn't see that this is a possible duplicate. I tried it again and think that it may still be another issue. If I revert to the old gh-pages version (c95ff2a), it is in fact the behavior that it only works after a reload. With the current compilation (63785e7), however, it even doesn't work after a reload, but the error in the console is the same. |
I did some digging and think I found the issue: The gh-pages branch does not initialize the webassembly module: Line 314 in 63785e7
Line 315 in 63785e7
while the examples on the master branch do: Line 318 in bb3b652
Therefore when the (new) libheif.js and libheif.wasm files are used with the old gh-pages html file, the libheif variable is not webassembly module but actually a function that initializes and returns the webassembly module. So calling heif_get_version() on it throws an error. I'm not sure why the gh-pages branch is using this outdated file but it could probably be replaced by the examples/demo.html file on the master branch, As a sidenote, another issue I ran into when testing the
The solution was to manually fetch the wasm binary file and pass it in as a parameter to the libheif() function, e.g.: window.onload = function() {
if (typeof libheif === "undefined") {
alert("libheif could not be loaded, please check your browser console for details.");
return;
}
fetch('libheif.wasm')
.then((res) => res.arrayBuffer())
.then((wasmBinary) => {
var demo = new HeifDemo(libheif({ wasmBinary: wasmBinary }));
// .... I'm not sure if this would also be an issue on Github pages but if it is, the solution is above. |
Thank you, @EzraH442 . With your proposed changes, I managed to make the page work again. This is great. Without your hints, I would have searched forever... |
When building libheif to JS/WASM (current
master
branch, but also forv1.18.0
) withI get the libheif.js and libheif.wasm files, but when I insert them into the demo-website https://strukturag.github.io/libheif/, I get the following error in the browser console:
This has worked before, but I now cannot even build the old versions anymore. Any ideas what the reason for this could be?
I'm using emcc 3.1.66.
CC: @fancycode @EzraH442
The text was updated successfully, but these errors were encountered: