Bug 283222
| Summary: | Poor performance of querySelectorAll() with descendant selectors (:has()) | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Jeff Johnson <opendarwin> |
| Component: | CSS | Assignee: | Antti Koivisto <koivisto> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | karlcow, koivisto, simon.fraser, webkit-bug-importer |
| Priority: | P2 | Keywords: | BrowserCompat, InRadar |
| Version: | Safari 18 | ||
| Hardware: | Mac (Apple Silicon) | ||
| OS: | Unspecified | ||
| See Also: |
https://bugs.webkit.org/show_bug.cgi?id=283220 https://bugs.webkit.org/show_bug.cgi?id=288923 |
||
Jeff Johnson
I discovered this bug while investigating another bug, Poor performance of selector div:has(img) button https://bugs.webkit.org/show_bug.cgi?id=283220
Steps to reproduce:
1. Open https://sdpc.a4l.org/search_national.php
2. Open the web inspector
3. document.querySelectorAll('foobar div:has(img) button')
Expected results: The node list is returned immediately.
Actual results: The node list takes about 3 seconds to return.
Since document.querySelectorAll('foobar') contains no items, the rest of the selector should be irrelevant and ignored. But WebKit is still clearly calculating the 'div:has(img) button' part of the selector.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/140093151>
Karl Dubost
var startTime = performance.now(); document.querySelectorAll('foobar div:has(img) button'); var endTime = performance.now(); console.log(`${endTime - startTime} milliseconds`)
Safari: 2247 ms
Firefox: 2 ms
Chrome: 22 ms
Safari Technology Preview 207 20621.1.4.3
Firefox Nightly 134.0a1 13424.11.7
Google Chrome Canary 133.0.6843.0 6843.0
Antti Koivisto
Pull request: https://github.com/WebKit/WebKit/pull/36893
EWS
Committed 286908@main (cdba6f7e0a32): <https://commits.webkit.org/286908@main>
Reviewed commits have been landed. Closing PR #36893 and removing active labels.
Antti Koivisto
*** Bug 283220 has been marked as a duplicate of this bug. ***