Unhandled Promise Rejection: CompileError: WebAssembly.Module problem

Hi,

We’re experiencing a problem where the website won’t load on certain combinations of iPad’s and iOS.

I see this error in the console:

Unhandled Promise Rejection: CompileError: WebAssembly.Module doesn't parse at byte 58: invalid opcode 192, in function at index 35:
failed to initialize basis worker: CompileError: WebAssembly.Module doesn't parse at byte 662: invalid opcode 193, in function at index 108

Not sure how to proceed troubleshooting. I’ve tried reimporting basis.js but with no luck.
I’ve also tried replacing basis files with a version from here: engine/examples/src/lib/basis at 8a7b0e11482231dc7d5a65acbd4ce16a4191791a · playcanvas/engine · GitHub from 2 years ago, and wen’t through my texture assets to recompress them all.

It seems it’s this issue … please try the workaround mentioned

It could be that issue, but possibly not too. It has failed on iOS18 too, and also iOS 14. But works on iOS 16.3 for example.

Is this the workaround you suggest I try? Handle ios 17 basis wasm regression by slimbuck · Pull Request #5657 · playcanvas/engine · GitHub

technical question - how do I go about trying the workaround?

hi sorry it seems the ticket was not updated … see the workaround linked at the end now

I see, thanks!

I’ve downloaded those file from github, and replaced the ones in my project under the Basis folder. But is that enough, or do I have to go through all images in project and recompress them?

Just replacing the basis files did not remedy the problem namely. I’m still getting this:

​ Unhandled Promise Rejection: CompileError: WebAssembly.Module doesn't parse at byte 58: invalid opcode 192, in function at index 35
(anonymous) @ [native code]:1
promiseReactionJob @ [native code]:1
playcanvas-stable.min.js:10 failed to initialize basis worker: CompileError: WebAssembly.Module doesn't parse at byte 662: invalid opcode 193, in function at index 108

Note that it does not explicitly talk about basis here.

Recompressing them did nothing either.

To reproduce:

  1. Create a new project based on the model viewer
  2. Import Basis
  3. Compress the textures in cube/textures
  4. Publish the build, and test with iPad Pro 12.9 2020 v14.0 over at browserstack for example.

There it fails with this message: failed to initialize basis worker: CompileError: WebAssembly.Module doesn't parse at byte 4572: invalid opcode 192, in function at index 73

in playcanvas-stable.min.js:10

Even If I replace the basis files with the ones suggested from here: Update basis binaries by slimbuck · Pull Request #5674 · playcanvas/engine · GitHub and I recompress textures, I still get the same issue.

Can you reproduce?

I’m super keen on a workaround here, but not sure where to start. He have a bunch of ipads on a huge trade fair starting today and they are all stuck on progress bar.

it kinda does?

failed to initialize basis worker

The workaround was to recompile the wasm, and just use the wasm, no need to reconvert. But this just luckily hid the issue with the Safari, so not a real reliable workaround unfortunately.

@slimbuck - any ideas here?

@bjorn.syse - would you have some repro here we could use for testing? Specific devices with Safari version and similar?

You’re right, it does in that example :slight_smile:

Yes, the steps I posted here above should give you the error, I’m still waiting for Logs on the physical devices over in Las Vegas at the trade fair, but they are some hours behind. Should come within 30 mins. They initially had them running ios18 and the issue was there, then they downgraded to ios17 but still seeing the issue.

In the meantime I’ve been able to produce this error on an iPad Pro 12.9 2020 v14.0 which i found at browserstack.com. Safari version I can’t tell. I can not reproduce the error on browserstack ios17 however.

1 Like

Hey @bjorn.syse,

basis.wasm.js and basis.wasm.wasm are glue code and wasm binary files (respectively) used to decode basis.

If the browser doesn’t support wasm modules, then it falls back to the pure javascript version of the decoder instead, which is named basis.js.

What the engine should be doing (but currently isn’t) is falling back to the plain js version if wasm compilation fails (as it does for you).

The result will be slower decoding basis files, but at least it should work. I’ll see now how easy it is to make this change.

Thanks!

1 Like

oh, ok! thanks for you efforts!

Just getting the logs from the devices on the trade fair, and it might actually be something else:

maybe related Glossines control when using environment map - #6 by mvaligursky

check ‘Max Texture Image Units’ perhaps on those devices using
https://webglreport.com/

ok thanks, will ask them to check. Sanity check but we’re talking WebGL1 right?

I’m checking on browserstack.com and that ipad 12.9 from 2020 is reporting 16. But will get back when I get stats from actual device to double check.

that depends on your project settings. If there is webgl2 on the device, and you’re not forcing webgl1, it would use webgl2.