Fix scanner crash on game windows wider than the OCR upscale cap (v0.3.5) - #51
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
upscale_gray/upscale_rgbacapped the Golden Combo band upscale withclamp(width, GC_BAND_MAX_WIDTH), andclamppanics when min exceeds max — which is every crop already wider than the 1000px cap. Their emulator window is 1920px wide, so the band crop is0.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,runningstayed 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
.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.stoppedand clearsrunninghowever it exits, panic included, so the UI can't show a live scanner that no longer polls and refuses to restart.Test plan
golden_combo_band_survives_a_wide_target_windowreproduces 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_shrinksandprepare_gc_band_yellow_leaves_crops_wider_than_the_cap_alonepin the three width regimes (below, at, and over the cap).cargo test --release— 244 passed.npm run lint(3 pre-existing warnings) andnpm run build.