twilco

#56015: fix: crash when a spellcheck provider answers a superseded request

Merged
Created: Nov 23, 2026, 10:40:23 AM
Merged: Nov 23, 2026, 9:41:12 PM
6 comments
Target: main

Description of Change

Since Electron 41, using webFrame.setSpellCheckProvider can crash the renderer in editors that change the selection or contents from script, such as CKEditor.

Cause

Chromium 146 (CL 7452579) made Blink's spellcheck user-action restrictions always on. When the selection or contents change without a user gesture, Blink now cancels the in-flight spellcheck request and later sends a new one. SpellCheckClient isn't told about the cancellation, and it assumed only one request at a time.

  1. Request B replaces request A while the provider still holds A's callback.
  2. A's callback finishes B using A's results, then clears B.
  3. B's callback dereferences null, and the renderer crashes.
Fix

Each request gets an ID, which is bound to both the posted SpellCheckText task and the JS callback. Callbacks and tasks for requests that were replaced or already finished are now ignored. This also covers a provider calling the same callback twice. Chrome's own SpellCheckProvider uses the same approach, keying completions by ID (add) and dropping unknown ones (lookup).

Test

A new crash case, spellcheck-provider-superseded-request, holds the provider's callbacks, types until Blink sends a second request, then calls both callbacks. It's a crash case rather than a webFrame spec because spec/index.js enables UnrestrictSpellingAndGrammarForTesting, which turns off the restriction that triggers this. Without the fix it fails with exit code 1 (renderer gone). With the fix it passes, as do the existing api-web-frame and spellchecker specs.

Manual verification

I ran the reporter's CKEditor repro side by side on unfixed main (left) and on main plus this fix (right). It's not made totally clear in the video, but the before-side crashes and is totally unresponsive to clicks and any other input.

before-after-spellcheck-crash-fix.mp4

Checklist

This PR fixes #55399.

Assisted-By: Claude Opus 5.5, Claude Code

Release Notes

Notes: Fixed a renderer crash when using webFrame.setSpellCheckProvider in editors that change the selection or contents from script.

Backports

44-x-y
In-flight
PR Number
#56030
Waiting to be merged
45-x-y
In-flight
PR Number
#56031
Waiting to be merged
46-x-y
In-flight
PR Number
#56029
Waiting to be merged

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron