Skip to content

Fix scanner crash on game windows wider than the OCR upscale cap (v0.3.5) - #51

Merged
sbrants merged 1 commit into
mainfrom
fix/gc-band-upscale-panic
Aug 10, 2026
Merged

Fix scanner crash on game windows wider than the OCR upscale cap (v0.3.5)#51
sbrants merged 1 commit into
mainfrom
fix/gc-band-upscale-panic

Conversation

@sbrants

@sbrants sbrants commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

The tester's v0.3.4 debug package answered the "scanning stops a few seconds into a run" report outright, thanks to the panic logging added in that release:

PANIC in thread wavetrace-scanner at src\ocr.rs:414: min > max. min = 1728, max = 1000

upscale_gray/upscale_rgba capped the Golden Combo band upscale with clamp(width, GC_BAND_MAX_WIDTH), and clamp panics when min exceeds max — which is every crop already wider than the 1000px cap. Their emulator window is 1920px wide, so the band crop is 0.90 * 1920 = 1728px and the call panicked the moment the toast corridor held a plausible amount of yellow ink (800–7000 px, i.e. between the "empty" and "FX soup" gates). That killed the scanner thread mid-run: polling stopped, running stayed set so the UI kept reporting "scanning" over the last values it had read, and pressing New run bought another few seconds. It reproduces on any target window wider than ~1100px, which is why it never showed up on my narrower test window.

The same panic reached the main thread once through the Settings OCR probe, where unwinding into the Tauri event loop aborted the process (the app disappeared and restarted).

Changes

  • Fix the crash: cap the upscale with .min(cap).max(width), so a band wider than the cap is OCR'd at its own size instead of panicking. This was always the intent — the existing early return right below it skips resizing in exactly that case.
  • A crashing frame no longer stops the run: frame processing is wrapped so a panic is logged and that frame skipped, rather than unwinding the poll loop.
  • A dead scanner stops lying: the thread now publishes stopped and clears running however it exits, panic included, so the UI can't show a live scanner that no longer polls and refuses to restart.
  • The Settings probe can't abort the app: a panic there is returned as a failed probe.

Test plan

  • golden_combo_band_survives_a_wide_target_window reproduces the field panic exactly on the old code (min > max. min = 1728, max = 1000) and passes with the fix.
  • upscale_rgba_caps_growth_and_never_shrinks and prepare_gc_band_yellow_leaves_crops_wider_than_the_cap_alone pin the three width regimes (below, at, and over the cap).
  • cargo test --release — 244 passed.
  • npm run lint (3 pre-existing warnings) and npm run build.
  • Tester confirms a run keeps collecting past the first few seconds on their 1920px-wide window.

Capping the Golden Combo band upscale used clamp(width, cap), which panics when
the crop is already wider than the cap - every target window wider than ~1100px
(a 1920px-wide emulator gives a 1728px band). The panic killed the scanner
thread as soon as the toast corridor held a plausible amount of yellow, so
polling stopped a few seconds into a run while the UI kept reporting "scanning"
over the last values it read, and New run bought another few seconds.

A panicking frame is now skipped instead of unwinding the poll loop, a scanner
thread that does end reports itself as stopped rather than looking live, and the
Settings OCR probe no longer aborts the app by unwinding into the Tauri event
loop.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sbrants
sbrants merged commit d17b87c into main Aug 10, 2026
8 checks passed
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