New issue
Advanced search Search tips

Issue 705180 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Blocking:
issue 698661
issue 389390
issue 517298
issue 586768



Sign in to add a comment

SpellChecker::updateMarkersForWordsAffectedByEditing is slow

Project Member Reported by xiaoche...@chromium.org, Mar 25 2017

Issue description

This function is called both at the beginning and the ending of an editing operation (e.g., typing a character), with super complicated logic.

We should make it simple and fast.
 
Repro steps:

1. Open https://en.wikipedia.org/w/index.php?title=Timeline_of_United_States_history&action=edit
2. Move caret in the middle of any word near the end of the textarea
3. Hold key A

Observe that SpellChecker::updateMarkersForWordsAffectedByEditing takes about half of the total running time of WebViewImpl::handleInputEvent


Screenshot from 2017-03-24 18:20:08.png
162 KB View Download
trace_slow_update_markers.json.gz
1.7 MB Download
Blocking: 586768 389390
Labels: Performance
Note that this issue is orthogonal to idle time spell checker.

Comment 3 by yosin@chromium.org, Mar 25 2017

Blocking: 517298
The issue[1] also implies making Editor independent from spell checker. We should
have idle time spelling marker remover along with idle time spell checker.

Since idle time spell checker tracks contents modification and it should remove marker on requeted
paragraph, we may want to removing marker into it.

[1]  http://crbug.com/517298  Spell checker should work in idle time rather than every text change
I summarized the removal of stale spellcheck markers here:

https://docs.google.com/document/d/1RVnBQxwIe_Tfx0bVHrM0bdUeRSJiG2OGuPgsKIO2gOI/edit?usp=sharing

Given that:
1. Successful SpellCheckRequest clears all markers in its checking range, and
2. The checking range of a SpellCheckRequest is always aligned to sentence boundaries
There is not much need to remove any stale marker if a SpellCheckRequest is issued. There are some corner cases but I don't think they are important.

Hence, this issue can be solved in the framework of idle time spell checker:

1. In hot mode checking, for each root editable that was just edited:
- If we decide to check the root editable, no need to clear any stale marker
- If we decide not to check the root editable because we are typing in the middle of a word, call SpellChecker::updateMarkersForWordsAffectedByEditing to clear marker under the current word
- If we decide not to check the root editable for any other reason, still no need to clear any stale marker

2. Baseline correctness: any stale marker not cleared in hot mode will be cleared in cold mode
In review: https://codereview.chromium.org/2785103005

Attachments are trace taken after patch. Latency due to spell checking code is almost negligible (75ms out of 2.5s), and the average latency per character input is reduced by half.
trace_marker_update_after_patch.json.gz
2.3 MB Download
Screenshot from 2017-03-30 17:14:43.png
203 KB View Download
Project Member

Comment 6 by bugdroid1@chromium.org, Apr 5 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/fd7ce52f21f9dd6c741ee0545cc109ed6267b95e

commit fd7ce52f21f9dd6c741ee0545cc109ed6267b95e
Author: xiaochengh <xiaochengh@chromium.org>
Date: Wed Apr 05 03:34:11 2017

Remove stale spellcheck markers at idle time

Blink's spellchecker used to remove stale/invalid markers
synchronously, which is time-costly. This patch greatly
simplifies the removal logic by integrate it with idle
time spell checker.

Detailed design and analysis: https://goo.gl/P7F710

BUG= 705180 
TEST=Existing layout tests under editing/spelling/

Review-Url: https://codereview.chromium.org/2785103005
Cr-Commit-Position: refs/heads/master@{#461968}

[modify] https://crrev.com/fd7ce52f21f9dd6c741ee0545cc109ed6267b95e/third_party/WebKit/Source/core/editing/spellcheck/HotModeSpellCheckRequester.cpp
[modify] https://crrev.com/fd7ce52f21f9dd6c741ee0545cc109ed6267b95e/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp

Status: Fixed (was: Assigned)
After r461968, stale spellcheck marker removal is no longer an issue as long as idle time spell checking is enabled. Hence marking the issue as fixed.

Sign in to add a comment