-
Notifications
You must be signed in to change notification settings - Fork 1.6k
AX: AXTextMarker::findMarker, a frequently called function, can copy all the text-runs strings, causing performance issues on pages with lots of text #47209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
EWS run on previous version of this PR (hash 44d3719) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
I think we talked about comparing stringValue to the concatenated textRuns strings to assert that they're equal, and maybe even avoid saving both - that'd be even easier now.
44d3719
to
aff5d98
Compare
EWS run on current version of this PR (hash aff5d98) |
…all the text-runs strings, causing performance issues on pages with lots of text https://bugs.webkit.org/show_bug.cgi?id=294996 rdar://154332688 Reviewed by Joshua Hoffman. For groups of text runs that contain non-ASCII characters, AXTextMarker::findMarker needs to use CachedTextBreakIterator to determine how many offsets to move forward or backward. This is relevant for things like multi-byte emojis. CachedTextBreakIterator takes a StringView, but we were always doing the far less efficient thing of combining the text from all AXTextRun structs into a single String, requiring multiple allocations along the way. This is a major performance problem on webpages that have lots of text (e.g. 40 seconds of a 60 second sample was spent building and allocating strings underneath findMarker). We had to do it this way because CachedTextBreakIterator needs the full string from all runs, but because each AXTextRun owned its own string, we couldn't just naively use StringView here, because you can't combine disparate StringViews (one for each AXTextRun) into one larger StringView (that's not how StringViews work). Solve the issue by making AXTextRuns own a singular string for all runs, and add start and end index fields to AXTextRun that point into this string. This allows us to use StringViews in many more places, which this commit does. * Source/WebCore/accessibility/AXLogger.cpp: (WebCore::streamTextRuns): * Source/WebCore/accessibility/AXTextMarker.cpp: (WebCore::AXTextMarkerRange::toString const): (WebCore::AXTextMarker::findMarker const): (WebCore::AXTextMarker::findParagraph const): (WebCore::AXTextMarker::findWordOrSentence const): * Source/WebCore/accessibility/AXTextRun.cpp: (WebCore::AXTextRuns::debugDescription const): (WebCore::AXTextRuns::localRect const): (WebCore::AXTextRuns::substring const): Deleted. * Source/WebCore/accessibility/AXTextRun.h: (WebCore::AXTextRun::AXTextRun): (WebCore::AXTextRun::length const): (WebCore::AXTextRuns::AXTextRuns): (WebCore::AXTextRuns::at const): (WebCore::AXTextRuns::operator[] const): (WebCore::AXTextRuns::runLength const): (WebCore::AXTextRuns::lastRunLength const): (WebCore::AXTextRuns::lineID const): (WebCore::AXTextRuns::toString const): (WebCore::AXTextRuns::toStringView const): (WebCore::AXTextRuns::substring const): (WebCore::AXTextRuns::runString const): (WebCore::AXTextRuns::runStringView const): (WebCore::AXTextRuns::runStartsWithLineBreak const): (WebCore::AXTextRuns::runEndsWithLineBreak const): (WebCore::AXTextRun::debugDescription const): Deleted. (WebCore::AXTextRun::startsWithLineBreak const): Deleted. (WebCore::AXTextRun::endsWithLineBreak const): Deleted. (WebCore::AXTextRun::characterAt const): Deleted. (WebCore::AXTextRun::textLength const): Deleted. * Source/WebCore/accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::textRuns): * Source/WebCore/accessibility/cocoa/AXTextMarkerCocoa.mm: (WebCore::AXTextMarkerRange::toAttributedString const): Canonical link: https://commits.webkit.org/296681@main
aff5d98
to
d05070c
Compare
Committed 296681@main (d05070c): https://commits.webkit.org/296681@main Reviewed commits have been landed. Closing PR #47209 and removing active labels. |
d05070c
aff5d98