• Bruce Long's avatar
    Windows Spellcheck: Fix for delayed init on clicking editable content · 56df41c3
    Bruce Long authored
    This change fixes an issue with the delayed initialization of the
    spellcheck service (a feature that in Chromium is currently behind the
    WinDelaySpellcheckServiceInit feature flag). While the first click in
    the editable content indeed initializes the spellcheck service by
    loading dictionaries, it does not guarantee a successful spell check
    request. Spelling may not be checked until further typing or focusing
    in a different editable element. If the text is long enough
    (multilined?), then a single click works.
    
    The bug is caused by a race condition in the mojo calls from the
    browser to the renderer process. There is no guarantee that the
    callback to the renderer process when InitializeDictionaries completes
    will be invoked in the renderer process after the call to
    SpellCheck::Initialize that results from the browser method
    SpellcheckService::InitForRenderer. If the first call wins the race,
    no spellchecking will occur because the spellcheck provider thinks
    there are no dictionaries available and does not check spelling.
    
    Mojo does not guarantee ordering in separate message pipes, which
    the SpellChecker and SpellCheckHost interfaces comprise. One fix that
    I considered was to make these associated interfaces that share a
    single channel between the browser and renderer processes. But I
    believe this risks breaking other platforms. So the fix I have
    here instead ensures that when the InitializeDictionaries callback is
    received in the renderer, SpellCheck::Initialize is called with the
    list of dictionaries provided by the browser process.
    
    Test coverage is provided by a browser test based on the original test
    that caught this bug (ChromeSitePerProcessTest.OOPIFSpellCheckTest):
    ChromeSitePerProcessSpellCheckTestDelayInit.OOPIFSpellCheckTest. The
    HTML source for this browser test contains just a snippet of editable
    content, so putting focus in it to invoke spellchecking and initialize
    the spellcheck service on demand exposed the issue.
    
    Bug: 1103847
    Change-Id: I809e4aef3d51808d222012ddd0c0b46e3d57098a
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2335028Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
    Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
    Reviewed-by: default avatarGuillaume Jenkins <gujen@google.com>
    Commit-Queue: Bruce Long <brlong@microsoft.com>
    Cr-Commit-Position: refs/heads/master@{#796789}
    56df41c3
spellcheck_per_process_browsertest.cc 14.5 KB