Fyrox: wasm error with condvar mutex

I was able to run my game in editor and wasm_pack generated the wasm file without any issue. but when i run it in browser e.g. Chrome, it threw following errors:

panicked at ‘condvar wait not supported’, library/std/src/sys/wasm/…/unsupported/locks/condvar.rs:21:9

panicked at ‘assertion failed: (left == right) left: true, right: false: cannot recursively acquire mutex’, library/std/src/sys/wasm/…/unsupported/locks/mutex.rs:24:9

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (11 by maintainers)

Commits related to this issue

Most upvoted comments

WebAssembly is kinda annoying, the fact that you cannot block to execute a future is sad. However, there’s one good thing about this - having non-blocking code will make your app much better from user perspective. You can draw a progress bar, or some other stuff while game’s assets are loading.

The issue should be fixed, I got @invokermain 's project running in both Firefox and Chrome: изображение

@invokermain If you have any improvements to executor-wasm template, please make a PR 🙏

@GOVYANSONG looks like you’re trying to get a reference to a non-loaded scene by a null-handle.

It turns out that there’s a handful of block_ons left in the engine code. I’ll try to fix that today.

This is what I have after building executor-wasm and running it in Firefox: изображение

The idea is to remove any platform-specific code from user code. WebAssembly does not support std::thread (at least on wasm32-unknown-unknown target) and it is only possible to spawn a background task with some custom actions. So AsyncSceneLoader is that cross-platform solution - internally it “off-threads” scene loading as a background task and provides fetch_result method that can be used to obtain actual loading result (when it is ready).

So first steps to fix the issue were made. New AsyncSceneLoader works fine with WebAssembly, now it is time to improve fyrox-template - it needs a separate executor-wasm project for WebAssembly. executor itself cannot be modified (at least I don’t see how to do it), because WebAssembly requires very specific project structure:

  • Your game must be a dynamic library
  • A bunch of service code (codegen attributes, helper methods to catch and report panic, etc) must be added.

I hope I can add this today, this is interesting task and I’m eager to see some of my games (this one https://github.com/mrDIMAS/FishFolly specifically) working on WebAssembly targets.

I’ll try to fix that today.