Skip to content

test(example): de-flake use-rive-trigger #230 (deterministic re-renders)#303

Merged
mfazekas merged 2 commits into
mainfrom
fix/flaky-use-rive-trigger-renders
Jul 1, 2026
Merged

test(example): de-flake use-rive-trigger #230 (deterministic re-renders)#303
mfazekas merged 2 commits into
mainfrom
fix/flaky-use-rive-trigger-renders

Conversation

@mfazekas

@mfazekas mfazekas commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

The #230 test drove re-renders with setInterval(50ms) for 300ms and asserted renderCount >= 3 within a 2000ms waitFor. waitFor resolves the instant renderCount hits 3 — i.e. it needs exactly 2 interval ticks, zero margin. When the JS thread is busy at mount (RiveView + dataBind init) the ticks are starved and only 1 lands, so renderCount stays at 2 and the test fails (the intermittent expected 2 to be greater than or equal to 3).

Fix

Drive the re-renders deterministically via an exposed context.rerender() (the pattern issue297.hooks already uses) instead of racing a wall-clock setInterval. The callback-identity churn is preserved; the timing dependence is gone.

Reproduction kept in the test

The PR keeps the failure condition as a permanent regression guard — a 500ms JS-thread block at mount that starves any re-render driver (what RiveView init does on a slow runner). This is the concrete reproduction:

  • old setInterval approach + this block → 8/8 fail (renderCount stuck at 2)
  • new deterministic approach + this block → 8/8 pass

So every CI run now verifies the fix against the reproduction, rather than relying on the ~1% natural flake. (Locally I also confirmed the natural flake at ~1%, and that renderCount lands at exactly 3 — zero margin — on every passing run.)

CI changes

This PR is not purely a JS test change — it also touches .github/workflows/ci.yml:

  • Pin the iOS jobs (build-ios, test-harness-ios) to macos-15 (Xcode 26.3, simulator iPhone 16 Pro on iOS >=26.0). macos-latest is mid-migration to macOS 26, whose simulator set has no matching iPhone 16 Pro / iOS >=26 runtime, which breaks the harness boot ("No devices found"). This overlaps with ci(ios): pin iOS jobs to macos-15 to stabilize simulator boot #300, which pins the same runners; if ci(ios): pin iOS jobs to macos-15 to stabilize simulator boot #300 lands first, this part should be rebased away.
  • Add a 300s per-attempt watchdog to the test-harness-ios retry loop. The harness can hang indefinitely if the app launches but never connects to the bridge; without a cap a single stuck attempt eats the whole 15-min step budget and the retry loop never advances. macOS has no timeout, so a background watchdog kills the stuck attempt and nuke_harness reaps the rest before the retry.

@mfazekas mfazekas force-pushed the fix/flaky-use-rive-trigger-renders branch from f092cf5 to 1f39e95 Compare June 29, 2026 10:25
@mfazekas mfazekas requested review from HayesGordon and Copilot June 29, 2026 11:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to de-flake the useRiveTrigger harness regression test from #230 by removing wall-clock–driven re-render scheduling and replacing it with deterministic, test-driven re-renders, while also pinning iOS CI runners to stabilize simulator availability.

Changes:

  • Add an explicit context.rerender() hook to deterministically churn callback identity in the unstable-callback harness test.
  • Keep a mount-time JS-thread blocking reproduction in the test as a permanent regression guard.
  • Pin iOS GitHub Actions jobs (build-ios, test-harness-ios) to macos-15 to avoid simulator roulette on macos-latest.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
example/tests/use-rive-trigger.harness.tsx Replaces interval-based re-rendering with a deterministic context.rerender() driver and retains a mount-time JS-block regression guard.
.github/workflows/ci.yml Pins iOS jobs to macos-15 to avoid intermittent simulator boot failures tied to macos-latest runner image changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread example/__tests__/use-rive-trigger.harness.tsx
Comment thread .github/workflows/ci.yml
@mfazekas mfazekas enabled auto-merge (squash) July 1, 2026 20:00
mfazekas added 2 commits July 1, 2026 22:00
The #230 test drove re-renders with setInterval(50ms)/300ms and asserted
renderCount >= 3 within a 2000ms waitFor. waitFor resolves the instant
renderCount hits 3, so it needs exactly 2 interval ticks — zero margin.
When the JS thread is busy at mount (RiveView + dataBind init) the ticks
are starved and only 1 lands, so renderCount stays at 2 and the test fails
(the intermittent 'expected 2 to be greater than or equal to 3').

Drive the re-renders deterministically via an exposed context.rerender()
instead of racing a wall-clock setInterval, removing the timing dependence.

Keep the failure condition as a permanent regression guard: a 500ms
JS-thread block at mount that starves any re-render driver. The old
setInterval version fails 8/8 under it; the deterministic version passes
8/8 — so every run now verifies the fix against the reproduction.
macos-latest is mid-migration to macOS 26. Jobs randomly land on
macos-15-arm64 or macos-26-arm64, and only the macOS 15 image has a
pre-created iPhone 16 Pro on an iOS >=26 runtime. When a job lands on
macos-26 the simulator-action boot step fails with 'No devices found',
which is why the same commit passes on one run and fails on another.

Pin build-ios and test-harness-ios to macos-15 for deterministic runs.
@mfazekas mfazekas force-pushed the fix/flaky-use-rive-trigger-renders branch from ea6b23b to 2e2b975 Compare July 1, 2026 20:00
@mfazekas mfazekas merged commit c643963 into main Jul 1, 2026
8 of 9 checks passed
@mfazekas mfazekas deleted the fix/flaky-use-rive-trigger-renders branch July 1, 2026 20:12
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.

3 participants