From a598809e0e6ac2a47d9081dbf5a34747a1a739b2 Mon Sep 17 00:00:00 2001 From: Alexey Martemyanov Date: Thu, 15 Oct 2026 00:03:03 +0600 Subject: [PATCH] [2026-10-15] eagle: work/projects/macos-tests-worktrees-2026-10-14.md --- .../macos-tests-worktrees-2026-10-14.md | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/work/projects/macos-tests-worktrees-2026-10-14.md b/work/projects/macos-tests-worktrees-2026-10-14.md index e0a86437..793dd9cb 100644 --- a/work/projects/macos-tests-worktrees-2026-10-14.md +++ b/work/projects/macos-tests-worktrees-2026-10-14.md @@ -19,7 +19,7 @@ All worktrees are in `/Users/admin/DuckDuckGo/apple-browsers.git/`, on bra | `macos-unit-tests-no-app-delegate` | origin/main `ca834f869a` | Unit tests no longer use the app delegate, buildable folder, test plans | Done, not committed | | `fix-address-bar-tests-flakiness` | origin/main `ddb1a82283` | Fix flaky `AddressBarTests`: mocks plus two leak root causes | Done, not committed | | `fix-ask-ai-chat-button-animation-leak` | origin/main `e698211924` | Ask AI Chat button animation leak plus regression test | In progress | -| `animation-leak-audit` (+ `fix-…-leak` per confirmed leak) | origin/main `e698211924` | Audit `NSAnimationContext` completion handlers for leaks | In progress | +| ~~`animation-leak-audit`~~ | origin/main `e698211924` | Audit `NSAnimationContext` completion handlers for leaks | Done: no leaks found; worktree and branch removed | | `fix-fire-window-video-leak` | origin/main `e698211924` | Video keeps playing after a Fire Window is closed: reproduce, fix, regression test | In progress | | `spm-browser-tests` (existing) | — | Source of the unit-test changes (SwiftPM variant) | Not changed | @@ -51,7 +51,7 @@ Branch `alex/fix-address-bar-tests-flakiness`. 3 files, +100/−6. - **Root cause:** the tests didn't actually hang. In DEBUG, `ensureObjectDeallocated(... .interrupt)` sends SIGINT when an object is still alive. Two causes: 1. `TestRunHelper` read `NSApp.windows`, which autoreleased the address bar's suggestions window. Fixed with `autoreleasepool`. - 2. A real leak in the app: the `animateAskAIChatButtonContraction()` completion handler captured `self` strongly. Fixed with `[weak self]`. + 2. The `animateAskAIChatButtonContraction()` completion handler captured `self` strongly. Fixed with `[weak self]`. The audit refined this finding: it isn't a permanent leak. While the display is asleep, the completion is held until it wakes. - **Mocks and settings in `AddressBarTests`:** - OHHTTPStubs answers `duckduckgo.com/ac/` and blocks all other external network. - AI Chat settings are pinned in `NSArgumentDomain`. @@ -60,18 +60,31 @@ Branch `alex/fix-address-bar-tests-flakiness`. 3 files, +100/−6. - Isolated: 7 out of 7 runs with 0 failures and 0 restarts. Before the fix, origin/main had 1–6 failures per run. - Full Integration Tests ×2: 0 AddressBarTests failures. - The 3 remaining failures also fail on main because of this machine's settings: FireCoordinator (locale) and NTP search (`aichat.enabled=0`). +- **TODO:** reword the comment in `AddressBarButtonsViewController` to say the handler is held until the animation ends, rather than "never called". The wording will match the fix in `fix-ask-ai-chat-button-animation-leak`. ## fix-ask-ai-chat-button-animation-leak -Branch `alex/fix-ask-ai-chat-button-animation-leak`. In progress. Separate production fix for the Ask AI Chat button animation leak in `AddressBarButtonsViewController`, plus a regression test that fails on main and passes with the fix. +Branch `alex/fix-ask-ai-chat-button-animation-leak`. In progress. Separate production fix for the Ask AI Chat button animation in `AddressBarButtonsViewController` (`[weak self]`), plus a regression test. -## animation-leak-audit (+ worktrees per confirmed leak) +- **Revised requirement after the audit:** the test must fail on main deterministically regardless of whether the display is asleep or awake. It asserts deallocation right after teardown, before the 0.2 s animation ends. -Branch `alex/animation-leak-audit` is for investigation. In progress. It checks `NSAnimationContext` completion handlers: `NavigationBarBadgeAnimator`, `BrowserTabViewController.dismissCookiePopupProtectionOptInDialog`, and others. Each confirmed leak gets its own `alex/fix-…-leak` worktree with a regression test. +## animation-leak-audit (removed) + +Checked with standalone AppKit harnesses (in the session scratchpad: `scratchpad/anim/exp*.swift`). No permanent leaks were found, and the code was not changed. The worktree and branch were removed. + +- **Key finding:** AppKit does call `runAnimationGroup` completion handlers after the window is closed. + - Animations of a view's `alphaValue`/`frame`, `performBatchUpdates`, and `scroll` always complete. + - Display-link-driven animations (`NSLayoutConstraint.animator().constant`, `NSWindow.animator().alphaValue`) stall while the display is asleep. Their completion, along with any strong captures, is held until the display wakes. + - This Mac has `displaysleep 10`, so its display is often asleep. That explains the flaky dealloc checks in tests. +- **Checked, no leaks found:** + - `NavigationBarBadgeAnimator` (alpha only, no view controller or window captured). + - `BrowserTabViewController.dismissCookiePopupProtectionOptInDialog` (alpha only, `self` not captured). + - `AIChatCoordinator.transitionSidebar` and `TabBarViewController` (weak captures, or completions that always run). + - `PromptBarPresenter.dismiss`, `CircularProgressView`, `SpinnerView`, `JSAlertController`, and others. ## fix-fire-window-video-leak -Branch `alex/fix-fire-window-video-leak`. In progress. Reproduce (with a test) the bug where video and audio keep playing after a Fire Window is closed, find the root cause, and fix it. +Branch `alex/fix-fire-window-video-leak`. In progress. Reproduce (with a test) the bug where video and audio keep playing after a Fire Window is closed, find the root cause, and fix it. The test must work whether the display is asleep or awake. ## Temporary and source worktrees