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 WASM support for bevy_winit #503

Merged
merged 1 commit into from
Sep 16, 2020
Merged

Implement WASM support for bevy_winit #503

merged 1 commit into from
Sep 16, 2020

Conversation

smokku
Copy link
Member

@smokku smokku commented Sep 16, 2020

This modifies the rest of default plugins to build for wasm32 and twists bevy_winit to run.

The main problem is that winit Window is not Send + Sync, but since our WASM runtime is single threaded,
we can safely fake it.

Zrzut ekranu z 2020-09-16 22-02-02

Also, replaced wasm_timer::Instant with instant::Instant as it is used by winit WASM implementation, so the code won't duplicate.

To build the example use:

cargo build --example winit_wasm --target wasm32-unknown-unknown --no-default-features --features bevy_winit

and modify index.html to run it.

Also, replaced wasm_timer::Instant with instant::Instant as it is
used by winit WASM implementation.
@Moxinilian Moxinilian added C-Feature A new feature, making something new possible O-Web Specific to web (WASM) builds A-Windowing Platform-agnostic interface layer to run your app in labels Sep 16, 2020
@cart
Copy link
Member

cart commented Sep 16, 2020

Mmmm I love waking up to more wasm support :)

@cart cart merged commit 34c6f5f into bevyengine:master Sep 16, 2020
@chemicstry
Copy link

Do you actually need cfg macros for instant? It's a multi platform lib so you can just use it by default everywhere

@cart
Copy link
Member

cart commented Sep 17, 2020

I thought a bit about this before approving. Instant is actually just a type alias for std::Instant on native platforms. But not using the instant crate on non-wasm platforms lets us cut 1 dependency. Honestly a negligible "compile time" win, but its one less thing in the "trust chain", which imo is worth it.

@smokku smokku deleted the wasm branch September 17, 2020 11:34
mrk-its pushed a commit to mrk-its/bevy that referenced this pull request Oct 6, 2020
Also, replaced wasm_timer::Instant with instant::Instant as it is
used by winit WASM implementation.
bors bot pushed a commit that referenced this pull request Sep 2, 2022
…n wasm. (#5863)

# Objective

#503 added these.
I don't know what problem it solved, the PR doesn't say and the code didn't make it obvious to me.

## Solution

AFAIK removing unsafe `Send`/`Sync` impls can't introduce unsoundness.
Yeet.

## Migration Guide
Why tho.


Co-authored-by: devil-ira <[email protected]>
james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 28, 2022
…n wasm. (bevyengine#5863)

# Objective

bevyengine#503 added these.
I don't know what problem it solved, the PR doesn't say and the code didn't make it obvious to me.

## Solution

AFAIK removing unsafe `Send`/`Sync` impls can't introduce unsoundness.
Yeet.

## Migration Guide
Why tho.


Co-authored-by: devil-ira <[email protected]>
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
…n wasm. (bevyengine#5863)

# Objective

bevyengine#503 added these.
I don't know what problem it solved, the PR doesn't say and the code didn't make it obvious to me.

## Solution

AFAIK removing unsafe `Send`/`Sync` impls can't introduce unsoundness.
Yeet.

## Migration Guide
Why tho.


Co-authored-by: devil-ira <[email protected]>
Subserial pushed a commit to Subserial/bevy_winit_hook that referenced this pull request Jan 24, 2024
…n wasm. (#5863)

# Objective

bevyengine/bevy#503 added these.
I don't know what problem it solved, the PR doesn't say and the code didn't make it obvious to me.

## Solution

AFAIK removing unsafe `Send`/`Sync` impls can't introduce unsoundness.
Yeet.

## Migration Guide
Why tho.


Co-authored-by: devil-ira <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in 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.

4 participants