Skip to content

test(ios): wait for the navigation glass animation to finish - #9787

Closed
brow wants to merge 2 commits into
fix-ios-navigation-glass-test-flakefrom
nav-glass-test-wait-for-settle
Closed

brow wants to merge 2 commits into
fix-ios-navigation-glass-test-flakefrom
nav-glass-test-wait-for-settle

Conversation

@brow

@brow brow commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #9786. Test-only.

UIViewPropertyAnimator.startAnimation() sets the views' model alpha and transform right away. So both waitUntil conditions in #9786 already hold on their first check, before anything animates. The test then starts close/open/close while the open is still running and reads the end state before any animation finishes. It never exercises a close that starts after the open has finished, which is what happens when someone closes the menu.

This adds one condition to each wait: both side layers have no running animations (layer.animationKeys() is empty). Each wait now returns once the animation finishes. The rapid close/open/close calls stay back-to-back, and the helper and assertions are unchanged.

Regressions

None expected. The waits now take until the animation ends instead of returning at once. The whole test took 0.07 s on the simulator (0.03 s on #9786, about 2 s before it).

Validation

On an iOS 27 simulator, running only this test, with three temporary mutations of JumpToLatestGlassButton.swift (never committed):

Production code #9786 This PR
Unchanged passes passes (0.07 s)
Active-animator check rewritten as guard state == .active else { return }, so a close after a finished open does nothing passes fails at "restored", both orientations
Animator started with isReversed = true passes fails at "merged", both orientations
Open completion resets the left surface's alpha to 1 passes fails at "merged", both orientations

The first two change only code that exists today. The old one-second polling caught them only because it happened to look after the animation had finished.

matt2e and others added 2 commits November 20, 2026 17:39
…econd

testNavigationGlassMergesAndRestoresInBothDirections timed out on CI
(run 44682658228) waiting 2 s for the side surfaces of
MergingNavigationGlass to fade out after setMenuOpen(true), a 0.18 s
animation.

The test waited with XCTNSPredicateExpectation, which evaluates its
predicate about once a second: the test's four waits take about 4 s in
passing runs, 1 s each for a 0.18 s animation. A 2 s timeout therefore
gets one or two evaluations. RunnerTests runs inside the Flutter app, and
when that app holds the main thread across those evaluations the wait
expires even though the animation has long finished. In the failing run
the 2 s timeout was reported 5.2 s after the test started.

Replace both waits with a `waitUntil` helper that checks the condition
every 10 ms on the main actor for up to 10 s, the budget the other
RunnerTests callbacks use. It checks the condition before the deadline on
every pass, so a main-thread stall of any length is followed by one more
check rather than a timeout. The conditions and the assertions after them
are unchanged, and the test no longer spends 4 s waiting.

The cause is inferred from the CI timings and the code. Not compiled or
run locally; `swiftc -parse` accepts the file.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
The merged and restored values are set as soon as an animation starts,
so both waits passed on their first check. Also require that the side
layers have no running animations, so the close that follows starts from
a finished animator.

Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
Signed-off-by: Tom Brow <tomb@block.xyz>
@brow
brow marked this pull request as ready for review November 20, 2026 07:37
@brow
brow requested a review from a team as a code owner November 20, 2026 07:37
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T07:38:19.949618Z 0519036 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Star Lord recommends approval at 0519036. Two source reviews found no issues with the animation waits, and the native iOS CI job was still running at review time.

@jedwards27 jedwards27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 :bot: Jude’s code review agent — changes recommended on 05190369eef50ac538c53ed58ee3213244f25db2 (base aee2ab3f7a9ba6e1b0066291297bdd4afc071893). This is a test-only correctness finding, not a production UI finding.

The wait does not establish animation completion. mobile/ios/RunnerTests/RunnerTests.swift:71–86,94–99 creates MergingNavigationGlass without a window and interprets empty leftSurface/rightSurface.layer.animationKeys() as “finished.” Those keys can also be empty when no Core Animation was installed/observed on the detached layers, or when Reduce Motion skips animation. The property animator in mobile/ios/Runner/JumpToLatestGlassButton.swift:827–865 is configured for 0.18 s; the PR reports only 0.07 s for both orientations. Timing alone is not conclusive, but the test never observes the animation start or its completion, so the central promised case—closing after a completed open—is not proven. The existing state mutations demonstrate assertions are sensitive to state, not to that completion boundary.

Author action: Exercise the animated path in a visible test window (skip explicitly if Reduce Motion is enabled), and require an observed active animation followed by a completed animation before the first close; an explicit property-animator completion signal is also a sound alternative. Preserve the back-to-back close/open/close burst. Demonstrate that a mutation making post-completion close a no-op fails because the completion boundary is exercised, with an exact-head native simulator run. A mere delay without a start/completion assertion would leave the same blind spot.

Validation / ownership: Source and exact-head diff review on macOS; git diff aee2ab3... 05190369... --check passed. GitHub’s Mobile Swift Native/Release and mobile test checks passed on this head, but none establish the timing condition. No independent native simulator result is claimed here; reviewer/native verification remains outstanding, separate from the author-actionable test defect. No other issue found in the 11-line test-only diff. Formal Request Changes is left to the human reviewer.

@matt2e
matt2e force-pushed the fix-ios-navigation-glass-test-flake branch from aee2ab3 to 7cdfda6 Compare November 23, 2026 03:39
@brow

brow commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

🤖 Landed in #9786 as 7cdfda6.

@brow brow closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants