Repository navigation
fix(spell-check): stop service views crashing while typing - #723
Merged
Merged
Conversation
Since Electron 44 (Chromium 152), Blink cancels an in-flight spell check when a script moves the caret in a field the user didn't focus, as Slack and Telegram composers do. The late answer to the cancelled request completes the newer one in Electron's SpellCheckClient, whose own answer then dereferences a null pending request and segfaults the renderer, leaving a blank service view. Answer only the most recent request, and only once the renderer is idle, so a request Electron has accepted but not yet handed over always supersedes a stale answer before it is delivered. Signed-off-by: Marc Nuri <marc@marcnuri.com>
A timed-out idle callback runs as a regular task, which could beat Electron's hand-over of a newer spell check request and reopen the renderer crash. State the requirement next to the delivery and fail a test if a timeout is ever passed. Signed-off-by: Marc Nuri <marc@marcnuri.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.



Problem
Since v0.0.123, typing in a service (a Slack or Telegram DM, for example) eventually kills the service view and leaves a blank screen. It only happens with the non-native spell checker (the nodehun dictionaries).
The renderer segfaults with
EXC_BAD_ACCESSat0x18on its main thread, from a resolved promise calling back into Electron.Root cause
SpellCheckClienttracks a single pending request.OnSpellCheckDonedereferences it without a null check:pending_request_param_->wordlist(), which sits at offset0x18.IdleSpellCheckController. A selection change in an element that wasn't focused by a user gesture, or a content change without transient user activation, now callsDeactivate(). That cancels Blink's in-flight check. Slack and Telegram focus their composers by script.Fix
preload.spell-check.jsnow only answers the most recentspellCheckrequest, exactly once, and delivers the answer from arequestIdleCallback.The idle hop covers the case where Blink has issued a request that hasn't reached the preload yet. Electron hands requests over from a normal-priority task it posts, and that task always runs before an idle callback, so the stale answer finds itself superseded.
A dictionary failure still answers with nothing misspelled, so Blink never stalls on an unanswered request.
Testing
preload.spell-check.test.jsnow covers a request superseded while its dictionary lookup is in flight, and one superseded while its answer waits for the renderer to be idle. Removing only the superseded-request guard makes exactly those two tests fail.npm run pretestandnpm testpass (60 suites, 1181 tests).contenteditablereproduces the crash deterministically:UnrestrictSpellingAndGrammarForTestingEnabling the native spell checker is a workaround until this ships.