fix(desktop): release leaked NSGlassEffectView on re-apply#1912
Merged
richiemcilroy merged 2 commits intoJun 12, 2026
Merged
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
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
apply_liquid_glass_background does alloc + initWithFrame on an NSGlassEffectView (a +1 retain from alloc) and adds it as a subview.
remove_liquid_glass_subviews only called removeFromSuperview, which drops the superview's retain but never balances the original alloc, so every re-apply (e.g. each window-chrome route navigation that triggers createEffect) permanently leaks one GPU/IOSurface-backed NSGlassEffectView at refcount 1.
This adds the matching release after removeFromSuperview to balance
ownership.
Test plan
Greptile Summary
Fixes a memory leak in the macOS Liquid Glass background feature where every call to
apply_liquid_glass_backgroundpermanently leaked one GPU/IOSurface-backedNSGlassEffectView. The root cause was thatalloc+initWithFramegave the Rust caller a +1 ownership retain, butremove_liquid_glass_subviewsonly calledremoveFromSuperview(which drops the superview's retain), leaving the alloc retain permanently unbalanced.msg_send![view, release]immediately afterremoveFromSuperviewinremove_liquid_glass_subviews, consistent with the identical pattern already present in the early-return path ofapply_liquid_glass_background(line 228).subviewsNSArray snapshot, which is returned autoreleased and retains each element, keeps each view alive through the release call, so there is no use-after-free risk during the iteration.continueafterreleaseprevents any further use of the pointer.Confidence Score: 5/5
The change is a single-line addition that correctly balances a known alloc/release pair; no existing behavior is altered beyond reclaiming the leaked memory.
The fix mirrors the identical
releasepattern used in the early-bailout path ofapply_liquid_glass_background(line 228), confirming this is the right idiom for this codebase. The NSArray snapshot retains each view element throughout the loop, so there is no use-after-free exposure, and thecontinueensures the pointer is never touched after the release. No other call site needs updating.No files require special attention.
Important Files Changed
releaseafterremoveFromSuperviewinremove_liquid_glass_subviewsto fix a memory leak of alloc-ownedNSGlassEffectViewobjects on every re-apply.Reviews (1): Last reviewed commit: "fix(desktop): release leaked NSGlassEffe..." | Re-trigger Greptile