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

Implement single threaded task scheduler for WebAssembly #496

Merged
merged 2 commits into from
Sep 16, 2020
Merged

Implement single threaded task scheduler for WebAssembly #496

merged 2 commits into from
Sep 16, 2020

Conversation

smokku
Copy link
Member

@smokku smokku commented Sep 15, 2020

This implements a single threaded "TaskPool" and systems scheduler for use with WebAssembly target.

I see it as a temporary solution, until Rust wasm story gets better support for wasm threads (see #88). This is why I kept my change minimal, without any major refactoring. It is ugly, but it works.

Provided examples demonstrate how to build and run wasm32 target. See examples/README.md.

Bevy is now able to run "headless" in browser.
Zrzut ekranu z 2020-09-15 22-53-14

Together with #209 it should be enough (+/- fixes) to run Bevy app in browser.

@memoryruins memoryruins added C-Feature A new feature, making something new possible O-Web Specific to web (WASM) builds labels Sep 15, 2020
@smokku
Copy link
Member Author

smokku commented Sep 16, 2020

Should Bevy use +nightly compiled when testing, while it does not require such compiler to run?
Zrzut ekranu z 2020-09-16 02-12-00

@cart
Copy link
Member

cart commented Sep 16, 2020

Yeah it needs nightly for cargo fmt because we currently require "combined imports" (its also required for clippy). im considering dropping that requirement to make the development process a little easier on people.

@smokku
Copy link
Member Author

smokku commented Sep 16, 2020

Oh, it actually did find an improvement to this use line.
I usually use VSCode Refactor->Merge Imports feature for these, but I missed this one. I'm all for keeping it. :-)

Fixed.

@cart
Copy link
Member

cart commented Sep 16, 2020

I'm not going to lie, this put a real smile on my face:

image

examples/wasm/index.html Outdated Show resolved Hide resolved
@cart
Copy link
Member

cart commented Sep 16, 2020

The current clippy failure is probably because extern crate console_error_panic_hook probably doesn't work on non-wasm platforms.

Maybe we should create a WasmLogPlugin to make configuring this easier / hiding it behind a feature flag easier?

@smokku
Copy link
Member Author

smokku commented Sep 16, 2020

Maybe we should create a WasmLogPlugin to make configuring this easier / hiding it behind a feature flag easier?

It is not a part of the engine per-se. Just an example on how one could handle panics in own application.
But it is not required.

Anyway, moving it to normal dev-dependencies (not target specific ones) helps.

@cart
Copy link
Member

cart commented Sep 16, 2020

Alrighty lets merge this 😄

@cart cart merged commit 2b0ee24 into bevyengine:master Sep 16, 2020
@smokku smokku deleted the wasm branch September 16, 2020 11:42
mrk-its pushed a commit to mrk-its/bevy that referenced this pull request Oct 6, 2020
)

* Add hello_wasm example

* Implement single threaded task scheduler for WebAssembly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Feature A new feature, making something new possible O-Web Specific to web (WASM) builds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants