Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 42a531abe63602f463a4b02b82c7b4386284d61f
https://github.com/WebKit/WebKit/commit/42a531abe63602f463a4b02b82c7b4386284d61f
Author: Nipun Shukla <[email protected]>
Date: 2026-05-14 (Thu, 14 May 2026)
Changed paths:
A PerformanceTests/Bindings/insert-img-with-src.html
M Source/WebCore/contentextensions/ContentExtension.cpp
M Source/WebCore/contentextensions/ContentExtension.h
M Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
M Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp
M Source/WebCore/contentextensions/DFABytecodeInterpreter.h
M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/ContentRuleListNotification.mm
Log Message:
-----------
Dynamically inserting `<img>` elements with `src` attribute is slow
https://bugs.webkit.org/show_bug.cgi?id=314251
rdar://166201075
Reviewed by Chris Dumez.
Dynamically inserting <img> elements with src was exceedingly slow due to
DFABytecodeInterpreter, which re-walks the full URL from byte 0 on every
call.
Since DFA state at byte N is a function of url[0..N], we checkpoint
each DFA's program counter and accumulated actions at the first '/' after
'://' in a 4-slot LRU on ContentExtension. Subsequent same-origin URLs resume
from the checkpoint instead of re-walking the prefix.
The included performance test progresses from a mean of 84 ms to 4 ms when
testing locally. An APITest is included to ensure that we do not regress
behavior when dealing with domains with the same starting characters.
* PerformanceTests/Bindings/insert-img-with-src.html: Added.
* Source/WebCore/contentextensions/ContentExtension.cpp:
(WebCore::ContentExtensions::ContentExtension::ContentExtension):
(WebCore::ContentExtensions::ContentExtension::interpretURLFilters const):
* Source/WebCore/contentextensions/ContentExtension.h:
* Source/WebCore/contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::actionsFromContentRuleList
const):
* Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp:
(WebCore::ContentExtensions::DFABytecodeInterpreter::DFABytecodeInterpreter):
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):
* Source/WebCore/contentextensions/DFABytecodeInterpreter.h:
(WebCore::ContentExtensions::DFABytecodeInterpreter::DFABytecodeInterpreter):
Deleted.
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/ContentRuleListNotification.mm:
(TEST(ContentRuleList, InterpretURLFilterCacheDoesNotConfuseSameStartDomains)):
Canonical link: https://commits.webkit.org/313268@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications