fix(app): avoid Wayland pointer-constraint crash on focus regain #908

Merged
SakulFlee merged 1 commit from fix/wayland-pointer-constraint-crash into main 2026-10-23 21:28:26 +00:00

Summary

Fixes the intermittent Wayland crash:

zwp_pointer_constraints_v1#19: error 1: the surface is already constrained
Io error: Broken pipe (os error 32)
Runtime failure: ExitFailure(1)

Wayland allows only one pointer constraint per surface and seat. In the winit version used by Orbital, set_cursor_grab records the requested grab even when no pointer is over the surface. When the pointer enters later, winit re-applies it and can send confine_pointer while the previous constraint is still active. The compositor treats that as a fatal already_constrained error and drops the client connection.

This is rust-windowing/winit#4073, fixed upstream in winit 0.30.10 (6c214e7). The Orbital-Winit fork, based on iced-rs/winit v0.30.x, carries the backport in SakulFlee/Orbital-Winit@6de2c63c. iced-rs/winit v0.30.x has not moved since 2025-09-15 (still 0.30.8) and still lacks both this fix and the Android/iOS input work, so the fork remains required.

Changes

  • Cargo.lock: bump winit/dpi to Orbital-Winit a9d045d6.
  • ModuleRuntime: track pointer-over-window and focus, and route resumed, Focused, CursorGrabbed, and CursorEntered through sync_cursor_grab(). Grabs are deferred until the pointer is over a focused surface, so winit is never asked to grab without a pointer.

Verification

  • cargo fmt --all -- --check
  • cargo clippy -- -D warnings
  • cargo test --no-fail-fast
  • Ran template_all_in_one under Wayland; clean exit, no protocol errors.
  • WAYLAND_DEBUG=1: confine_pointer only after wl_pointer.enter; re-grabs are destroy -> confine with no discarded destroy; no already_constrained.

Fork: SakulFlee/Orbital-Winit@6de2c63c (fix), a9d045d6 (docs).

## Summary Fixes the intermittent Wayland crash: ``` zwp_pointer_constraints_v1#19: error 1: the surface is already constrained Io error: Broken pipe (os error 32) Runtime failure: ExitFailure(1) ``` Wayland allows only one pointer constraint per surface and seat. In the winit version used by Orbital, `set_cursor_grab` records the requested grab even when no pointer is over the surface. When the pointer enters later, winit re-applies it and can send `confine_pointer` while the previous constraint is still active. The compositor treats that as a fatal `already_constrained` error and drops the client connection. This is [rust-windowing/winit#4073](https://github.com/rust-windowing/winit/issues/4073), fixed upstream in winit 0.30.10 (`6c214e7`). The `Orbital-Winit` fork, based on `iced-rs/winit` `v0.30.x`, carries the backport in `SakulFlee/Orbital-Winit@6de2c63c`. `iced-rs/winit` `v0.30.x` has not moved since 2025-09-15 (still 0.30.8) and still lacks both this fix and the Android/iOS input work, so the fork remains required. ## Changes - `Cargo.lock`: bump `winit`/`dpi` to `Orbital-Winit` `a9d045d6`. - `ModuleRuntime`: track pointer-over-window and focus, and route `resumed`, `Focused`, `CursorGrabbed`, and `CursorEntered` through `sync_cursor_grab()`. Grabs are deferred until the pointer is over a focused surface, so winit is never asked to grab without a pointer. ## Verification - `cargo fmt --all -- --check` - `cargo clippy -- -D warnings` - `cargo test --no-fail-fast` - Ran `template_all_in_one` under Wayland; clean exit, no protocol errors. - `WAYLAND_DEBUG=1`: `confine_pointer` only after `wl_pointer.enter`; re-grabs are `destroy` -> `confine` with no discarded destroy; no `already_constrained`. Fork: `SakulFlee/Orbital-Winit@6de2c63c` (fix), `a9d045d6` (docs).
fix(app): avoid Wayland pointer-constraint crash on focus regain
All checks were successful
Lint / lint (pull_request) Successful in 2m31s
Templates / templates (pull_request) Successful in 4m5s
PR / test (pull_request) Successful in 7m21s
38fab88051
Backport winit 0.30.10's set_cursor_grab fix via Orbital-Winit and defer grab changes until the pointer is over a focused surface.

Applying a grab with no pointer over the window desynchronises winit's Wayland grab bookkeeping; a later re-apply can then send confine_pointer while the previous constraint is still active, which the compositor treats as a fatal already_constrained protocol error and drops the connection.

- Bump winit/dpi to Orbital-Winit a9d045d6.
- Track pointer-over-window and focus in ModuleRuntime.
- Route resumed, Focused, and CursorGrabbed through sync_cursor_grab().

Smart test results

Result: PASS

Scope: full workspace

Reason: workspace-level change: Cargo.lock

Elapsed: 6m 56s

Workflow run

Overall: 388 tests, 378 passed, 0 failed, 10 skipped

Nextest: 377 tests, 377 passed, 0 failed, 0 skipped
Doctests: 11 tests, 1 passed, 0 failed, 10 skipped

Outcome charts are split between nextest and doctests. The timing chart covers nextest only.

