Skip to content

fix(core): free a removed relayout boundary from the boundary queue - #1009

Merged
houko merged 2 commits into
nsgo-dev:mainfrom
iFwu:fix/relayout-boundary-slots
Nov 20, 2026
Merged

houko merged 2 commits into
nsgo-dev:mainfrom
iFwu:fix/relayout-boundary-slots

Conversation

@iFwu

@iFwu iFwu commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1007.

relayoutBoundaries popped Tree.boundaries without clearing the slot, so the backing array kept every boundary it had laid out, and through each the whole subtree it was in, until a later queue as long reused the slot. A view hidden or rebuilt after being laid out on its own stayed in memory. The pop now clears the slot.

  • core/layout.go: clear the popped slot.
  • core/layout_test.go: TestRemovedRelayoutBoundariesAreFreed lays out two boundaries on their own, hides, shows and hides them again, then checks that both are collected. It fails on main.
  • 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 '^TestRemovedRelayoutBoundariesAreFreed$' ./core fails on main at 211434ba (a boundary removed two showings ago stays in memory) 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,061 passed, 8 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.
  • 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 size/S documentation Improvements or additions to documentation core bug Something isn't working labels Nov 20, 2026
@houko
houko force-pushed the fix/relayout-boundary-slots branch from e35838f to 8bc62c7 Compare November 20, 2026 15:03
iFwu added 2 commits November 21, 2026 00:45
relayoutBoundaries popped Tree.boundaries without clearing the slot, so the backing array kept every boundary it had laid out, and through each the whole subtree it was in, until a later queue as long reused the slot. A view hidden or rebuilt after being laid out on its own stayed in memory, and an app switching between views kept a removed copy per slot. The pop now clears the slot.

Fixes #NNN
The previous commit's CHANGELOG line and Fixes footer held #NNN until the issue was filed.

Fixes nsgo-dev#1007
@houko
houko force-pushed the fix/relayout-boundary-slots branch from 8bc62c7 to f7a4874 Compare November 20, 2026 15:45
@houko

houko commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Reviewed. Thank you, @iFwu!

  • Clearing the popped slot is correct and minimal.
  • The new test fails on main and passes with the fix; the core tests pass.
  • Core-only change, so no device check.

@houko
houko merged commit be72083 into nsgo-dev:main Nov 20, 2026
20 checks passed
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 view that was laid out as a relayout boundary stays alive in Tree.boundaries

2 participants