Bug 104884 - Safari spends a lot of time in WebCore::findSimpleWordBoundary while selecting text on large scrabutility.com page
Summary: Safari spends a lot of time in WebCore::findSimpleWordBoundary while selectin...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2012-12-13 00:03 PST by Ryosuke Niwa
Modified: 2012-12-13 02:10 PST (History)
9 users (show)

See Also:


Attachments
Don't find word boundaries outside of editable region (1.81 KB, patch)
2012-12-13 00:24 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2012-12-13 00:03:38 PST
Visit http://scrabutility.com/4_TWL06.php and select text by mouse drags. You see a spin.

<rdar://problem/12188622>
Comment 1 Ryosuke Niwa 2012-12-13 00:03:53 PST
It appears that this could be a regression from http://trac.webkit.org/changeset/120357.
Comment 2 Ryosuke Niwa 2012-12-13 00:04:57 PST
We’re spending a significant amount of time in AlternativeTextController::respondToChangedSelection

Running Time	Self		Symbol Name
1183.0ms   50.6%	1183.0	 	icu::RuleBasedBreakIterator::handleNext(icu::RBBIStateTable const*)
1183.0ms   50.6%	0.0	 	 icu::RuleBasedBreakIterator::next()
1183.0ms   50.6%	0.0	 	  icu::RuleBasedBreakIterator::following(int)
1183.0ms   50.6%	0.0	 	   -[NSAttributedString(NSAttributedStringKitAdditions) doubleClickAtIndex:inRange:]
1183.0ms   50.6%	0.0	 	    WebCore::findWordBoundary(unsigned short const*, int, int, int*, int*)
1183.0ms   50.6%	0.0	 	     WebCore::endWordBoundary(unsigned short const*, unsigned int, unsigned int, WebCore::BoundarySearchContextAvailability, bool&)
1183.0ms   50.6%	0.0	 	      WebCore::nextBoundary(WebCore::VisiblePosition const&, unsigned int (*)(unsigned short const*, unsigned int, unsigned int, WebCore::BoundarySearchContextAvailability, bool&))
1183.0ms   50.6%	0.0	 	       WebCore::endOfWord(WebCore::VisiblePosition const&, WebCore::EWordSide)
1183.0ms   50.6%	0.0	 	        WebCore::AlternativeTextController::respondToChangedSelection(WebCore::VisibleSelection const&, unsigned int)
1183.0ms   50.6%	0.0	 	         WebCore::Editor::respondToChangedSelection(WebCore::VisibleSelection const&, unsigned int)
1183.0ms   50.6%	0.0	 	          WebCore::FrameSelection::setSelection(WebCore::VisibleSelection const&, unsigned int, WebCore::FrameSelection::CursorAlignOnScroll, WebCore::TextGranularity)
Comment 3 Ryosuke Niwa 2012-12-13 00:21:04 PST
Okay, I have a fix for this particular bug but selection is still very laggy. Now we spend most of time clipping selection rect :(

Running Time	Self		Symbol Name
2832.0ms   62.5%	0.0	 	                      -[WebTileLayer drawInContext:]
2832.0ms   62.5%	0.0	 	                       WebCore::TileCache::drawLayer(WebTileLayer*, CGContext*)
2832.0ms   62.5%	0.0	 	                        drawLayerContents(CGContext*, CALayer*, WebCore::PlatformCALayer*)
2830.0ms   62.4%	0.0	 	                         WebCore::GraphicsLayer::paintGraphicsLayerContents(WebCore::GraphicsContext&, WebCore::IntRect const&)
2830.0ms   62.4%	0.0	 	                          WebCore::RenderLayerBacking::paintContents(WebCore::GraphicsLayer const*, WebCore::GraphicsContext&, unsigned int, WebCore::IntRect const&)
2830.0ms   62.4%	0.0	 	                           WebCore::RenderLayerBacking::paintIntoLayer(WebCore::RenderLayer*, WebCore::GraphicsContext*, WebCore::IntRect const&, unsigned int, unsigned int)
2829.0ms   62.4%	0.0	 	                            WebCore::RenderLayer::paintLayerContents(WebCore::GraphicsContext*, WebCore::RenderLayer::LayerPaintingInfo const&, unsigned int)
2829.0ms   62.4%	0.0	 	                             WebCore::RenderLayer::paintLayer(WebCore::GraphicsContext*, WebCore::RenderLayer::LayerPaintingInfo const&, unsigned int)
2829.0ms   62.4%	2.0	 	                              WebCore::RenderLayer::paintLayerContents(WebCore::GraphicsContext*, WebCore::RenderLayer::LayerPaintingInfo const&, unsigned int)
2827.0ms   62.4%	0.0	 	                               WebCore::RenderBlock::paint(WebCore::PaintInfo&, WebCore::LayoutPoint const&)
2826.0ms   62.3%	0.0	 	                                WebCore::RenderBlock::paintObject(WebCore::PaintInfo&, WebCore::LayoutPoint const&)
2819.0ms   62.2%	0.0	 	                                 WebCore::RenderBlock::paintFloats(WebCore::PaintInfo&, WebCore::LayoutPoint const&, bool)
2819.0ms   62.2%	0.0	 	                                  WebCore::RenderBlock::paint(WebCore::PaintInfo&, WebCore::LayoutPoint const&)
2819.0ms   62.2%	0.0	 	                                   WebCore::RenderBlock::paintObject(WebCore::PaintInfo&, WebCore::LayoutPoint const&)
1904.0ms   42.0%	0.0	 	                                    WebCore::RenderBlock::paintSelection(WebCore::PaintInfo&, WebCore::LayoutPoint const&)
1363.0ms   30.0%	52.0	 	                                     WebCore::RenderBlock::selectionGaps(WebCore::RenderBlock*, WebCore::LayoutPoint const&, WebCore::LayoutSize const&, WebCore::LayoutUnit&, WebCore::LayoutUnit&, WebCore::LayoutUnit&, WebCore::PaintInfo const*)
1300.0ms   28.7%	12.0	 	                                      WebCore::GraphicsContext::clipOut(WebCore::IntRect const&)
Comment 4 Ryosuke Niwa 2012-12-13 00:24:39 PST
Created attachment 179219 [details]
Don't find word boundaries outside of editable region
Comment 5 Ryosuke Niwa 2012-12-13 00:29:46 PST
+antti, +kling in the case they know how to improve GraphicsContext::clipOut.
Comment 6 Hajime Morrita 2012-12-13 00:37:09 PST
Comment on attachment 179219 [details]
Don't find word boundaries outside of editable region

Looks an easy win. You'd file a bug for tracking slowness of selection in general.
Comment 7 Ryosuke Niwa 2012-12-13 00:45:19 PST
Comment on attachment 179219 [details]
Don't find word boundaries outside of editable region

Thanks for the review.
Comment 8 Ryosuke Niwa 2012-12-13 00:53:12 PST
(In reply to comment #6)
> (From update of attachment 179219 [details])
> Looks an easy win. You'd file a bug for tracking slowness of selection in general.

Yeah, I'll go talk with someone familiar with GraphicsContext and see there's anyway to improve clipping.
Comment 9 WebKit Review Bot 2012-12-13 02:10:17 PST
Comment on attachment 179219 [details]
Don't find word boundaries outside of editable region

Clearing flags on attachment: 179219

Committed r137577: <http://trac.webkit.org/changeset/137577>
Comment 10 WebKit Review Bot 2012-12-13 02:10:21 PST
All reviewed patches have been landed.  Closing bug.