fix(ios): hold ContentBlocker pending targets weakly, drop on failure#25
Merged
Conversation
pendingTargets held queued WKWebViews strongly and was never drained on a compile failure (or when WKContentRuleListStore.default() is nil, whose completion never fires), leaking them for the app's lifetime. A tab closed during the ~cold-compile window was likewise kept alive and then received a pointless add-rules + reload() on its detached web view when the queue drained. - Hold pendingTargets as weak boxes; drainPending skips deallocated targets. - Clear the queue on terminal compile failure. - TabsManager.closeTab removes the closing tab's web view via ContentBlocker.cancelPending(for:) so it is neither reloaded nor retained. Adds tests for the compile-failure branch and the removed/deallocated-before- drain paths, plus FakeRuleListStore.failCompile() to model a terminal completed(false) (distinct from the existing defer-then-succeed). Resolves P3 #1 and closes the P3 #5 test-fidelity gap from the M5 final review. Full BlancTests suite: 81/81 green (incl. the WebKit integration test and TabsManagerTests). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Fixes two latent lifetime defects in the iOS
ContentBlockerad-block queue (P3 #1 from the M5 final review):pendingTargetsheld queuedWKWebViews strongly and was never drained on a compile failure (or whenWKContentRuleListStore.default()is nil, whose completion never fires), leaking them for the app's lifetime.add(ruleList)+reload()on its detached web view when the queue drained.Changes
pendingTargetsas weak boxes;drainPendingskips targets that deallocated while queued.TabsManager.closeTabremoves the closing tab's web view viaContentBlocker.cancelPending(for:)so it is neither reloaded nor retained.Tests
FakeRuleListStore.failCompile()to model a terminalcompleted(false)(distinct from the existing defer-then-succeed).BlancTestssuite: 81/81 green, including the real-WebKit integration test andTabsManagerTests.Resolves P3 #1 and closes the P3 #5 compile-failure test-fidelity gap.
🤖 Generated with Claude Code