-
-
Notifications
You must be signed in to change notification settings - Fork 832
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
web: Fallback to instantiate with improper MIME type #2561
Conversation
26ce083
to
9f825e1
Compare
The selfhosted build works great but the extensions (.xpi and .zip) are broken, at least on my end: it misses the |
Having trouble reproing here, I get the dist folder--could you try:
|
BTW, I use the npm http-server to test the fallback, as it doesn't serve with the WASM MIME type. |
The directory / files are still missing, unfortunately. Weird. I'll give it another try tomorrow. |
I've tried again and the issue still happened. I've no issue compiling on the current master branch. FWIW, reverting the changes in |
Okay, I was able to repro the issue on my side. Looking into it now. |
Use --target web in wasm-bindgen and file-loader for WASM files, allowing wasm-bindgen's built-in fallback from WebAssembly.instantiateStreaming to instantiate. file-loader spits out the WASM file directly in the output folder, and imports will resolve to the URL, so that we can load the file directly, avoiding webpack's built-in wasm loaders. This allows Ruffle to function on web servers even if they serve WASM files with the incorrect MIME type, fixing one of our biggest support requests (ruffle-rs#400, ruffle-rs#1458). There is some performance impact on loading with the fallback, but this is preferable to not working at all.
9f825e1
to
cc81927
Compare
Forgot to remove |
I confirm this is working now. 👍 |
There's just a surprising thing, in the JS file there's a path to the folder where Ruffle has been compiled:
This is not really important though, as |
That code is from wasm-bindgen, which originally does |
Use
--target web
in wasm-bindgen and file-loader for WASM files,allowing wasm-bindgen's built-in fallback from
WebAssembly.instantiateStreaming to instantiate to function.
file-loader spits out the WASM file directly in the output folder,
and imports will resolve to the URL, so that we can load the file
directly, avoiding webpack's built-in wasm loaders.
This allows Ruffle to function on web servers even if they serve
WASM files with the incorrect MIME type, fixing one of our biggest
support problems (#400, #1458). There is some performance impact
on loading with the fallback, but it seems minimal to me and is preferable
to not working at all.
Perhaps someone with more webpack/JS experience can look this over and verify that everything makes sense.