Support `wasm32v1-none`
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by auditing the winit-core, winit-web, and winit crates against the ten listed wasm32v1-none and no_std blockers, especially public APIs using PathBuf, Mutex, Instant, and io::Error. Build the relevant crates for wasm32v1-none first, then verify that the platform APIs and dependencies compile without the current std assumptions; done means the target builds with compatible web functionality.
Written by the indexing model from the issue text.
Description
Description
When compiling for web, wasm32-unknown-unknown is currently the defacto target. However, this target has an evolving set of enabled Wasm features, which can cause browser compatibility issues. Rust's solution to this problem is the relatively recent wasm32v1-none target, which enables the bare minimum set of Wasm features, maintaining a consistent compatibility. Critically, this target also undoes the decision to use a stubbed std, opting instead for wasm32v1-none to just be a no_std target.
I noticed winit was missing this compatibility while working on wgpu#6826, as I have made enough progress to start working on examples.
Based on a cursory glance, here are some changes I think would need to be made:
- Warn on
clippy::std_instead_of_core,clippy::std_instead_of_alloc, andclippy::alloc_instead_of_coreand replacestdusage withcoreandallocwhere trivial. - Add
#![no_std] extern crate std; extern crate alloc;towinit-core,winit-web, andwinitto swap from thestdimplicit prelude to thecoreimplicit. - Disable default features on most dependencies
- Add
libmtowinit-core. Note thatdpihas an inlined subset oflibm, I don't believe this is advisable forwinit-core, asround,sin,cos,tan,atan,atan2, andhypotare all required. - Change
WindowEvent. TheDragevents include public usage ofPathBuf. Either the enum needs to benon_exhaustivewith those arms gated, or some further encapsulation is required. SurfaceSizeWriterusesMutexin its public API. This could be pretty easily abstracted with a new type wrapping either an alternateMutex(e.g.,spin), or it could just be a packedAtomicU64.web-timecurrently lacksno_stdsupport for no particular reason, so either APIs involvingInstantneed to be gated, or further work upstream is required.BadIconwraps anio::Error. This type is moved intocoreonnightly, but there's no ETA for stabilisation.winit-webmakes extensive usage ofthread_local's. These can be safely replaced withunsafe impl Send + Syncwrappers, since Wasm without atomics is trivially single threaded only. This is the approachwgpuuses.- Probably need to bring in
once_lock.
Relevant platforms
Web
- Dominant language
- Rust
- Stars
- 6.2k
- Forks
- 1.3k
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 10
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-windowing/winit
-
Delta overflow errorOpenB - bug DS - win32
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rust-windowing/winit#4722 ·
Maintainers usually reply within 2 days
-
B - bug DS - appkit
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
rust-windowing/winit#4666 · 1 comment ·
Maintainers usually reply within 2 days
-
DS - x11
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
rust-windowing/winit#4479 · 5 comments · 1 reaction ·
Maintainers usually reply within 2 days
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
rust-windowing/winit#4721 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
rust-windowing/winit#4719 · 1 comment · 1 reaction ·
Maintainers usually reply within 2 days
All issues in rust-windowing/winit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
aws-samples/sample-pacer#76 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
axodotdev/cargo-dist#2523 ·
Maintainers usually reply within 2 days