Bug 261123 - Performance improvement for the word boundary finding algorithm (findNextWordFromIndex)
Summary: Performance improvement for the word boundary finding algorithm (findNextWord...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: Safari 16
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: https://jsfiddle.net/1ucrpsq5/show
Keywords: InRadar, Performance
Depends on:
Blocks:
 
Reported: 2023-09-04 14:23 PDT by Ahmad Saleem
Modified: 2024-06-26 18:49 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ahmad Saleem 2023-09-04 14:23:29 PDT
Hi Team,

While going through Blink's commit, I came across test case, where Safari hangs (it is performance test case, so it is kind of edge case).

Both Chrome Canary 118 and Firefox Nightly 118 are fast and complete it in 3xx milliseconds while I am unable to see timing for Safari due to hangs.

Test Case - in URL field.

Just wanted to raise so we can fix it.

Thanks!
Comment 1 Karl Dubost 2023-09-04 18:17:38 PDT
This is indeed failing quite hard.
Comment 2 Radar WebKit Bug Importer 2023-09-04 18:17:46 PDT
<rdar://problem/114954726>
Comment 3 zalan 2023-09-05 10:18:48 PDT
Looks like we spend some time in nextWordFromIndex:forward

32.79 s   82.2%	0 s	 	                          WebCore::jsDOMSelectionPrototypeFunction_modify(JSC::JSGlobalObject*, JSC::CallFrame*)
32.79 s   82.2%	0 s	 	                           WebCore::DOMSelection::modify(WTF::String const&, WTF::String const&, WTF::String const&)
32.79 s   82.2%	0 s	 	                            WebCore::FrameSelection::modify(WebCore::FrameSelection::EAlteration, WebCore::SelectionDirection, WebCore::TextGranularity, WebCore::EUserTriggered)
32.79 s   82.2%	0 s	 	                             WebCore::FrameSelection::modifyExtendingForward(WebCore::TextGranularity)
32.79 s   82.2%	0 s	 	                              WebCore::FrameSelection::nextWordPositionForPlatform(WebCore::VisiblePosition const&)
32.79 s   82.2%	0 s	 	                               WebCore::nextWordPosition(WebCore::VisiblePosition const&)
32.79 s   82.2%	0 s	 	                                WebCore::nextBoundary(WebCore::VisiblePosition const&, unsigned int (*)(WTF::StringView, unsigned int, WebCore::BoundarySearchContextAvailability, bool&))
32.79 s   82.2%	0 s	 	                                 WebCore::forwardSearchForBoundaryWithTextIterator(WebCore::TextIterator&, WTF::Vector<char16_t, 1024ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc>&, unsigned int, unsigned int (*)(WTF::StringView, unsigned int, WebCore::BoundarySearchContextAvailability, bool&))
29.34 s   73.6%	0 s	 	                                  WebCore::findNextWordFromIndex(WTF::StringView, int, bool)
27.03 s   67.8%	0 s	 	                                   -[NSAttributedString(NSAttributedStringUIFoundationAdditions) nextWordFromIndex:forward:]

(changing component to editing)