Skip to content

fix: unify flash analysis, add spatial detection, and handle canvas context loss#3

Merged
OMARVII merged 1 commit intomainfrom
fix/p0-correctness-fixes
Apr 11, 2026
Merged

fix: unify flash analysis, add spatial detection, and handle canvas context loss#3
OMARVII merged 1 commit intomainfrom
fix/p0-correctness-fixes

Conversation

@OMARVII
Copy link
Copy Markdown
Owner

@OMARVII OMARVII commented Apr 11, 2026

Summary

  • Unified flash analysis: Extract shared analyzeFlashWindow() helper used by both FlashDetector and CSSFlashDetector, eliminating divergent inline counting logic. CSSFlashDetector now detects red flashes and classifies severity correctly (previously hardcoded isRedFlash: false).
  • Spatial region-based detection: Add 4×4 grid of 8×8 pixel regions to analyzeFrame(). analyzeFlashWindow() checks each region independently on the slow path, catching localized flashes that average below the 0.1 threshold across the full frame — improving WCAG 2.3.1 spatial compliance.
  • Canvas context loss handling: FlashDetector now listens for contextlost/contextrestored events. _sampleFrame() returns null when GPU context is reclaimed, preventing silent analysis failure. Resumes automatically on restoration.

Test plan

  • All 70 existing tests pass (zero regressions)
  • 14 new tests added (84 total, 0 failures)
  • npm run validate clean (lint + tests)
  • Localized flash in 1/16th of frame now triggers detection (previously missed)
  • CSSFlashDetector red flash → severity "danger" path verified
  • Canvas context loss returns null from _sampleFrame

🤖 Generated with Claude Code

…ontext loss

- Extract shared analyzeFlashWindow() helper used by both FlashDetector
  and CSSFlashDetector, eliminating divergent inline counting logic
- CSSFlashDetector now detects red flashes and classifies severity correctly
  via shared analysis path (previously hardcoded isRedFlash: false)
- Add 4×4 region-based spatial analysis (8×8 pixel blocks) to catch
  localized flashes that average below threshold across the full frame,
  improving WCAG 2.3.1 spatial compliance
- Handle canvas context loss gracefully — detector returns null from
  _sampleFrame when GPU context is reclaimed, resumes on restoration
- Add 14 new tests covering all three fixes (84 total, 0 failures)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@OMARVII OMARVII merged commit 3f903df into main Apr 11, 2026
2 checks passed
@OMARVII OMARVII deleted the fix/p0-correctness-fixes branch April 11, 2026 08:15
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