emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.36k stars 3.25k forks source link

--preload-file works when running locally but not when deployed as a github page #22100

Open Gerark opened 2 weeks ago

Gerark commented 2 weeks ago

Hello, I'm trying to catch what I'm maybe doing wrong but after a bunch of hours I'm sort of giving up.

I'm packing some data under a folder ( specifically a .ttf file and a .png ) and when I build and run locally ( through emrun ) the resources are loaded correctly. I can see the font being visualized correctly ( I'm using ImGui ) and the image looks good as well ( I'm using OpenGL and stb_image to load it ). Here's a little screenshot: image

I created a workflow action in github to deploy the files as a github page but this is what I get instead: image

It looks like the files are actually loaded ( I don't get asserts or errors from ImGui or stb_image ) but the font seems to be ignored and the image is entirely black. I'm guessing there's something I should setup in order to have the github page working properly.

Are there any aspect I should keep in mind which are automatically addressed when running the webserver locally through emrun?

sbc100 commented 2 weeks ago

I would advice switching to --embed-file since then that data will be embedded directly in the wasm file itself with no external asset dependencies.

If you really need --preload-file instead of --embed-file then we can look into next steps for debugging.

Gerark commented 2 weeks ago

I changed the --preload-file to --embed-file but I get the same result. Running locally seems to work but not when deployed. What are the things I should look at as a first step for debugging?

sbc100 commented 2 weeks ago

I guess the first thing to do would be verify that files are really there in emscriptens virtual filesystem.. e.g. call stat() on both those file on startup and show the results.

The other thing you could try is taking your working build and pushing it to github pages.. if that works then you would know the problem has to do with when the github action build is working, which seems like the most likely thing here.

sbc100 commented 2 weeks ago

Do you have a link to the github action build? So I can see the compile and link commands used to produce the build?

Gerark commented 2 weeks ago

Do you have a link to the github action build? So I can see the compile and link commands used to produce the build?

Yes, here are all the links: