Repository navigation
Conversation
RewindOCRService pinned recognitionLanguages to ["en-US"], and Vision treats that list as the whole recognition scope, so non-Latin screen text was not recognised at all and Rewind search was silently non-functional for those users. Resolve the list once from Locale.preferredLanguages, filtered to what Vision reports as supported and always retaining an English fallback for mixed screen text. It still resolves into a single process-lifetime static let, so the bridged-NSArray lifetime fix from BasedHardware#5891/BasedHardware#5151 is preserved. Fixes BasedHardware#12797
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Two review findings on the locale resolver: - When the capability list was non-empty but shared nothing with the user, the resolver returned a literal en-US that Vision may not support, and an unsupported tag makes perform throw -- the total OCR loss the filtering was meant to avoid. That branch now picks from Vision's own reported list; en-US stays reserved for the empty-capability case, where there is no list. - Matching collapsed a tag to its primary language, so zh-TW could be handed the zh-Hans scope and read Traditional text with the Simplified model. Matching now compares language and script from the maximised identifier, which keeps zh-TW on zh-Hant while still letting ja reach ja-JP.
|
Verified against the diff and the surrounding code — this is a clean, well-scoped fix for #12797. Notes per file:
One follow-up worth tracking separately (not a reason to expand this PR): #12797 also lists three sibling pinned constants still on main — No CI runs against this target, so the one thing static review can't cover is runtime behavior on a non-Latin-locale machine — the issue's repro document would be a quick pre-merge spot-check for whoever merges. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks for the careful read — and agreed on keeping the three sibling constants out of this PR. On the runtime gap you flagged: that is the right limitation to name. I do not have a macOS host or an Xcode toolchain in this environment, so I have not run the Swift suite or reproduced the Japanese sample on a device, and I said so in the description rather than implying otherwise. The eight tests are deliberately pure so the ordering, script-matching and fallback rules can be checked without Vision — but they cannot tell you what a non-Latin-locale machine actually recognises. The issue's repro document is the right pre-merge spot-check. One thing worth having explicitly, since it is the part a reviewer would most reasonably worry about: the change cannot regress an existing Post-merge validation addendum — 2026-09-14 (MICA-IO) Additional reduced-target validation was run against the exact merged PR head Preserved replay package identity: The original runtime caveat still stands: this executed a connector-transcribed excerpt of the three pure language-selection methods, not a full-file/blob-verified application checkout. Upstream XCTest, native macOS OCR/Vision execution, the static capability query, and array-lifetime behavior were not exercised here. The native non-Latin-locale OCR spot-check therefore remains outstanding. This is supplementary evidence, not device-level validation or a new bounty/payment claim. |
kodjima33
left a comment
There was a problem hiding this comment.
Desktop bug fix (owner-override): root cause is clear (RewindOCRService pinned recognitionLanguages to en-US only, so non-Latin scripts like Japanese get zero OCR recognition), scoped diff, 5 new regression tests against the pure resolver, confirmed still broken on main. No abuse signals.
Fixes #12797
What
On macOS, Rewind's screen OCR recognises no Japanese text at all. Latin characters on the same frame come back fine, so this is not degraded recognition — the script is out of scope, and Rewind's search is silently non-functional for anyone working in a non-Latin script.
Why it happens
RewindOCRServicepins the recognition language list to a compile-time constant:VNRecognizeTextRequesttreats that list as the entire recognition scope. A language absent from it is not recognised poorly; it is not recognised at all. There is no setting that changes this.That constant is not arbitrary, though — the comment above it records why it must stay a process-lifetime constant: Vision's TextRecognition enumerates the bridged
NSArrayasynchronously, and an array literal whose storage is tied to the call frame can be freed mid-enumeration, tripping_assertionFailure(#5891, #5151). Any fix has to widen the scope without reintroducing a per-call array.The change
recognitionLanguagesis now resolved once, from the user's own locale, into the same pinnedstatic let:performthrows on an unsupported language, which would fail the whole request — turning a partial-recognition bug into total OCR loss.jaselects Vision'sja-JP.The crash-safety property is preserved: this still resolves to exactly one array held for the process lifetime.
Scope is deliberately limited to the recognition language list. I have not touched capture cadence, recognition level, or
usesLanguageCorrection.Verification
RewindOCRQualityTestsgains five cases against the pure resolver, so the ordering and filtering rules are testable without invoking Vision or changing the host's locale:testRecognitionLanguagesFollowThePreferredLocaleInsteadOfAPinnedOneja-JPpreferred →["ja-JP", "en-US"]— fails onmain, which yields["en-US"]testRegionlessPreferredLanguageSelectsASupportedRegionalVariantja→ja-JPtestUnsupportedPreferredLanguagesAreDroppedRatherThanPassedToVisionxx-YYnever reaches VisiontestEnglishIsNotDuplicatedWhenItIsAlreadyPreferredtestAnUnavailableSupportedListStillYieldsAUsableLanguage["en-US"]The first case is the regression test: on
mainthe resolver does not exist and the constant is["en-US"], so a Japanese-preferring host cannot produceja-JP.I do not have a macOS host or an Xcode toolchain in this environment, so I have not run the Swift suite myself and am not claiming a device-level repro of the Japanese sample. The change was derived from the source and the issue's measurements. Please let the Desktop Swift checks run; I will fix anything they surface.
Failure-Class: new
FC-recognition-scope-pinned-below-user-locale, added in.github/failure-classes/in this change.Root cause. The constant was introduced to solve a lifetime problem — keep one array alive for the process — and the language policy was silently absorbed into that fix as a literal. Once a scope value lives inside a constant justified on other grounds, nothing points at it when the user's locale differs from it. The failure is quiet by construction: OCR returns text, the row is written, search runs, and every layer above reports success over content it never saw.
Durable guard. The canonical prevention artifact is
RewindOCRQualityTests.swift, which asserts the resolver's behaviour rather than a fixed language list. A future change to the language set stays correct as long as it derives from the user's locale, and any reintroduction of a pinned scope fails the first case.The distinction from the two neighbouring locale classes:
FC-repository-text-io-inherits-host-localeandFC-subprocess-output-inherits-host-localeare both about inheriting an ambient locale where an explicit one was required. This is the inverse — an explicit constant pinned below the user's locale.Invariants
None named. No locked invariant globs
Sources/Rewind/Core/RewindOCRService.swift; the Rewind paths that are covered areRewindDatabase/RewindIndexer/RewindStorage(INV-AUTH),TaskChatMessageStorage(INV-CHAT-1),MemoryStorage/MemoryModels(memory tiers) andActionItemStorage(INV-TASK-1).