Skip to content

fix(wayland): stop aborting on a subsurface without a parent - #135

Merged
PapyElGringo merged 1 commit into
mainfrom
fix/parentless-subsurface-crash
Oct 14, 2026
Merged

PapyElGringo merged 1 commit into
mainfrom
fix/parentless-subsurface-crash

Conversation

@PapyElGringo

Copy link
Copy Markdown
Contributor

What

Fixes the crash reported in #132.

The log's real failure is not the recurring font-weight errors but:

thread 'main' (2525) panicked at src/embedder/state.rs:790:57:
called `Option::unwrap()` on a `None` value
...
thread caused non-unwinding panic. aborting.

Column 57 of that line is the .unwrap() in:

parent: get_surface_id(&get_parent(surface).unwrap()),

src/embedder/state.rs, State::construct_subsurface_role_message. The backtrace shows it running inside wayland_backend::sys::server_impl::resource_dispatcher, i.e. a Wayland request handler. Wayland dispatch cannot unwind, so the panic aborts the whole process instead of failing one request.

Root cause

In the pinned Smithay, destroying a wl_subsurface calls PrivateSurfaceData::unset_parent, which only take()s the parent link — it leaves role == SUBSURFACE_ROLE on the wl_surface. So a surface can report the subsurface role while get_parent() returns None.

construct_surface_role_message matched on that role and unwrapped the parent unconditionally. Any later commit of the still-alive surface, or the shell-reload resend in on_shell_ready (which iterates data.subsurfaces, still holding the entry), hit None and aborted.

Fix

  • construct_subsurface_role_message now returns Option<SubsurfaceMessage>, using get_parent(surface)?.
  • construct_surface_role_message maps through it, so a parentless subsurface yields role = None.
  • on_shell_ready skips the resend when the role message is None.

The shell already treats a null role as roleless (surface.manager.dart), so this degrades gracefully.

Verification

  • cargo check — clean (only pre-existing warnings).
  • cargo test — 216 passed, 0 failed.
  • cargo fmt applied.

Not part of this fix

The Bad state: Invalid "font-weight": 596 spam comes from flutter_svg/vector_graphics_compiler on a malformed SVG asset and is logged as an unhandled isolate exception; it does not abort the app. Tracked separately.

A `wl_surface` whose `wl_subsurface` was destroyed still reports the
`subsurface` role: Smithay's `unset_parent` only clears the parent link,
leaving `role == SUBSURFACE_ROLE`. `construct_subsurface_role_message`
then unwrapped `get_parent()`, so a later commit of that surface — or the
shell-reload resend in `on_shell_ready` — hit `None` and panicked inside
Wayland request dispatch. That dispatch cannot unwind, so the panic
aborted the whole compositor instead of failing one request (issue #132).

Return `None` from `construct_subsurface_role_message` when the parent is
gone and treat the surface as roleless on both call paths. The shell
already handles a null role.
@PapyElGringo
PapyElGringo merged commit 100199e into main Oct 14, 2026
2 checks passed
@PapyElGringo
PapyElGringo deleted the fix/parentless-subsurface-crash branch October 14, 2026 07:14
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.

1 participant