fix: widget lifecycle correctness sweep (#171, #173, #174, #175, #181, #182)#186
Merged
Conversation
…174) Evicted decorators were overwritten without UnmountTree, leaking GPU scenes and signal bindings. New decorators from Content[C].Render were never mounted, so child signal bindings were dead. Changes: - cleanupWidget helper calls UnmountTree on evicted widgets - fullRebuild/incrementalUpdate unmount old widgets before replacement - clear() unmounts all widgets before zeroing - buildDecorator calls MountTree after creation when ctx is available - cache.update() now accepts widget.Context (passed from Draw)
…181) Cell widgets from Content[C].Render were never mounted (signal bindings dead) and never unmounted on eviction (scene/binding leak). Changes: - cellCache.update unmounts old widgets before rebuilding - cellCache.clear unmounts all widgets - New cells are mounted with MountTree when ctx is available - cellCache.update accepts widget.Context parameter
Overlay containers were pushed/popped without mount/unmount calls, leaking signal bindings and goroutines in content widgets. Changes: - PushOverlay calls MountTree on the container after pushing - PopOverlay calls UnmountTree on the popped container - RemoveOverlay unmounts the target and all overlays above it (matching overlay.Stack.Remove stack semantics)
Window had no Close method, so the animation pumper goroutine leaked on window close, and widget trees were never unmounted. Changes: - Window.Close() stops animPumper, unmounts all overlays, unmounts root - desktop.Run OnClose callback calls Window.Close before releasing GPU - Close is idempotent (safe to call multiple times)
…fety (#182) PushValue, AddSeries, ClearSeries called SetNeedsRedraw directly from arbitrary goroutines. SetNeedsRedraw propagates upward through the parent chain which is not thread-safe. Changes: - Add scheduler field, stored during Mount, cleared during Unmount - requestRedraw helper routes through scheduler.MarkDirty when available, falls back to direct SetNeedsRedraw for unmounted usage - Replace all SetNeedsRedraw(true) calls with requestRedraw()
- listview lifecycle_test.go: mount/unmount on scroll, eviction, clear - gridview lifecycle_test.go: cell mount/unmount, update, invalidate - overlay_lifecycle_test.go: push/pop lifecycle, signal bindings - window_close_test.go: close idempotency, unmount, stop pumper - linechart safety_test.go: concurrent PushValue, scheduler routing - CHANGELOG v0.1.46, ROADMAP version update
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Six widget lifecycle fixes addressing memory leaks, goroutine leaks, and dead signal bindings reported by @AnyCPU from long-term macOS testing.
Fixed
scene.SceneContent[C].Render()results receiveMountTreesoBindToSchedulersignal bindings activatePushOverlaycallsMountTree,PopOverlay/RemoveOverlaycallUnmountTreeSetNeedsRedrawTests
28 regression tests across 5 new test files:
core/listview/lifecycle_test.go(5 tests)core/gridview/lifecycle_test.go(4 tests)app/overlay_lifecycle_test.go(7 tests)app/window_close_test.go(6 tests)core/linechart/safety_test.go(6 tests)Test plan
go build ./...— passgo test ./... -count=1— all tests passgolangci-lint run --timeout=5m— 0 issues