Skip to content

fix(core): range-tolerant calibration-flash detection (#46) - #47

Merged
jbrecht merged 1 commit into
mainfrom
fix/46-flash-detection
Jun 15, 2026
Merged

jbrecht merged 1 commit into
mainfrom
fix/46-flash-detection

Conversation

@jbrecht

@jbrecht jbrecht commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Closes #46.

Root cause

Flash detection thresholded chroma at uavg > 180 && vavg > 170, tuned to a full-range magenta frame (≈201/221). The same frame decoded as limited range (16–235) — which CI's webm pipeline and some ffmpeg builds do — scales toward center to ≈177/195, straddling the old cutoff. So detection intermittently missed the flash and fell back to clock-zero (degrading audio sync), and the e2e videoClockOffsetMs > 0 assertion flaked (failed once on the 0.11.0 release PR, passed on re-run).

Fix

Lower both thresholds to a single FLASH_CHROMA_MIN = 150:

  • Still far above neutral (128) and above any single-channel UI colour — magenta is the only thing that lifts both U and V at once, so requiring both stays magenta-specific.
  • Wide margin now absorbs limited-range / compression drift.

Internal-only; no API change.

Tests

  • New parseFlashFromMetadata cases: a limited-range/dimmed magenta frame (177/195) is now detected; a single elevated channel (saturated blue or red UI) is still rejected.
  • e2e note added; local run green with the flash reliably detected (offset 200ms).
  • pnpm -r typecheck clean; 158 unit tests pass; e2e exit 0.

🤖 Generated with Claude Code

Flash detection thresholded chroma at uavg>180 && vavg>170, tuned to a
full-range magenta frame (~201/221). The same frame decoded as limited
range (16-235) — common in CI and some ffmpeg builds — scales toward
center (~177/195) and straddled the cutoff, so detection intermittently
missed and fell back to clock-zero (degrading audio sync). This also made
the e2e flash assertion flaky.

Lower both thresholds to a single FLASH_CHROMA_MIN=150: still far above
neutral (128) and above any single-channel UI colour (magenta needs BOTH
channels elevated), but with wide margin for range/compression drift.
Add regression tests for a limited-range magenta frame and for
magenta-specificity (a single elevated channel is not a flash).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jbrecht
jbrecht merged commit c415009 into main Jun 15, 2026
1 check passed
@jbrecht
jbrecht deleted the fix/46-flash-detection branch June 15, 2026 02:24
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.

Flaky e2e: calibration flash detection intermittently fails in CI

1 participant