Re: Issue 109587 in chromium: Pasting lots of text to a textarea is slow

249 views
Skip to first unread message

chro...@googlecode.com

unread,
May 2, 2013, 1:18:42 AM5/2/13
to chromi...@chromium.org
Updates:
Summary: Pasting lots of text to a textarea is slow

Comment #22 on issue 109587 by nba...@chromium.org: Pasting lots of text to
a textarea is slow
http://code.google.com/p/chromium/issues/detail?id=109587

Narrowing scope of bug.

Split off editing issue to:
Issue 237433: Editing textarea with lots of text is slow
Deleting (and selecting) is already covered at:
Issue 163131: Clearing a textarea which contains a large amount of text is
extremely slow
Restricting this bug to "Pasting is slow".

Pasting is measurably slower than Firefox (by 3x), but should be expected
to be the slowest operation, since it is inevitably O(n) (for full loading)
-- navigation, editing, selecting, and pasting should all be O(1), or at
least close to instant.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

chro...@googlecode.com

unread,
May 2, 2013, 5:54:27 AM5/2/13
to chromi...@chromium.org

Comment #23 on issue 109587 by kenji...@chromium.org: Pasting lots of
User expectations for pasting are lower than editing so Issue 237433 (in
particular) and Issue 163131 should be prioritized over this one.

How long does it take to paste a reasonably long block of text (e.g. one of
the longest wikipedia articles for instance)?

chro...@googlecode.com

unread,
May 2, 2013, 10:05:03 AM5/2/13
to chromi...@chromium.org

Comment #24 on issue 109587 by pholm...@gmail.com: Pasting lots of text to
My app allows the pasting of spreadsheet data, copy/paste is much nicer
than a file upload because it doesn't involve the server. Spreadsheet data
can be many MBs...

chro...@googlecode.com

unread,
May 2, 2013, 10:14:03 AM5/2/13
to chromi...@chromium.org

Comment #25 on issue 109587 by kenji...@chromium.org: Pasting lots of
We'll get to this particular issue but the other issues mentioned above are
more painful.

chro...@googlecode.com

unread,
May 2, 2013, 10:23:03 AM5/2/13
to chromi...@chromium.org

Comment #26 on issue 109587 by nba...@chromium.org: Pasting lots of text to
If you want file data, how about using the File API in HTML5?
http://www.html5rocks.com/en/tutorials/file/dndfiles/
This is cross-browser, it's currently supported in Chrome, and it avoids
using a text area.

That is, your use case sounds like it's better served by a different
programming approach, not by using textarea as a form of file upload.

File size can be arbitrarily large -- I can imagine wanting 100 MB+ data
files, or even multi-GBs of data, and we shouldn't be optimizing textarea
for that!

We do plan to improve this, but for the size data you're working with, the
File API is a much better fit, and maybe a better UI for your users too!

chro...@googlecode.com

unread,
May 2, 2013, 10:40:03 AM5/2/13
to chromi...@chromium.org

Comment #27 on issue 109587 by pholm...@gmail.com: Pasting lots of text to
Sorry I probably should have explained more...

There is one other important reason why copy/paste works so well for me.
Copy/pasting from any format of spreadsheet, or tables on web pages, or
long lists of data... the data automatically gets put into a friendly
tab-delimited format. So I don't need to worry about XLS files, or CSV, or
Numbers docs, or OpenOffice docs, etc..

Many people also find copy/paste is a easier operation than opening up the
file browser.

Anyway it is an edge case use I am sure, but I am sure copy/pasting is an
important operation in other apps.

Thanks for your time and consideration on this issue.

chro...@googlecode.com

unread,
May 6, 2013, 10:42:15 PM5/6/13
to chromi...@chromium.org

Comment #28 on issue 109587 by nba...@chromium.org: Pasting lots of text to
Thanks for the details Phil!

If you want to input data via pasting, rather that using a textarea, you
can directly bind to the paste event. That is, you shouldn't have to go via
a textarea if you don't actually need the text to be in a textarea (which
you don't).
Assuming this works, it should be much faster and cleaner.

(Details mentioned here as pasting large data via a textarea is an
intuitive approach, if suboptimal.)

That is:
* on the EventTarget (an element, the document itself, etc.),
* addEventListener to the 'paste' event,
* get the data via clipboardData.getData('text/plain'), and
* parse the data directly.

I think you also need to:
* preventDefault to stop the usual paste from happening.

In code:
target.addEventListener('paste', function(event) {
// cancel paste
event.preventDefault();

// get text representation of clipboard
var text = event.clipboardData.getData('text/plain');

// parse text yourself
// YOUR CODE HERE
});
Above code from:
http://stackoverflow.com/questions/12027137/javascript-trick-for-paste-as-plain-text-in-execcommand

Hope this helps!

chro...@googlecode.com

unread,
May 23, 2013, 9:44:24 AM5/23/13
to chromi...@chromium.org

Comment #29 on issue 109587 by david.uv...@gmail.com: Pasting lots of text
Adding attributes 'spellcheck="false"' and 'autocomplete="off"' to the
textarea seems to speed thing up considerably. It may not be fast but it is
usable.

chro...@googlecode.com

unread,
May 23, 2013, 11:05:28 PM5/23/13
to chromi...@chromium.org

Comment #30 on issue 109587 by nba...@chromium.org: Pasting lots of text to
Thanks David, that's very useful!

chro...@googlecode.com

unread,
May 24, 2013, 12:36:55 AM5/24/13
to chromi...@chromium.org
Updates:
Labels: Cr-UI-Browser-Autofill Cr-UI-Browser-Spellcheck

Comment #31 on issue 109587 by asvi...@chromium.org: Pasting lots of text
adding autofill/spellcheck labels per comment 29

chro...@googlecode.com

unread,
May 24, 2013, 9:34:22 PM5/24/13
to chromi...@chromium.org

Comment #32 on issue 109587 by gr...@chromium.org: Pasting lots of text to
FWIW, I can not verify comment 29. Having 4 text areas with
autofill/spellcheck combos, all take ~7 seconds to paste the text from
repro.html into them. Selecting is about a second, deleting is
instantaneously.

This is for 29.0.1516.0 canary, OSX 10.6.8. I see the same timing on
Ubuntu/ToT.

David, what version are you using?

chro...@googlecode.com

unread,
May 27, 2013, 6:45:12 AM5/27/13
to chromi...@chromium.org

Comment #33 on issue 109587 by david.uv...@gmail.com: Pasting lots of text
I'm using version 27.0.1453.94 on Windows 7 Ultimate (SP1).

User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/27.0.1453.94 Safari/537.36

I have tested with two versions of repro.html, one modified as in comment
#29 and the other one original. Both will render the copied text equally
fast. After the text has been rendered the caret will start blinking and
the textarea will become responsive in the modified version, but the
original version will hang until the process crash.

Could also verify comment #32 using Mozilla/5.0 (Macintosh; Intel Mac OS X
10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93
Safari/537.36.

chro...@googlecode.com

unread,
May 28, 2013, 3:14:16 PM5/28/13
to chromi...@chromium.org

Comment #34 on issue 109587 by gr...@chromium.org: Pasting lots of text to
Ah. Crash is good :) Sorry it crashes for you, but it might help find this
bug quicker.

Do you happen to have a crash ID? chrome://crashes/ lists past crash IDs if
you have crash reporting turned on. If you don't have it on, would you mind
turning it on and recreating the crash?

chro...@googlecode.com

unread,
May 29, 2013, 9:58:53 AM5/29/13
to chromi...@chromium.org

Comment #36 on issue 109587 by david.uv...@gmail.com: Pasting lots of text
I looked into this a bit further and what I realized was that the
spellchecker was set to Swedish while I was doing the testing. When I
changed it to English and pasted the text from repro.html the response was
as fast as with spell-checker turned off. I then changed it back to Swedish
and pasted the text and it was again unresponsive (chrome
showing 'Unresponsive page' alert after some time. If I then
click 'continue' the page seems to stall forever).

I have no idea how the spellchecker works internally but it looked like it
was trying to check the spelling of all the pasted text at once before
giving back control to the user. Since the sample text is in English there
were a lot of spelling errors that it had to process and highlight.
This may be the reason why it can't be reproduced on OSX since the
spellchecker there only checks the currently selected/typed word.

chro...@googlecode.com

unread,
May 31, 2013, 10:01:12 PM5/31/13
to chromi...@chromium.org
Updates:
Labels: -Cr-Blink-Forms -Cr-UI-Browser-Autofill

Comment #37 on issue 109587 by gr...@chromium.org: Pasting lots of text to
Ah. That made a bit of a difference.

Setting my checker to swedish, I can see the same behavior on OSX. A quick
sampling in ActivityMonitor shows 96% of time spent in
WebCore::DocumentMarkerController::addMarker(WebCore::Node*,
WebCore::DocumentMarker const&)

Looking at the function makes clear why it's so expensive - it's
essentially a linear scan of the existing markers for coalescing purposes.
I _think_ we can use WTF::approximateBinarySearch to find the first
occurrence instead.

Taking off autofill/forms for now

chro...@googlecode.com

unread,
Mar 12, 2014, 7:29:45 AM3/12/14
to chromi...@chromium.org

Comment #38 on issue 109587 by psta...@opera.com: Pasting lots of text to a
This should be fixed by 279293.

chro...@googlecode.com

unread,
Mar 12, 2014, 7:35:47 AM3/12/14
to chromi...@chromium.org
Updates:
Blockedon: chromium:279293

Comment #39 on issue 109587 by nba...@chromium.org: Pasting lots of text to
This issue, right?
Issue 279293: DocumentMarkerController::addMarker very slow for large
number of markers

chro...@googlecode.com

unread,
Mar 12, 2014, 7:40:47 AM3/12/14
to chromi...@chromium.org

Comment #40 on issue 109587 by psta...@opera.com: Pasting lots of text to a
right

chro...@googlecode.com

unread,
Apr 22, 2015, 1:16:11 AM4/22/15
to chromi...@chromium.org

Comment #45 on issue 109587 by rajkumar...@gmail.com: Pasting lots of text
to a textarea is slow
https://code.google.com/p/chromium/issues/detail?id=109587

Any further updates on this issue? We are working on a couple of customer
issues and as per our early analysis this could be one among the cause.

chro...@googlecode.com

unread,
May 20, 2015, 8:19:21 AM5/20/15
to chromi...@chromium.org

Comment #47 on issue 109587 by pixelwol...@gmail.com: Pasting lots of text
Issue seems to still exist in Chrome 42.
I have pasted 30K of ASCII data into a textarea and the target tab is not
responding and after some time it is usable again but the data never gets
pasted.

Issue exists and needs to be fixed!

chro...@googlecode.com

unread,
Jul 28, 2015, 9:35:53 AM7/28/15
to chromi...@chromium.org

Comment #51 on issue 109587 by ksschwar...@googlemail.com: Pasting lots of
Using current chrome version 43 still comes with that issue.
Even if we use the javascript way to insert the content (which makes it
already more performant), it still slows down the whole page (and the
reason is not a slow hardware!). Using a textarea for editing large
content, doesn't make fun at all. Please be so kind to prioritize this
issue. If you need more input, don't hesitate to ask.

Thanks in advance!

chro...@googlecode.com

unread,
Jul 28, 2015, 11:16:11 AM7/28/15
to chromi...@chromium.org

Comment #52 on issue 109587 by phil.lar...@gmail.com: Pasting lots of text
Please fix, would like to know what's causing this? Is it the page find
tool is indexing the page?

chro...@googlecode.com

unread,
Jul 30, 2015, 7:09:09 AM7/30/15
to chromi...@chromium.org

Comment #53 on issue 109587 by 4lev...@gmail.com: Pasting lots of text to a
I can confirm that on Chrome-stable Version 44.0.2403.107 (64-bit) the
issue exists, but seems entirely related to the spellchecker. When pasting
eg. 50k lines of json, everything freezes caused by huge cpu spikes.
Disabling the spellchecker in the preferences resolves this

chro...@googlecode.com

unread,
Jul 30, 2015, 7:12:09 AM7/30/15
to chromi...@chromium.org

Comment #54 on issue 109587 by nguyenti...@gmail.com: Pasting lots of text
But we can not tell with users that they must disable spellchecker to work
with our tool.

So my work around is when they paste some large thing, I will save into a
Js variable, then cut off the content in textarea to 32000 characters. Then
when they take action (submitting or something), I will use the variable
instead of the textarea itself.

chro...@googlecode.com

unread,
Jul 30, 2015, 10:00:07 PM7/30/15
to chromi...@chromium.org

Comment #55 on issue 109587 by tk...@chromium.org: Pasting lots of text to
Issue 515634 has been merged into this issue.

chro...@googlecode.com

unread,
Jul 30, 2015, 10:01:06 PM7/30/15
to chromi...@chromium.org
Updates:
Labels: Hotlist-Google

Comment #56 on issue 109587 by tk...@chromium.org: Pasting lots of text to
(No comment was entered for this change.)

chro...@googlecode.com

unread,
Jul 31, 2015, 11:24:14 AM7/31/15
to chromi...@chromium.org

Comment #57 on issue 109587 by varu...@google.com: Pasting lots of text to
setting spellcheck="false" does not make it faster in textarea in chrome.
After pasting bug_text.txt inside the textarea in
text_area_not_working.html, it is very slow (after enabling spellchecking
from browser's language settings).

But when i disable spellchecking form browser's language settings, it is as
fast as other browsers like firefox or safari.

Attachments:
bug_text.txt 325 KB
text_area_not_working.html 310 bytes

chro...@googlecode.com

unread,
Aug 11, 2015, 4:10:49 AM8/11/15
to chromi...@chromium.org

Comment #58 on issue 109587 by koste...@gmail.com: Pasting lots of text to
I am also having this issue with Chrome Version 44.0.2403.130 m (for
Windows). Spellchecker is disabled.

Pasting a 700 KB chunk of text in a textarea causes the tab to become
unresponsive for a good 10 seconds. Please fix!

chro...@googlecode.com

unread,
Aug 11, 2015, 4:19:57 AM8/11/15
to chromi...@chromium.org

Comment #59 on issue 109587 by koste...@gmail.com: Pasting lots of text to
Following up my post above: I removed "white-space: nowrap" from the CSS
attributes on my textarea, and it made it a lot faster. The lag went from
about 10 seconds to less than 1 second.

chro...@googlecode.com

unread,
Aug 15, 2015, 7:42:24 AM8/15/15
to chromi...@chromium.org

Comment #60 on issue 109587 by sbminteg...@gmail.com: Pasting lots of text
This issue (long text pasted into textarea causes 100% of CPU in Chrome
task manager and practically stoping execution). Maybe something common
with practical impossibility view long textarea in developers console due
to Codemirror formating ?
Firefox has no similar problem.
Why solution of this in my oppinion very big problem has no solution 4
years ?

chro...@googlecode.com

unread,
Aug 16, 2015, 9:00:08 PM8/16/15
to chromi...@chromium.org
Updates:
Status: Assigned
Owner: yoic...@chromium.org
Labels: -Cr-Blink-Forms-Textarea -Cr-Blink-Editing-Command

Comment #61 on issue 109587 by yo...@chromium.org: Pasting lots of text to
(No comment was entered for this change.)

chro...@googlecode.com

unread,
Sep 8, 2015, 4:08:01 PM9/8/15
to chromi...@chromium.org
Updates:
Cc: brajku...@chromium.org

Comment #62 on issue 109587 by rous...@chromium.org: Pasting lots of text
Issue 527480 has been merged into this issue.

chro...@googlecode.com

unread,
Sep 11, 2015, 4:21:32 AM9/11/15
to chromi...@chromium.org

Comment #63 on issue 109587 by sladecol...@gmail.com: Pasting lots of text
Please fix this !!! The FF guys in the office are all "See FF is just
better and less memory usage...and chrome is bloated ...and..."

chro...@googlecode.com

unread,
Sep 11, 2015, 11:13:57 AM9/11/15
to chromi...@chromium.org

Comment #64 on issue 109587 by ayres.p...@gmail.com: Pasting lots of text
I believe that I have found another reason why this needs attention. Having
a text area into which I paste 5000 lines of text (just first and last
names) slows JQuery access to the dom considerably. Maybe a difference of
2-5 times slower from what I can tell. If I clear the content of the
textarea with a .val('').html('') and use the exactly identical code to
search and manipulate my dom, the measured performance drag goes away.

chro...@googlecode.com

unread,
Oct 19, 2015, 12:13:24 AM10/19/15
to chromi...@chromium.org

Comment #65 on issue 109587 by tk...@chromium.org: Pasting lots of text to
Issue 544649 has been merged into this issue.

chro...@googlecode.com

unread,
Oct 30, 2015, 10:39:43 PM10/30/15
to chromi...@chromium.org

Comment #67 on issue 109587 by gr...@chromium.org: Pasting lots of text to
Indeed - spellcheck=true seems to be ignored when you paste HTML. See
https://jsfiddle.net/5g4bx6cq/ for small repro case.

chro...@googlecode.com

unread,
Nov 26, 2015, 12:34:15 AM11/26/15
to chromi...@chromium.org

Comment #69 on issue 109587 by yoic...@chromium.org: Pasting lots of text
Issue 531033 has been merged into this issue.

chro...@googlecode.com

unread,
Dec 16, 2015, 2:19:16 AM12/16/15
to chromi...@chromium.org

Comment #70 on issue 109587 by xiaoche...@chromium.org: Pasting lots of
chrome://tracing shows that
SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar is a major (maybe
not the only) source of the inefficiency.

With some code digging, every time something is pasted, even if it's just a
single character, the above mentioned method examines the full text in the
textarea. My gut feeling is that we should examine only the pasted part
(and possibly a few characters before/after it) instead.

Even worse, this method runs in O(n^2) time in the worst case, where n is
the length of the full text in the textarea (including the text that was
just pasted). To get an idea, (in a sketch) the function does the following:
1. Cut the text to be examined (i.e., everything in the textarea) into
chunks, where each chunk has length kChunkSize = 16384 (hardcoded)
2. Expand each chunk to align with sentence boundaries by calling
expandRangeToSentenceBoundary
3. Call SpellChecker::markAllMisspellingsAndBadGrammarInRanges on each
expanded chunk

As far as I have checked, step 2 is a troublemaker. Function
expandRangeToSentenceBoundary calls startOfSentence and endOfSentence to
find sentence boundaries, which in turn call previousBoundary and
nextBoundary, respectively. previousBoundary copies to a temporary buffer a
text fragment that ends at the starting position of the chunk, and then
scans the buffer with a TextBreakIterator to find a sentence boundary. In
the worst case, the text fragment starts at the beginning of the full text.
nextBoundary does something symmetric.

As a result, in the worst case, step 2 needs to process everything in the
textarea, in which case the chunking trick is completely useless. And the
worst case is very easily achievable: just paste some very long text into
an empty textarea, and then the two boundary functions together copy the
full text into their buffers every time step 2 is run.

chro...@googlecode.com

unread,
Dec 16, 2015, 6:19:43 AM12/16/15
to chromi...@chromium.org
Updates:
Cc: psta...@opera.com

Comment #71 on issue 109587 by psta...@opera.com: Pasting lots of text to a
It seems the trouble making code got introduced by the fix for
https://code.google.com/p/chromium/issues/detail?id=264737. This bug
predates the fix but it's possible that fix made things worse.

chro...@googlecode.com

unread,
Dec 16, 2015, 3:52:11 PM12/16/15
to chromi...@chromium.org

Comment #72 on issue 109587 by gr...@chromium.org: Pasting lots of text to
If the slowdown depends on text size, it's very likely the chunking is the
culprit - each chunk *should* be treated as an asynchronous request.

Technically, we only need to call previousBoundary on the very start - then
chunk, call nextBoundary on end of chunk, and use that as start for next
chunk as well.

Next up, for pasted text, we need to expand the range to the
sentenceBoundaries including the pasted item. (Contextual spellcheck
operates on a sentence context)

Finally, I'd suggest adding a limit to the next/prevBoundary functions. If
your sentence boundary is more than ~1K(rough heuristic) away, I'm
perfectly OK with spellcheck not being entirely meaningful. Your text isn't
either :)

chro...@googlecode.com

unread,
Dec 16, 2015, 9:44:14 PM12/16/15
to chromi...@chromium.org

Comment #73 on issue 109587 by xiaoche...@chromium.org: Pasting lots of
pstanek@: thanks for pointing out that. Fortunately, it doesn't seem to
introduce the trouble making code in this bug, though.

When SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar is called, the
call stack does not overlap with the revision in your patch:

#0 blink::SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar
#1 blink::Editor::replaceSelectionWithFragment
#2 blink::Editor::replaceSelectionWithText
#3 blink::Editor::handleTextEvent
#4 blink::EventHandler::defaultTextInputEventHandler
#5 blink::Node::defaultEventHandler
#6 blink::HTMLElement::defaultEventHandler
#7 blink::EventDispatcher::dispatchEventPostProcess
#8 blink::EventDispatcher::dispatch
#9 blink::EventDispatchMediator::dispatchEvent
#10 blink::EventDispatcher::dispatchEvent
#11 blink::Node::dispatchEventInternal
#12 blink::EventTarget::dispatchEvent
#13 blink::Editor::pasteAsPlainText
#14 blink::Editor::pasteAsPlainTextWithPasteboard
#15 blink::Editor::paste
#16 blink::executePaste
#17 blink::Editor::Command::execute
#18 blink::Editor::Command::execute
#19 blink::Editor::handleEditingKeyboardEvent
#20 blink::Editor::handleKeyboardEvent
... (irrelevant frames)

