https://vuldb.com/?cvssv3.2012 takes long time to load.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Oct 2016 16:41:48 +0000 (16:41 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Oct 2016 16:41:48 +0000 (16:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162994
<rdar://problem/28593746>

Reviewed by Darin Adler.

Source/WebCore:

Stop visiting cousins when we hit the style sharing search threshold.

In addition to mistakenly ignoring the threshold at SharingResolver::findSibling(), we
continued on searching for cousin elements.

Test: fast/selectors/slow-style-sharing-with-long-cousin-list.html

* style/StyleSharingResolver.cpp:
(WebCore::Style::SharingResolver::resolve):
(WebCore::Style::SharingResolver::findSibling):
(WebCore::Style::SharingResolver::locateCousinList):

LayoutTests:

It takes ~100 seconds to run this test case without the fix (300ms with the fix).
Surely it will timeout if it gets regressed.

* fast/selectors/slow-style-sharing-with-long-cousin-list-expected.txt: Added.
* fast/selectors/slow-style-sharing-with-long-cousin-list.html: Added.
* platform/mac/TestExpectations: Skip perf test in debug.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206916 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/selectors/slow-style-sharing-with-long-cousin-list-expected.txt [new file with mode: 0644]
LayoutTests/fast/selectors/slow-style-sharing-with-long-cousin-list.html [new file with mode: 0644]
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/style/StyleSharingResolver.cpp

index 8fe3d93..5930404 100644 (file)
@@ -1,3 +1,18 @@
+2016-10-07  Zalan Bujtas  <zalan@apple.com>
+
+        https://vuldb.com/?cvssv3.2012 takes long time to load.
+        https://bugs.webkit.org/show_bug.cgi?id=162994
+        <rdar://problem/28593746>
+
+        Reviewed by Darin Adler.
+
+        It takes ~100 seconds to run this test case without the fix (300ms with the fix).
+        Surely it will timeout if it gets regressed. 
+
+        * fast/selectors/slow-style-sharing-with-long-cousin-list-expected.txt: Added.
+        * fast/selectors/slow-style-sharing-with-long-cousin-list.html: Added.
+        * platform/mac/TestExpectations: Skip perf test in debug.
+
 2016-10-07  Ryan Haddad  <ryanhaddad@apple.com>
 
         Marking contentextensions tests as flaky on mac-wk2.
diff --git a/LayoutTests/fast/selectors/slow-style-sharing-with-long-cousin-list-expected.txt b/LayoutTests/fast/selectors/slow-style-sharing-with-long-cousin-list-expected.txt
new file mode 100644 (file)
index 0000000..f58064a
--- /dev/null
@@ -0,0 +1 @@
+PASSED.
diff --git a/LayoutTests/fast/selectors/slow-style-sharing-with-long-cousin-list.html b/LayoutTests/fast/selectors/slow-style-sharing-with-long-cousin-list.html
new file mode 100644 (file)
index 0000000..66ea1fc
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This test will timeout if we regress style sharing with long cousin list.</title>
+<style>
+td:nth-child(2) {  
+  color: transparent;
+}
+</style>
+</head>
+<body>
+<div id=container></div>
+</body>
+<script>
+if (window.testRunner)
+  testRunner.dumpAsText();
+var table = document.createElement("table");
+for (var i = 0; i < 30000; ++i) {
+  var row = document.createElement("tr");
+  row.appendChild(document.createElement("td"));
+  row.appendChild(document.createElement("td"));
+  table.appendChild(row);
+}
+document.body.appendChild(table);
+document.body.offsetHeight;
+document.body.innerText = "PASSED.";
+</script>
+</html>
\ No newline at end of file
index bf348c4..92eee2e 100644 (file)
@@ -1467,3 +1467,5 @@ webkit.org/b/127116 [ Debug ] svg/custom/animate-initial-pause-unpause.html [ Pa
 # rdar://problem/28586837
 fast/text/variations/order.html [ Crash ]
 animations/font-variation-settings-order.html [ Crash ]
+
+[ Debug ] fast/selectors/slow-style-sharing-with-long-cousin-list.html [ Skip ]
index 60314ac..9cad8b7 100644 (file)
@@ -1,3 +1,23 @@
+2016-10-07  Zalan Bujtas  <zalan@apple.com>
+
+        https://vuldb.com/?cvssv3.2012 takes long time to load.
+        https://bugs.webkit.org/show_bug.cgi?id=162994
+        <rdar://problem/28593746>
+
+        Reviewed by Darin Adler.
+
+        Stop visiting cousins when we hit the style sharing search threshold.
+
+        In addition to mistakenly ignoring the threshold at SharingResolver::findSibling(), we
+        continued on searching for cousin elements. 
+
+        Test: fast/selectors/slow-style-sharing-with-long-cousin-list.html
+
+        * style/StyleSharingResolver.cpp:
+        (WebCore::Style::SharingResolver::resolve):
+        (WebCore::Style::SharingResolver::findSibling):
+        (WebCore::Style::SharingResolver::locateCousinList):
+
 2016-10-07  Romain Bellessort  <romain.bellessort@crf.canon.fr>
 
         [Readable Streams API] Implement generic reader functions
index 241012d..0178bfd 100644 (file)
@@ -115,6 +115,8 @@ std::unique_ptr<RenderStyle> SharingResolver::resolve(const Element& searchEleme
         shareElement = findSibling(context, cousinList, count);
         if (shareElement)
             break;
+        if (count >= cStyleSearchThreshold)
+            break;
         cousinList = locateCousinList(cousinList->parentElement());
     }
 
@@ -144,7 +146,7 @@ StyledElement* SharingResolver::findSibling(const Context& context, Node* node,
             continue;
         if (canShareStyleWithElement(context, downcast<StyledElement>(*node)))
             break;
-        if (count++ == cStyleSearchThreshold)
+        if (count++ >= cStyleSearchThreshold)
             return nullptr;
     }
     return downcast<StyledElement>(node);
@@ -152,8 +154,7 @@ StyledElement* SharingResolver::findSibling(const Context& context, Node* node,
 
 Node* SharingResolver::locateCousinList(const Element* parent) const
 {
-    const unsigned maximumSearchCount = 10;
-    for (unsigned count = 0; count < maximumSearchCount; ++count) {
+    for (unsigned count = 0; count < cStyleSearchThreshold; ++count) {
         auto* elementSharingParentStyle = m_elementsSharingStyle.get(parent);
         if (!elementSharingParentStyle)
             return nullptr;