Skip to content

fix(core): free an overlay's host entry when its view goes - #1008

Open
iFwu wants to merge 2 commits into
nsgo-dev:mainfrom
iFwu:fix/discard-hosted-overlay
Open

iFwu wants to merge 2 commits into
nsgo-dev:mainfrom
iFwu:fix/discard-hosted-overlay

Conversation

@iFwu

@iFwu iFwu commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1006.

Tree.discard left a hoisted node in its host's hosted list. Readers skip deleted entries, but the list kept the node, and through its parent and children the whole subtree it was in, for the life of the window. This held for every hoisted node (an Overlay, a Modal, a Position: Fixed view), and a Tooltip's bubble is a hoisted overlay even while hidden, so every rebuild of a view with a tooltip kept that view. discard now takes the node out of its host's list, as syncPosition and rehost already do when a node leaves a host.

  • core/tree.go: discard removes n from n.hoist.host.hosted.
  • core/tooltip_test.go: TestRebuiltTooltipFreesTheOldView rebuilds a view with a tooltip three times, then checks that the root view hosts one overlay and that the first view is collected. It fails on main with 4 hosted overlays.
  • CHANGELOG.md: an Unreleased line.

Targets

  • Shared code (core, base, ui, tsx, the nsgo tool)
  • macOS
  • iOS
  • tvOS
  • watchOS
  • Android
  • Windows
  • Linux
  • Web
  • Mini programs
  • Docs or website only

Screenshots

None.

Verification

  • go tool nsgo test -run '^TestRebuiltTooltipFreesTheOldView$' ./core fails on main at 211434ba (the root view hosts 4 overlays, want the shown tooltip's 1) and passes with this change, also with -count=3.
  • go tool nsgo check on Linux x86_64 (the host): passes.
  • go tool nsgo test on Linux x86_64 under Xvfb (GDK_BACKEND=x11, GSK_RENDERER=cairo): 3,060 passed, 9 failed, 59 skipped. The same 8 fail on main in the same environment: TestAccessibilitySelectedAndExpandedReachATSPI (no AT-SPI registry), TestVideoShowsWhatIsBehindItsTransparentPixels (no GStreamer plug-in for the alpha WebM), and six TestInstance* whose socket path passed the address limit under this run's long TMPDIR; all six pass with a short one. TestInputsDrawTheirTextAsTextDoes (internal/platform/linux) failed once under the full run's load, as it did once on the other fix's branch; it passes alone three times out of three here and on main.
  • On macOS, the same change on v0.2.0 has run in a desktop app since 2026-11-20 (Apple M3, macOS 27.2.1), whose memory stays flat where it grew without it.
  • Not run: -target tests, as nothing here is backend-specific; Windows, web and Apple's mobile targets.

Checklist

  • The title is a Conventional Commit, such as fix(linux): keep the caret after a paste; a squash merge uses it as the commit subject.
  • Docs whose facts change are updated, and CHANGELOG.md's Unreleased has a line for a capability users can see.
  • New third-party code, assets and dependencies name their source and license.

@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation core labels Nov 20, 2026
@github-actions

Copy link
Copy Markdown

Thanks for your first pull request! Before it is merged:

  • Write the title as a Conventional Commit, such as fix(linux): ...; a squash merge uses it as the commit subject.
  • Run go tool nsgo check and go tool nsgo test, and say in the description what you ran on which targets and what you could not.
  • Making a change says what a pull request needs, and AGENTS.md and ARCHITECTURE.md how the code is organized.

@houko
houko force-pushed the fix/discard-hosted-overlay branch 2 times, most recently from dbf44ec to 99337fb Compare November 20, 2026 15:45
discard left a hoisted node in its host's hosted list: readers skip deleted entries, but the list kept the node, and through its parent and children the whole subtree it was in, for the life of the window. This holds for every hoisted node, an Overlay, a Modal or a Fixed view, and a Tooltip's bubble is a hoisted overlay even while hidden, so every rebuild of a view with a tooltip kept that view, its text layouts and its bindings. discard now takes the node out of its host's list, as syncPosition and rehost do when a node leaves a host.

Fixes #NNN
@houko
houko force-pushed the fix/discard-hosted-overlay branch from 99337fb to d40ce90 Compare November 20, 2026 16:28
The previous commit's CHANGELOG line and Fixes footer held #NNN until the issue was filed.

Fixes nsgo-dev#1006
@houko
houko force-pushed the fix/discard-hosted-overlay branch from d40ce90 to 261f6db Compare November 20, 2026 16:28

This branch has not been deployed

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

Labels

bug Something isn't working core documentation Improvements or additions to documentation size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core: a removed Tooltip, Overlay, Modal or Fixed view stays in its host's hosted list and keeps the whole removed subtree alive

1 participant