chro...@googlecode.com

unread,
Dec 16, 2015, 10:58:24 PM12/16/15
to chromi...@chromium.org

Comment #74 on issue 109587 by xiaoche...@chromium.org: Pasting lots of
groby@: thanks for pointing out the asynchronous spell check request. As a
newbie to chrome I learned new knowledge today.

The current implementation does process each expanded chunk with an
asynchronous SpellCheckRequest. This is done in
SpellChecker::markAllMisspellingsAndBadGrammarInRanges.

chro...@googlecode.com

unread,
Dec 17, 2015, 10:12:27 PM12/17/15
to chromi...@chromium.org
Updates:
Status: Started
Owner: xiaoche...@chromium.org

Comment #75 on issue 109587 by xiaoche...@chromium.org: Pasting lots of
(No comment was entered for this change.)

chro...@googlecode.com

unread,
Jan 7, 2016, 3:41:51 AM1/7/16
to chromi...@chromium.org

Comment #76 on issue 109587 by bugd...@chromium.org: Pasting lots of text
to a textarea is slow
https://code.google.com/p/chromium/issues/detail?id=109587#c76

The following revision refers to this bug:

https://chromium.googlesource.com/chromium/src.git/+/b0f70be05379a033d47c4eb7d5a389b546338044

commit b0f70be05379a033d47c4eb7d5a389b546338044
Author: xiaochengh <xiaoc...@chromium.org>
Date: Thu Jan 07 08:39:49 2016

Optimizations to Spellchecking Chunk Generation

1. The existing implementation frequently does translations between
offsets and positions, and each translation needs to scan from the
beginning of the text paragraph. The patch avoids such translations
completely.

2. Only the first chunk needs to have both of its start and end
positions expanded to sentence boundaries. For each subsequent chunk, we
only need to expand its end position to sentence boundary. Hence, we can
reduce the number of calls of startOfSentence to 1 regardless of the
number of chunks generated.

BUG=109587

Review URL: https://codereview.chromium.org/1563783003

