You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[iOS] DOM nodes can be leaked when searching for text in Safari
https://bugs.webkit.org/show_bug.cgi?id=285450
rdar://133689631
Reviewed by Abrar Rahman Protyasha and Richard Robinson.
The UIKit API for find-in-page on iOS expects clients to vend all found ranges to
the system. The system then tells the client to highlight / scroll to the appropriate
range. Since converting between the range representation for UIKit and `SimpleRange`s
can be slow, a cache of found ranges is maintained.
Under most API use (via the system search UI), the cache is populated when the user
starts searching and is cleared when the user dismisses the find bar. However, when
searches are performed using Safari's URL bar, the find APIs may be called directly,
without the full system user flow that clears caches. Since the cache preserves
`SimpleRange`s, it strongly holds on to DOM nodes.
Fix by updating the cache to store `WeakSimpleRange`s. Additionally, clear the cache
on memory pressure.
* Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp:
(WebKit::WebFoundTextRangeController::findTextRangesForStringMatches):
(WebKit::WebFoundTextRangeController::clearAllDecoratedFoundText):
(WebKit::WebFoundTextRangeController::clearCachedRanges):
(WebKit::WebFoundTextRangeController::simpleRangeFromFoundTextRange):
* Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::releaseMemory):
Canonical link: https://commits.webkit.org/288505@main
0 commit comments