Crate Nextest Passed Failed Skipped Doctests Time
orbital 1 1 0 0 - 0.67s
orbital_2d 29 29 0 0 0/1 0.25s
orbital_app 9 9 0 0 0/1 0.07s
orbital_camera 4 4 0 0 - 0.04s
orbital_core 2 2 0 0 - 0.01s
orbital_debug_render 0 0 0 0 0/1 0.00s
orbital_debug_ui 28 28 0 0 0/1 0.24s
orbital_ecs 114 114 0 0 0/2 0.88s
orbital_ecs_bridge 33 33 0 0 - 0.23s
orbital_file_manager 5 5 0 0 - 0.04s
orbital_iced 15 15 0 0 - 0.11s
orbital_importer_gltf 13 13 0 0 - 0.17s
orbital_input 10 10 0 0 - 0.07s
orbital_light 6 6 0 0 - 0.04s
orbital_macros 0 0 0 0 0/1 0.00s
orbital_math 4 4 0 0 - 0.03s
orbital_procgeo 2 2 0 0 - 0.01s
orbital_resources 18 18 0 0 - 0.32s
orbital_shader_core 0 0 0 0 1/1 0.00s
orbital_shader_preprocessor 12 12 0 0 - 0.07s
orbital_shadow 3 3 0 0 - 0.02s
orbital_text 14 14 0 0 0/1 0.44s
orbital_texture 9 9 0 0 - 0.06s
orbital_touch_ui 1 1 0 0 0/1 0.01s
orbital_ui 32 32 0 0 0/1 0.26s
orbital_world_environment 13 13 0 0 - 0.10s
pie showData
    title Nextest outcomes
    "Passed" : 377
pie showData
    title Doctest outcomes
    "Passed" : 1
    "Skipped" : 10
xychart-beta
    title "Slowest crates (nextest seconds)"
    x-axis ["orbital_ecs", "orbital", "orbital_text", "orbital_resources", "orbital_ui", "orbital_2d", "orbital_debug_ui", "orbital_ecs_bridge"]
    y-axis "Seconds" 0 --> 1
    bar [0.88, 0.67, 0.44, 0.32, 0.26, 0.25, 0.24, 0.23]
<!-- orbital-ci-test-results --> ## Smart test results **Result:** PASS **Scope:** full workspace **Reason:** workspace-level change: Cargo.lock **Elapsed:** 6m 56s [Workflow run](https://forgejo.sakul-flee.de/SakulFlee/Orbital/actions/runs/478) **Overall:** 388 tests, 378 passed, 0 failed, 10 skipped **Nextest:** 377 tests, 377 passed, 0 failed, 0 skipped **Doctests:** 11 tests, 1 passed, 0 failed, 10 skipped _Outcome charts are split between nextest and doctests. The timing chart covers nextest only._ | Crate | Nextest | Passed | Failed | Skipped | Doctests | Time | | --- | ---: | ---: | ---: | ---: | ---: | ---: | | orbital | 1 | 1 | 0 | 0 | - | 0.67s | | orbital_2d | 29 | 29 | 0 | 0 | 0/1 | 0.25s | | orbital_app | 9 | 9 | 0 | 0 | 0/1 | 0.07s | | orbital_camera | 4 | 4 | 0 | 0 | - | 0.04s | | orbital_core | 2 | 2 | 0 | 0 | - | 0.01s | | orbital_debug_render | 0 | 0 | 0 | 0 | 0/1 | 0.00s | | orbital_debug_ui | 28 | 28 | 0 | 0 | 0/1 | 0.24s | | orbital_ecs | 114 | 114 | 0 | 0 | 0/2 | 0.88s | | orbital_ecs_bridge | 33 | 33 | 0 | 0 | - | 0.23s | | orbital_file_manager | 5 | 5 | 0 | 0 | - | 0.04s | | orbital_iced | 15 | 15 | 0 | 0 | - | 0.11s | | orbital_importer_gltf | 13 | 13 | 0 | 0 | - | 0.17s | | orbital_input | 10 | 10 | 0 | 0 | - | 0.07s | | orbital_light | 6 | 6 | 0 | 0 | - | 0.04s | | orbital_macros | 0 | 0 | 0 | 0 | 0/1 | 0.00s | | orbital_math | 4 | 4 | 0 | 0 | - | 0.03s | | orbital_procgeo | 2 | 2 | 0 | 0 | - | 0.01s | | orbital_resources | 18 | 18 | 0 | 0 | - | 0.32s | | orbital_shader_core | 0 | 0 | 0 | 0 | 1/1 | 0.00s | | orbital_shader_preprocessor | 12 | 12 | 0 | 0 | - | 0.07s | | orbital_shadow | 3 | 3 | 0 | 0 | - | 0.02s | | orbital_text | 14 | 14 | 0 | 0 | 0/1 | 0.44s | | orbital_texture | 9 | 9 | 0 | 0 | - | 0.06s | | orbital_touch_ui | 1 | 1 | 0 | 0 | 0/1 | 0.01s | | orbital_ui | 32 | 32 | 0 | 0 | 0/1 | 0.26s | | orbital_world_environment | 13 | 13 | 0 | 0 | - | 0.10s | ```mermaid pie showData title Nextest outcomes "Passed" : 377 ``` ```mermaid pie showData title Doctest outcomes "Passed" : 1 "Skipped" : 10 ``` ```mermaid xychart-beta title "Slowest crates (nextest seconds)" x-axis ["orbital_ecs", "orbital", "orbital_text", "orbital_resources", "orbital_ui", "orbital_2d", "orbital_debug_ui", "orbital_ecs_bridge"] y-axis "Seconds" 0 --> 1 bar [0.88, 0.67, 0.44, 0.32, 0.26, 0.25, 0.24, 0.23] ```
SakulFlee deleted branch fix/wayland-pointer-constraint-crash 2026-10-23 21:28:26 +00:00
Sign in to join this conversation.
No description provided.