Skip to content

fix(common/models): lm-worker context resets didn't properly manage context cache 🐵#10185

Merged
jahorton merged 3 commits intofeature-gesturesfrom
fix/common/models/worker-reset-context
Dec 8, 2023
Merged

fix(common/models): lm-worker context resets didn't properly manage context cache 🐵#10185
jahorton merged 3 commits intofeature-gesturesfrom
fix/common/models/worker-reset-context

Conversation

@jahorton
Copy link
Copy Markdown
Contributor

@jahorton jahorton commented Dec 8, 2023

Fixes #10136.

The first commit, in particular, is the actual fix. Examining the changeset of #9855, I had made no changes whatsoever to model-compositor.ts's resetContext method... despite now tagging all context states with their context when built - a clear oversight. It did not tag the context on a context reset, which is what gave rise to the null cases for the Sentry events.

While fixing this, I noticed that the ContextManager isn't actually reset on a resetContext call. I decided to fix that while I was at it, which results in better centralization of the related code. That sort of state management was otherwise encapsulated within ContextTracker, and this change removes that "otherwise" caveat.

@keymanapp-test-bot skip

@jahorton jahorton requested a review from mcdurdin as a code owner December 8, 2023 02:32
@keymanapp-test-bot keymanapp-test-bot bot changed the title fix(common/models): lm-worker context resets didn't properly manage context cache fix(common/models): lm-worker context resets didn't properly manage context cache 🐵 Dec 8, 2023
@keymanapp-test-bot keymanapp-test-bot bot added this to the A17S27 milestone Dec 8, 2023
const priorMatchState = this.item(i);
if(transformDistribution && transformDistribution.length > 0) {
const priorTaggedContext = priorMatchState.taggedContext;
if(priorTaggedContext && transformDistribution && transformDistribution.length > 0) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need the null-guard now, but... just in case. Don't want a mistake causing spurious keyboard errors in the mobile apps.

Comment on lines -744 to -746
let tokenizedContext = models.tokenize(this.lexicalModel.wordbreaker || wordBreakers.default, context);
let contextState = correction.ContextTracker.modelContextState(tokenizedContext.left, null, this.lexicalModel);
this.contextTracker.enqueue(contextState);
Copy link
Copy Markdown
Contributor Author

@jahorton jahorton Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original form here served to "force" the context tracking to not consider any previous cached entries... but did nothing to clear them. There's no longer a need to "force" it if we've actually cleared the cache, as they're no longer available in that case.

@jahorton jahorton linked an issue Dec 8, 2023 that may be closed by this pull request
@mcdurdin mcdurdin modified the milestones: A17S27, A17S28 Dec 8, 2023
@jahorton jahorton merged commit cfedbc7 into feature-gestures Dec 8, 2023
@jahorton jahorton deleted the fix/common/models/worker-reset-context branch December 8, 2023 08:36
@jahorton jahorton mentioned this pull request Dec 12, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(common/models): cannot apply transform to null context 🐵

2 participants