Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c40691a5705e5b0d8ade87482cb7aef4bb86c385
      
https://github.com/WebKit/WebKit/commit/c40691a5705e5b0d8ade87482cb7aef4bb86c385
  Author: Aditya Keerthi <[email protected]>
  Date:   2025-01-06 (Mon, 06 Jan 2025)

  Changed paths:
    M Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp
    M Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.h
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp

  Log Message:
  -----------
  [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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to