Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5c8e008844109a2b2cf1bdc1819f50f4b9a41a1a
      
https://github.com/WebKit/WebKit/commit/5c8e008844109a2b2cf1bdc1819f50f4b9a41a1a
  Author: Abrar Rahman Protyasha <[email protected]>
  Date:   2025-06-17 (Tue, 17 Jun 2025)

  Changed paths:
    M Source/WebKit/Shared/WebFoundTextRange.cpp
    M Source/WebKit/Shared/WebFoundTextRange.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm

  Log Message:
  -----------
  [Unified PDF] Jetsams hit when quickly scrolling via Find-in-page results
https://bugs.webkit.org/show_bug.cgi?id=294617
rdar://149223603

Reviewed by Aditya Keerthi.

We notice the web content process often jetsams when we there is a large
number find-in-page results and we jump through them. This is explained
by unnecessary memory incurred in:

1. UnifiedPDFPlugin::visibleRectsForFindMatchRects(): Where we provide
   rects for _every_ find match, even if they are not within the
   unobscured content rect. Thus, WebFoundTextRangeController::drawRect
   paints many more paths than it needs to.
2. UnifiedPDFPlugin::selectionFromWebFoundTextRangePDFData(): Where we
   call into -[PDFDocument selectionFromPage:...] for every find-in-page
   result. This produces O(n) memory allocations under
   CGPDFSelectionCreateForRange.

Fixes are explained in line.

* Source/WebKit/Shared/WebFoundTextRange.cpp:
(WebKit::WebFoundTextRange::PDFData::hash const):
(WebKit::WebFoundTextRange::hash const):
(WebKit::operator<<):
    While the patch does not add new logging of PDFData, this is a useful
    utility to have.
* Source/WebKit/Shared/WebFoundTextRange.h:
(WTF::WebFoundTextRangePDFDataHash::hash):
(WTF::WebFoundTextRangePDFDataHash::equal):
(WTF::HashTraits<WebKit::WebFoundTextRange::PDFData>::emptyValue):
(WTF::HashTraits<WebKit::WebFoundTextRange::PDFData>::isEmptyValue):
(WTF::HashTraits<WebKit::WebFoundTextRange::PDFData>::constructDeletedValue):
(WTF::HashTraits<WebKit::WebFoundTextRange::PDFData>::isDeletedValue):
    Provide hash traits for PDFData, allowing it to be used as a map key.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::releaseMemory):
(WebKit::UnifiedPDFPlugin::findString):
     Remember to release the cache memory when appropriate, i.e. when a
     find session terminates or when we are generally releasing memory
     in the plugin.
(WebKit::UnifiedPDFPlugin::visibleRectsForFindMatchRects const):
    Only return rects for the find matches that currently intersect the
    unobscured content rect. This means we don't have an O(n) number of
    find match rects to paint.
(WebKit::UnifiedPDFPlugin::selectionFromWebFoundTextRangePDFData):

Canonical link: https://commits.webkit.org/296356@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