Skip to content

fix: tear down and release the panel and dock on rebuild - #53

Merged
mirkobrombin merged 2 commits into
singularityos-lab:mainfrom
BlakeGardner:fix/release-replaced-shell-surfaces
Nov 29, 2026
Merged

mirkobrombin merged 2 commits into
singularityos-lab:mainfrom
BlakeGardner:fix/release-replaced-shell-surfaces

Conversation

@BlakeGardner

@BlakeGardner BlakeGardner commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Moving the dock to another display in Settings → Displays rebuilds the panel
and dock, and the old ones are never cleaned up:

  • After a few moves, opening and closing a fullscreen app (a game, in my case) leaves extra dimmed top bars and docks stacked on screen, one per earlier move.
  • Every move after the first logs DockDBusService register_object failed. The first dock keeps the dev.sinty.Dock object path, so apps setting badges, icons or menus over D-Bus keep talking to a dock that is gone.
  • Each move leaves a full panel and dock in memory, still reacting to settings, network, audio and power changes.

Video of the issue

https://www.youtube.com/watch?v=Nr3IGMWpyKE

Cause

In GTK4, destroy() only hides a window and drops it from the toplevel list.
dispose() waits for the last reference, and the panel and dock are kept
alive by their own signal handlers. Their cleanup lived in dispose(), so it
never ran.

Commit 1 — tear down on destroy

  • Run the panel and dock teardown from destroy().
  • Refuse to show a panel or dock that is no longer a toplevel.

This alone fixes the ghost bars and docks.

Commit 2 — release what was replaced

  • One shared DockDBusService for the session. It registers once, and what
    apps set survives a rebuild.
  • Handlers connected on shared services go into a small SignalBag and are
    disconnected at teardown.
  • After destroy() returns, the window tree is disposed, which breaks the
    reference loops through the surface's own widgets and controllers.

Generative AI assistance

AI assistance: disclosed

Moving the shell to another display rebuilds the panel and dock. In GTK4
destroy() only hides a window and drops it from the toplevel list;
dispose() waits for the last reference, and the signal closures that
capture the panel and dock keep them alive. Their cleanup lived in
dispose(), so it never ran: the replaced surfaces kept answering
fullscreen and focus signals and presented themselves again when a
fullscreen window closed, leaving one extra panel and dock on screen per
earlier move.

Run the teardown from destroy(), disconnect the panel's AppSystem,
HomeCover and wallpaper handlers there, and refuse to show a panel or
dock that is no longer in the toplevel list.

Assisted-by: Claude:claude-fable-5-2
AI-Scope: diagnosis from shell logs and a temporary show/map probe; destroy-time teardown and show guard in panel, dock and layer_window
A panel or dock that was destroyed for a rebuild was never freed. Lambdas
connected on shared services held it, its own widgets and event
controllers held it through their handlers, and the dock's motion hints
held it through their alias callback. Each move of the shell to another
display left one more of each in memory, still reacting to settings,
network, audio and power changes.

The dock also created a D-Bus service per instance. The first one kept
the dev.sinty.Dock object path, so every later dock failed to register
and apps kept talking to the service of a dock that was gone.

Collect the handlers connected on outside objects in a SignalBag and
disconnect them in the teardown, drop the motion hints there, and
dispose the window tree once destroy() has returned. Make the dock D-Bus
service one shared instance, so the registration happens once and the
suffixes, icons and menus apps set survive a rebuild.

Checked in a headless session with two outputs: ten moves of the shell
between them release ten docks and nine panels with no GTK criticals.
The newest replaced panel is still held until the following rebuild.

Assisted-by: Claude:claude-fable-5-2
AI-Scope: leak analysis, SignalBag and window tree release helpers, handler tracking in panel and dock, shared dock D-Bus service; tested in a headless labwc session
@BlakeGardner
BlakeGardner force-pushed the fix/release-replaced-shell-surfaces branch from 7a0c200 to c63af34 Compare November 29, 2026 17:30
@mirkobrombin
mirkobrombin merged commit 0f79657 into singularityos-lab:main Nov 29, 2026
3 checks passed
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.

2 participants