Repository navigation
feat(web): support multi-canvas Rune islands on a single DOM page (#2553) - #3257
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Hona
force-pushed
the
feat/web-multi-canvas-islands
branch
from
December 2, 2026 05:56
dc303c1 to
c9e0632
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2553
Summary
Adds additive multi-canvas web island support so a single Rune app or WASM module can mount into multiple
<canvas>elements on one DOM page while leaving the existing single-canvasApp::run/App::canvas_iddefault behavior unchanged.Design & Changes
pubfields added to literal-built types):App::web_island(canvas_id, view),App::web_island_with(WebIsland<S>), andAppHandle::mount_web_island(WebIsland<S>)mount additional islands sharing stateS.WindowSpec::canvas_id(id)(withApp::window),rune::web::mount_island(canvas_id, app), and distinct inlineApp::canvas_id(...).try_run()calls mount independent-state islands onto the page's shared winit event loop.IslandHandle(canvas_id,is_mounted,request_redraw,unmount) tears down only its target island—releasing DOM listeners,ResizeObserver, frame/timer wakes, canvas surface, borrowed attributes/styles, and[data-rune-a11y]mirror—without disturbing sibling islands.crates/rune/src/platform/web_math/islands.rs):SharedStateCell<S>+SharedDrivertrack mutable state access (states,pollreturningtrue, key/focus/IME hooks,AppHandle::update) while keeping read-onlyViewDriver::viewrebuilds andTx::live_onlyhandlers out of mutation fan-out, so mutatingSin Island A marks Island B dirty and schedules its redraw with zero ping-pong.crates/rune/src/platform/web/islands.rs):BrowserWebGpuGpudevice across sibling canvas surfaces (destroying the device only when the shared loop exits), while keeping per-canvas WebGL2 devices isolated and destroyed on single-island unmount.crates/rune/src/platform/web/bridge.js):rune-focus-<id>-{0,1}focus proxy IDs (no duplicate IDs across islands).ResizeObserversyncing embedded[data-rune-a11y]and[data-rune-web-images]boxes to each canvas's offset rect so sibling canvases inside a shared parent never overlap mirrors, tagged withdata-rune-canvas-id.documentcopyhandling and automation-mode textbox focus checks strictly to the owning island, and cleaned upResizeObserver, live regions, focus proxies, and selection-pick style elements indestroy(h).Verification
node --test crates/rune/src/platform/web/bridge.test.mjs(97/97 pass, including new multi-island isolation, focus handoff, automation textbox isolation, and clean unmount tests)cargo test -j 1 -p rune --lib web(247/247 pass, including 6 new shared-state island and registry unit tests inplatform::web_math::islands::tests)cargo check -j 1 -p rune --lib,cargo check -j 1 -p rune --target wasm32-unknown-unknown, andcargo check -j 1 -p rune --target wasm32-unknown-unknown --features webglscripts/file-size.sh(0 errors, 0 folder-shape warnings, no new files over 800 lines)