Home > Software design >  wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly
wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly

Time:12-08

We are trying to use Cortona 3d Solo library in our web application. We recently upgraded to version 2.0 because some 3d models are not rendered when we initialize interactivity.xml. We are using Apache Tomcat Version 8.5.57. Before, we are just getting CORS policy issue which was expected in my local but now, I'm not able to replicate that issue anymore because of compilation error from wasm. Do I need to do something other than adding in web.xml?

I tried adding mime-mapping application/wasm in web.xml of Tomcat but we are still getting the error. Just to be sure, I also added the mime-mapping in web.xml of our storefront but still not working. The CORS policy is bypassed when we render 3d models in our staging using the old Cortona version. I tried deploying the new wasm files which is included in the new version but now, it is also not working in our staging. If possible, we don't want to update the Tomcat version.

<mime-mapping>
        <extension>wasm</extension>
        <mime-type>application/wasm</mime-type>
    </mime-mapping>

enter image description here

Edit: I saw that we should have the wasm in our Tomcat version here, enter image description here

Edit: We saw that the issue differs from browser to browser. We get this issue in Firefox. My question now is how will we remove the charset specifically for application/wasm? enter image description here

CodePudding user response:

I was able to fix the issue. Below are my actions.

  • I had to create a new filter class extending CharacterEncodingFilter.
  • Inside the new filter class, I check if the requestUrl contains .wasm in it.
  • If it has .wasm, I set the desired content type then called the doFilterInternal of parent class.
  • If it does not have .wasm, I set character encoding only to UTF-8 and then called the doFilterInternal of parent class.

After above has been fixed, I encountered another error with magic number. To fix that one, I had to remove the forceEncoding initial parameter set in our web.xml. I hope this could help others struggling with .wasm files.

  • Related