Cr-Commit-Position: refs/heads/master@{#368035}

[modify]
http://crrev.com/b0f70be05379a033d47c4eb7d5a389b546338044/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
[modify]
http://crrev.com/b0f70be05379a033d47c4eb7d5a389b546338044/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.h
[modify]
http://crrev.com/b0f70be05379a033d47c4eb7d5a389b546338044/third_party/WebKit/Source/core/editing/spellcheck/TextCheckingHelper.cpp
[modify]
http://crrev.com/b0f70be05379a033d47c4eb7d5a389b546338044/third_party/WebKit/Source/core/editing/spellcheck/TextCheckingHelper.h

chro...@googlecode.com

unread,
Jan 22, 2016, 7:20:09 AM1/22/16
to chromi...@chromium.org

Comment #77 on issue 109587 by bugd...@chromium.org: Pasting lots of text
to a textarea is slow
https://code.google.com/p/chromium/issues/detail?id=109587#c77

The following revision refers to this bug:

https://chromium.googlesource.com/chromium/src.git/+/c3cb0dce8a7f1a4a72b82b76945a7e709f93d7e4

commit c3cb0dce8a7f1a4a72b82b76945a7e709f93d7e4
Author: xiaochengh <xiaoc...@chromium.org>
Date: Fri Jan 22 11:49:03 2016

Pass Only the Pasted Text to Spellchecker

Without this patch, the root editable element is passed to spellchecker
after pasting, which results in a long running time if we paste some short
text into an editor that already has a large amount of text.

This patch passes the range of the pasted text only, which significantly
reduces the time spent on spellchecking in the above scenario.

BUG=109587

Review URL: https://codereview.chromium.org/1620653002

Cr-Commit-Position: refs/heads/master@{#370946}

[modify]
http://crrev.com/c3cb0dce8a7f1a4a72b82b76945a7e709f93d7e4/third_party/WebKit/Source/core/editing/Editor.cpp
[modify]
http://crrev.com/c3cb0dce8a7f1a4a72b82b76945a7e709f93d7e4/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
[modify]
http://crrev.com/c3cb0dce8a7f1a4a72b82b76945a7e709f93d7e4/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.h
[modify]
http://crrev.com/c3cb0dce8a7f1a4a72b82b76945a7e709f93d7e4/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
[modify]
http://crrev.com/c3cb0dce8a7f1a4a72b82b76945a7e709f93d7e4/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.h

chro...@googlecode.com

unread,
Feb 14, 2016, 6:32:30 PM2/14/16
to chromi...@chromium.org

Comment #79 on issue 109587 by tk...@chromium.org: Pasting lots of text to
Issue 586768 has been merged into this issue.

chro...@googlecode.com

unread,
Feb 16, 2016, 9:30:50 AM2/16/16
to chromi...@chromium.org

Comment #80 on issue 109587 by bugd...@chromium.org: Pasting lots of text
to a textarea is slow
https://code.google.com/p/chromium/issues/detail?id=109587#c80

The following revision refers to this bug:

https://chromium.googlesource.com/chromium/src.git/+/0fb56f3c6fa1f13cd17e714217900b73c1b75c3d

commit 0fb56f3c6fa1f13cd17e714217900b73c1b75c3d
Author: xiaochengh <xiaoc...@chromium.org>
Date: Tue Feb 16 14:20:34 2016

Optimize Boundary Finding with Progressive Text Accumulation

When searching for boundaries, we ensure that each time |copyTextTo()|
is called, the length of text copied is bounded by the buffer capacity,
and hence, avoiding copying everything of a large text node all at once.

This is part of a bigger CL [1].

[1] https://codereview.chromium.org/1604783002

BUG=109587
TEST=n/a; no behavior change

Review URL: https://codereview.chromium.org/1687813002

Cr-Commit-Position: refs/heads/master@{#375565}

[modify]
http://crrev.com/0fb56f3c6fa1f13cd17e714217900b73c1b75c3d/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
[modify]
http://crrev.com/0fb56f3c6fa1f13cd17e714217900b73c1b75c3d/third_party/WebKit/Source/core/editing/iterators/TextBufferBase.cpp
[modify]
http://crrev.com/0fb56f3c6fa1f13cd17e714217900b73c1b75c3d/third_party/WebKit/Source/core/editing/iterators/TextBufferBase.h

chro...@googlecode.com

unread,
Feb 17, 2016, 1:15:28 PM2/17/16
to chromi...@chromium.org

Comment #81 on issue 109587 by xiaoche...@chromium.org: Pasting lots of
The above 3 patches are now available in Canary.

Made a comparison made on my OS X 10.11.3 laptop. The operation is:

1. Open #4's repro.html
2. Select-All in the <textarea> and copy
3. Paste at the end of the <textarea>

The pasting took 25.6s on Stable (48.0.2564.109), and 10.4s on Canary
(50.0.2653.0). The running of
SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar is optimized from
19s to 4.4s.

Now the running time of pasting has two major sources:

1. FrameView::performView (issue 586772), which is called for multiple
times before the spellchecking code

2. Position canonicalization code: VisibleUnits::canonicalPosition,
VisibleUnits::mostForwardCaretPosition and
VisibleUnits::mostBackwardCaretPosition

Attachments:
stable_48.0.2564.109.png 139 KB
canary_50.0.2563.0.png 430 KB
trace_stable_48.0.2564.109.json.gz 3.2 MB
trace_canary_50.0.2653.0.json.gz 893 KB
Reply all
Reply to author
Forward
0 new messages