https://kotlinlang.org logo
#webassembly
Title
# webassembly
m

Michael Paus

12/08/2023, 11:44 AM
I am just trying to get my first Compose WASM app running in the browser. The app was generated via the Kotlin Multiplatform Wizard | JetBrains. Running it locally in the browser via
wasmJsBrowserRun
works without problem in Firefox and Chrome (latest versions) but when I create a distribution via
wasmJsBrowserDistribution
and upload it to my own server I just get a white page when I call the corresponding URL. The page seems to load but in the developer tools of the browser I see many lines like this. Does anyone know what the reason for this is and how it can be cured?
Copy code
wasm streaming compile failed: TypeError: WebAssembly: Response has unsupported MIME type '' expected 'application/wasm'
1
K 1
p

PHondogo

12/08/2023, 11:52 AM
Just guess: may be your server doesn't have mapping for wasm file extention to content type. Check in browser network development tools what content type have response for wasm file resource.
m

Michael Paus

12/08/2023, 12:07 PM
In the network analysis view files with the extension “wasm” have the type “wasm” too, if that’s what you mean.
p

PHondogo

12/08/2023, 12:08 PM
What value have response header Content-Type
For request for fetching wasm file
m

Michael Paus

12/08/2023, 12:12 PM
I am not a web developer and have no idea where to find this information you are looking for. Maybe it is faster if you just look at this URL https://mpmediasoft.de/test/AIPBrowserExp/index.html I’d be happy if you could point me to a solution 😇.
p

PHondogo

12/08/2023, 12:17 PM
I'll on mobile browser now. I'll help you within couple of hours when reach to laptop.
m

Michael Paus

12/08/2023, 12:33 PM
Thanks @Robert Jaros. But I doubt that this is the problem. (I don’t access to the server configuration. I can only upload files to it.) I have another, older example running on the same server side by side with the example from above and this works without problem. https://mpmediasoft.de/test/PolySpiralMpp/ It uses Compose Kotlin with JS and not WASM but it contains the file
skiko.wasm
and that works without problem. So, I doubt that the server settings are wrong.
r

Robert Jaros

12/08/2023, 12:44 PM
In both cases, your server doesn't return the correct content-type header for the
wasm
file. There is even the same message in the browser console. There is a difference - in the older example this is only a warning and in the newer it's an error. Perhaps there is some fallback in the old skiko.js. Anyway, fixing the server configuration is the correct way to address this issue.
1
👆 1
m

Michael Paus

12/08/2023, 12:45 PM
Ok, thanks a lot. I will see how I can get that fixed.
It works now 🎉. I don’t have access to the /etc/mime.types file as suggested in the above article but I can place
Copy code
AddType application/wasm .wasm
in a local
.htaccess
file and voila it works. Thanks a lot to everybody who helped.
🎉 2
c

Colton Idle

12/08/2023, 2:05 PM
awesome. TIL. what server are you using to host?
a

Arjan van Wieringen

12/08/2023, 5:32 PM
.htaccess typically means Apache server
c

Colton Idle

12/08/2023, 5:44 PM
gotcha. i guess i was curious which hosting provider. heroku, etc? idk. im not a web dev, so im just trying to learn where i can deploy my apps.
m

Michael Paus

12/08/2023, 7:30 PM
Yes, it seems to be an Apache server. The hosting provider is https://www.ionos.de/
👍 1
7 Views