Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3001d64b831c10251b04ea560505aeab4fa0a9ec
      
https://github.com/WebKit/WebKit/commit/3001d64b831c10251b04ea560505aeab4fa0a9ec
  Author: Wenson Hsieh <[email protected]>
  Date:   2026-01-02 (Fri, 02 Jan 2026)

  Changed paths:
    M Source/WebCore/page/text-extraction/TextExtraction.cpp
    M Source/WebKit/Sources.txt
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
    A Source/WebKit/UIProcess/TextExtractionAssertionScope.cpp
    A Source/WebKit/UIProcess/TextExtractionAssertionScope.h
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebProcessActivityState.cpp
    M Source/WebKit/UIProcess/WebProcessActivityState.h
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/TextExtractionTests.mm

  Log Message:
  -----------
  [AutoFill Debugging] Text extraction may hang indefinitely when invoked from 
system daemons
https://bugs.webkit.org/show_bug.cgi?id=304765
rdar://167099858

Reviewed by Megan Gardner and Abrar Rahman Protyasha.

Take a background process assertion when performing text extraction; without 
this, the web process
might become idle in the middle of text extraction, for certain clients that 
run in the context of
system daemons.

* Source/WebCore/page/text-extraction/TextExtraction.cpp:
(WebCore::TextExtraction::applyRules):

Drive-by fix: avoid `WTF::move`-ing the same arguments map multiple times when 
calling into each
filtering script.

* Source/WebKit/Sources.txt:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _extractDebugTextWithConfiguration:completionHandler:]):
(-[WKWebView 
_extractDebugTextWithConfigurationWithoutUpdatingFilterRules:assertionScope:completionHandler:]):
(-[WKWebView 
_extractDebugTextWithConfigurationWithoutUpdatingFilterRules:completionHandler:]):
 Deleted.

Add `assertionScope` (see below) as an argument to this internal method, so 
that we can hold on to
it over the scope of this text extraction call.

* Source/WebKit/UIProcess/TextExtractionAssertionScope.cpp: Added.
(WebKit::TextExtractionAssertionScope::TextExtractionAssertionScope):
(WebKit::TextExtractionAssertionScope::~TextExtractionAssertionScope):
* Source/WebKit/UIProcess/TextExtractionAssertionScope.h: Added.

Add a RAII helper class that handles accounting for text extraction assertions. 
Because a client may
invoke text extraction multiple times for a given web view (e.g. with different 
filtering or output
configuration options specified), we maintain a pending text extraction count, 
and call into
`takeTextExtractionAssertion` only when the count increments for the first 
time, and later
`dropTextExtractionAssertion` when the count decrements back to 0.

* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::createTextExtractionAssertionScope):
(WebKit::WebPageProxy::takeTextExtractionAssertion):
(WebKit::WebPageProxy::dropTextExtractionAssertion):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebProcessActivityState.cpp:
(WebKit::WebProcessActivityState::takeTextExtractionAssertion):
(WebKit::WebProcessActivityState::dropTextExtractionAssertion):
* Source/WebKit/UIProcess/WebProcessActivityState.h:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/TextExtractionTests.mm:
(TestWebKitAPI::overrideGetListsForNamespace):

Adjust an API test to exercise the fix in `TextExtraction::applyRules` by 
adding a second rule.

Canonical link: https://commits.webkit.org/305048@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to