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

Enable wasm, when it works #30

Merged
merged 5 commits into from
Aug 1, 2024
Merged

Conversation

ChristopherBiscardi
Copy link
Collaborator

wasm support with webgpu is not a tier-1 support target for vello, but it does work.

RUSTFLAGS="--cfg=web_sys_unstable_apis" cargo run --example transition --target wasm32-unknown-unknown

RUSTFLAGS is required for egui, which could be moved out of dependencies. I opted to try to keep development simple since the crate is prerelease rather than putting everything behind features and such.

I'd propose a support angle that is: "if it works in bevy_vello, it should work in woodpecker", so as to avoid bugs that are clearly not woodpecker related from becoming a support burden.

webgl2 support is not a possibility, so we're only talking about webgpu here.

  • arboard doesn't support wasm, so clipboard functionality is currently patched out.
  • std::time doesn't either, but web-time is a drop-in replacement that falls back to std::time

good news

a bunch of things work already, such as modals, transitions, and clipping.

screenshot-2024-07-29-at-19.48.27.mp4
screenshot-2024-07-29-at-19.49.43.mp4

screenshot-2024-07-29-at-19 50 51

Potential work

  • It seems like the scaling uses the desktop's native resolution. So on my 4k monitor on macos which I run at 1920x1080 scaled the output is huge. I changed my resolution to 4k to take the prior videos.

screenshot-2024-07-29-at-19 51 56@2x

  • clipboard support on web, maybe via web_sys or similar

let Ok(mut clipboard) = arboard::Clipboard::new() else {
return;
};
#[cfg(not(target_arch = "wasm32"))]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be able to use this as an alternative:
https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think Clipboard is going to work. Its necessarily async which is a bit of a pain since EventWriters, Commands, etc are going to get moved out of the loop (and can't be) but worst-case scenario I think we can AsyncTask it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a look at it tonight. TaskPool::scope would work (and is seemingly the Right Way) for passing the EventWriter in and such... except that it panics when awaiting the clipboard future.

This seems like a long-standing issue: bevyengine/bevy#1924

I pushed up some code that gets the clipboard text, but its not working as we'll need a workaround for scope not panning out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#ecs says use a channel so I'll do that

@StarArawn StarArawn merged commit 5bb1ad6 into StarArawn:main Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants