Skip to content
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

Inconsistent Rendering with Webassembly on lower-end hardware. Game chokes. #6363

Open
LarsDu opened this issue Oct 25, 2022 · 3 comments
Open
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior O-Web Specific to web (WASM) builds

Comments

@LarsDu
Copy link
Contributor

LarsDu commented Oct 25, 2022

Bevy version

main
The release number or commit hash of the version you're using.

[dependencies.bevy]
git = "https://github.com/bevyengine/bevy.git"
rev = "543465b721048355e34eb6078923645747c1d44b"

[Optional] Relevant system information

105.0.1 (64-bit)

Mac OSX Monterrey 12.5
  Processor Name:	Quad-Core Intel Core i7
  Processor Speed:	2.6 GHz
  Number of Processors:	1
  Total Number of Cores:	4
  L2 Cache (per Core):	256 KB
  L3 Cache:	6 MB
  Hyper-Threading Technology:	Enabled
  Memory:	16 GB

Numerous reports from people I shared this game with indicated that the web assembly build is slow, stalls, or crashes.

I've tried it on 3 different machines (1 Skylake PC running Ubuntu 22.04, an M1 Mac, and on the above listed laptop). On the above listed laptop certain models do not get shaded or lit correctly. All build choke for at least 2 seconds after pressing the start button.
I suspect there is some sort of threading issue.

If you cannot get Bevy to build or run on your machine, please include:

  • the Rust version you're using (you can get this by running cargo --version)
cargo 1.63.0 (fd9c4297c 2022-07-01)

If your bug is rendering-related, copy the adapter info that appears when you run Bevy.

What you did

Play the webassembly build of the above-linked game

Describe how you arrived at the problem. If you can, consider providing a code snippet or link.

What went wrong

If it's not clear, break this out into:

  • what were you expecting?
    Significantly better performance for WASM builds given the engine and language being used.
  • what actually happened?
    Very poor performance on WASM builds.
@LarsDu LarsDu added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Oct 25, 2022
@rparrett
Copy link
Contributor

rparrett commented Oct 25, 2022

The main issue is that Bevy is not multi-threaded at all on wasm. This is a known limitation (for now).

Anything doing heavy work on the CPU is going to create hiccups:

You can work around this somewhat by frontloading these things into a loading state in your app.

François' entry from Bevy Jam 2 (source) is the only example I know of that waits on pipeline creation in its loading state.

Subfuse, another entry from Bevy Jam 2 is a great demo of what's currently possible with 3d games on the web.

There are also some known issues with intel gpus that you may be seeing:

#3315
#4354

etc. That's probably not comprehensive.

@rparrett rparrett added A-Rendering Drawing game state to the screen O-Web Specific to web (WASM) builds and removed S-Needs-Triage This issue needs to be labelled labels Oct 25, 2022
@gilescope
Copy link
Contributor

You can have multiple processes running on wasm if you can offload some processing to another process and the serialisation overhead of the results isn't an issue: https://github.com/thedodd/trunk/tree/master/examples/webworker-gloo - I've got that working ok with bevy wasm.
That said it would be nice to get stats on how much time all of my various systems are taking and which are parallel and which are not run in parallel. Flamegraph doesn't seem to give that detail...

@kauly
Copy link

kauly commented Jan 13, 2023

Hey @gilescope, can you provide an example of bevy wasm and webworker-gloo? Im trying to understand how this work, do you put system/plugins inside of the worker?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior O-Web Specific to web (WASM) builds
Projects
None yet
Development

No branches or pull requests

4 participants