Skip to content

Conversation

@ealmloff
Copy link
Member

@ealmloff ealmloff commented Jan 9, 2026

This PR adds support for a fork of wasm bindgen, web sys and js sys. It moves the virtual dom to a separate thread from the event loop. This lets us share a lot more code between desktop and web including the logic for:

  • events
  • mounted data (web_sys::Element)
  • eval

Breaking changes

  • Many of the web-sys types we export are now web-sys-x types which use wasm-bindgen-x for desktop compatibility
  • The functions to create a window take closures for the new virtual dom and config constructors instead of passing them directly. This may be possible to remove in the future
  • Some hooks like the wry event handler hooks now require a Send bound. This breaks a couple of examples

Status of wasm-bindgen-x

Where we still aren't compatible with wasm-bindgen:

  • Low level wasm access like memory()
  • Macrotask timing for code that relies on the order of rust code running with respect to the finalization registry (eval is one case where we used to rely on this)
  • Unstable apis in wasm bindgen like wasm_bindgen::convert

Publishing:
An initial version is published here which works for dioxus' use cases without a patch. For patching it may be easier to rely on the git tag instead as cargo doesn't let you patch to the same source without a registry alias.

The current published version of web-sys-x has only a limited number of features because of the crates.io limit of 300 features per crate. I have reached out to the crates.io team to see if we can remove that limit to publish the full version

TODO

  • Move the virtual doms to a new thread
  • Get wasm bindgen working on that new thread
  • Fix event conversion for desktop-specific events
  • Get it working with multiple webviews
  • Create shims for all of the main thread-only functionality we previously exposed
  • Integrate into the CLI to either auto patch wasm-bindgen or recommend patching wasm-bindgen when we detect it
  • Fix android
  • Documentation

Partially addresses #4142 since as_web_event now works on desktop and mobile

@ealmloff ealmloff added enhancement New feature or request breaking This is a breaking change desktop Suggestions related to the desktop renderer labels Jan 9, 2026
@ealmloff ealmloff added this to the 0.8.0 milestone Jan 9, 2026
let form_element = self
.element
.dyn_ref::<web_sys_x::HtmlFormElement>()
.cloned()
Copy link
Member Author

Choose a reason for hiding this comment

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

This was the existing behavior we tested for in dioxus desktop

@ealmloff ealmloff marked this pull request as ready for review January 14, 2026 18:54
@ealmloff ealmloff requested a review from a team as a code owner January 14, 2026 18:54
@ealmloff
Copy link
Member Author

No space left on device : '/home/runner/actions-runner/cached/2.331.0/_diag/pages/17dfb33f-0037-46e5-ae39-d9ea7ee4fdbf_d3e09c59-d36d-43fe-9d07-2d68e31abafe_1.log'

CI is running out of storage with the new crates this PR adds. Running locally on linux gnu, the same tests pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking This is a breaking change desktop Suggestions related to the desktop renderer enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant