Skip to content

fix(test): remove the tight timeout from the blur snapshot test - #60

Merged
futamura merged 1 commit into
developfrom
fix/blur-snapshot-test-flake
Aug 21, 2026
Merged

fix(test): remove the tight timeout from the blur snapshot test#60
futamura merged 1 commit into
developfrom
fix/blur-snapshot-test-flake

Conversation

@futamura

Copy link
Copy Markdown
Owner

目的

UIKitSpecprepares blurred snapshots before becoming visible が CI で断続的に fail する。記録上 3 件 (PR #47 / #58 / #59)。いずれも同一 commit の再実行で pass しており、実装の bug ではなく test の待ち時間不足 (#41)。

原因

FluidBlurredBackgroundView は blur 画像を 2 段の async hop で生成する。

applyVisibility() -> updateSnapshot()
  -> blurQueue.async { CIGaussianBlur }
    -> DispatchQueue.main.async { blurView.image = blurredImage }

test 側は RunLoop.main.run(until:) を 0.01 秒刻みで回して待つ。CI runner が飽和していると 0.5 秒で 2 hop が完了しない。

suite 全体で tight な timeout はこの 1 箇所だけだった。helper waitForBlurredImage(in:timeout:) の default は 10 秒で、他 5 箇所 (1393 / 1436 / 1461 / 1502 / 1526) はすべて default を使い、flake の記録がない。

変更

-                    expect(waitForBlurredImage(in: backgroundView, timeout: 0.5)).notTo(beNil())
+                    expect(waitForBlurredImage(in: backgroundView)).notTo(beNil())
+                    expect(backgroundView.visibility).to(beCloseTo(0))
+                    expect(blurView?.alpha).to(beCloseTo(0))
  • timeout: 0.5 の override を削除し default (10 秒) を使う。他 5 箇所と揃う。
  • 待機後にも visibility / alpha が 0 のままであることを assert する。 この test の主張は「不可視のまま snapshot が準備される」ことであり、その担保は待ち時間ではなく可視性の assertion。従来は待機前にしか確認しておらず、0.5 という値は主張に寄与していなかった。

Sources は変更しない。

却下した案

  • Sources に snapshot 完了 callback を追加 — test 専用 surface を library に持ち込む。結局 async のため test 側は timeout 付きで待つことになり決定性は上がらない。Simulator 確認 gate と source compatibility 確認も発生する。
  • blur の同期化 — main thread で CIGaussianBlur を回すことになり実挙動が悪化する。

Verification

gate 結果
git diff --check exit 0
xcodebuild test -only-testing:FluidableTests 連続 3 回とも 174 tests / 0 failures
bundle exec fastlane ios lint 0 violations, 0 serious in 135 files
CI lint / test この PR の run で確認

Sources 非変更のため Simulator / 実機確認は非該当。

残リスク

flake の不在は証明できない。根拠は margin が 0.5 秒 -> 10 秒で 20 倍になること、および同じ default を使う 5 箇所が記録上一度も flake していないこと。再発した場合は helper の待ち方自体を作り直す判断になる。

関連: #41

UIKitSpec's "prepares blurred snapshots before becoming visible" waited
only 0.5 seconds for the blurred image and failed on CI in PRs #47, #58
and #59. A rerun of the same commit passed every time.

FluidBlurredBackgroundView produces the image across two async hops:
blurQueue runs CIGaussianBlur, then the main queue assigns
blurView.image. A loaded runner does not always finish both within
0.5s. This was the only tight timeout in the suite; the other five
call sites use the 10 second default and have never flaked.

Drop the override so the test uses that default, and assert visibility
and alpha again after the wait. The claim the test makes, that the
snapshot is prepared while the view is invisible, now rests on those
assertions instead of on how long the wait happened to be.
@futamura
futamura merged commit 0e1a2ba into develop Aug 21, 2026
2 checks passed
@futamura
futamura deleted the fix/blur-snapshot-test-flake branch August 21, 2026 02:03
@futamura futamura mentioned this pull request Aug 21, 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.

1 participant