New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 617404 link

Starred by 7 users

Issue metadata

Status: Fixed
Owner:
Closed: Jul 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 2
Type: Bug



Sign in to add a comment

Spell checker causes laggy typing

Project Member Reported by keishi@chromium.org, Jun 4 2016

Issue description

tldr I found another gmail laggy typing bug. I think the spell checker is causing slow layout.

Reproduction steps:

1. Open gmail
2. Open 4 compose windows each with lots of content (in my case a copy&paste of theverge.com). *Use Ctrl+Shit+v to copy the data, not Ctrl+v*.
3. Focus on each compose window body areas.
4. Open new compose window
5. Long press one letter key. (like s and type in ssssssss...)
6. Letters should be displayed one letter at a time. But display will lag behind. Starts with a small lag but quickly increases to few second lag.

Reproduced on Linux ToT(after r397626), Mac r371207 non oilpan
Didn't reproduce on Mac Firefox

Here is a video of me turing spell checker on/off and trying the repro procedure.
When the spell checker is off I cannot reproduce the laggy typing.
https://drive.google.com/file/d/0B4aiM9jljUy8MkdJdkVzY2pXSzA/view?usp=sharing
I start with spell checker on, reproduce the bug starting from step 3.
Then I turn off the spell checker, and show that typing is not laggy.
I repeat this one more time to make sure.

This is a trace of laggy typing.
https://drive.google.com/file/d/0BwRi59l_ri74aTRpRFp1NUJMV0E/view?usp=sharing
This is a trace of non-laggy typing, right after gmail reload.
https://drive.google.com/file/d/0BwRi59l_ri74ZmJKcTB6WkVxdms/view?usp=sharing

This screenshot shows the relevant part of these traces.
https://drive.google.com/file/d/0BwRi59l_ri74WXZXOUZFV3d5N3M/view?usp=sharing

Usually handling a input event is fast, but when the typing is laggy layout is taking 30ms(30x usual). This is causing the main thread to be filled up with input event handling and the display falls behind.

I ran a bisect on Mac but I'm not confident in the result.
My bisect indicates that this bug appeared between 44.0.2394.0 (good) and 44.0.2395.0 (bad).
https://chromium.googlesource.com/chromium/src/+log/44.0.2394.0..44.0.2395.0?pretty=full
M44 is one year ago so it could be a recent gmail change exposed a bug in M44.
But since I can't find any suspicious changes in that range, I will rerun a bisect on linux.
 
BTW I checked the size of m_range and it is always less than 100.
RenderWidgetInputHandler::OnHandleInputEvent is taking ~30ms.
Layout occurs twice inside the input event handler (because JS is using offsetWidth).
Each FrameView::layout takes ~15ms.
Inside 13ms inside layout is consumed by Document::layoutUpdated which calls DocumentMarkerController::updateRenderedRectsForMarkers.
DocumentMarkerController::updateRenderedRectsForMarkers calculates the bounding box for all the Ranges generated for each marker that the spell checker generated.
The # of markers is ~1500 in my case.
Calculating the bounding box for a Ranges is done in Range::textRects and it looks pretty heavy (lookup layout info for all nodes in range).

I'll investigate why the spell checker generates so many markers.
Summary: Spell checker causes laggy typing (was: Gmail laggy typing)
Looks like the # of markers and the time consumed by Range::textRects is not out of the ordinary.

(# of markers: 1500) * (Range::textRects: 0.01ms) = 15ms

I was able to reproduce the typing lagginess in a <textarea> with many spelling errors.
I created a proposed fix CL.
https://codereview.chromium.org/2034363002/
I was also able to make DocumentMarkerController::shiftMarkers() problematic.

Repro steps:
1. Open data:text/html,<textarea rows="50" cols="200"></textarea>
2. Copy and paste the text at this url into the textarea
https://gist.githubusercontent.com/keishi/d0012d6f0d547bf7c3648b20186cc2f4/raw/a7184bf9bfa1ced666095571b9e303f257759400/gistfile1.txt
3. Focus the textarea and scroll to end to run spell checker for entire text.
4. Move cursor to the beginning and long press letter key. (e.g. type something like "sssss...")
5. Typing will be laggy

This is because the Document::didInsertText calls shiftMarkers() which updates the marker render rects for all markers after the insertion point.

Update https://codereview.chromium.org/2034363002/ with a fix for this too.

Comment 10 by kotah@chromium.org, Jun 24 2016

Cc: kotah@chromium.org
Labels: Hotlist-Enterprise
Labels: -Hotlist-Enterprise Hotlist-enterprise
This is also true for textareas on wikis please fix this im using a dev build chromium and i need to disable the spellchecker in order to be able to work on larger articles within wikipedia.

Chromium	54.0.2798.0 (Entwickler-Build) (64-Bit)
Überarbeitung	c62f109fe5d7681051f4b8144a16ffc86b692bdc-refs/heads/master@{#405858}

Comment 12 by phistuck@gmail.com, Jul 23 2016

 Issue 237433  - related?

Comment 13 by yosin@chromium.org, Jul 25 2016

Status: Fixed (was: Started)

Sign in to add a comment