Title: [258268] trunk
Revision
258268
Author
[email protected]
Date
2020-03-11 10:30:48 -0700 (Wed, 11 Mar 2020)

Log Message

Defer async scripts until DOMContentLoaded or first paint, whichever comes first
https://bugs.webkit.org/show_bug.cgi?id=208896

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebbaseline WPT test due to script execution timing change.

* web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/085-expected.txt:

Source/WebCore:

Defer async scripts until DOMContentLoaded or first paint, whichever comes first. In
Bug 207698, we deferred them until DOMContentLoaded, as a first-paint optimization.
However, this seems overly aggressive on pages like wikipedia and it is sufficient
to defer those scripts until first-paint to get the performance win.

* dom/Document.cpp:
(WebCore::Document::shouldDeferAsynchronousScriptsUntilParsingFinishes const):
* page/Settings.yaml:

Source/WebKit:

Defer async scripts until DOMContentLoaded or first paint, whichever comes first. In
Bug 207698, we deferred them until DOMContentLoaded, as a first-paint optimization.
However, this seems overly aggressive on pages like wikipedia and it is sufficient
to defer those scripts until first-paint to get the performance win.

* Shared/WebPreferences.yaml:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _setupPageConfiguration:]):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (258267 => 258268)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-03-11 17:05:28 UTC (rev 258267)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-03-11 17:30:48 UTC (rev 258268)
@@ -1,3 +1,14 @@
+2020-03-11  Chris Dumez  <[email protected]>
+
+        Defer async scripts until DOMContentLoaded or first paint, whichever comes first
+        https://bugs.webkit.org/show_bug.cgi?id=208896
+
+        Reviewed by Darin Adler.
+
+        Rebbaseline WPT test due to script execution timing change.
+
+        * web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/085-expected.txt:
+
 2020-03-10  Rob Buis  <[email protected]>
 
         Align with Origin header changes

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/085-expected.txt (258267 => 258268)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/085-expected.txt	2020-03-11 17:05:28 UTC (rev 258267)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/085-expected.txt	2020-03-11 17:30:48 UTC (rev 258268)
@@ -1,4 +1,4 @@
 FAILED (This TC requires _javascript_ enabled)
 
-FAIL  scheduler: async script and slow-loading defer script assert_array_equals: property 0, expected "external script #2" but got "external script #1"
+PASS  scheduler: async script and slow-loading defer script 
 

Copied: trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/085-expected.txt (from rev 258267, trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/085-expected.txt) (0 => 258268)


--- trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/085-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/085-expected.txt	2020-03-11 17:30:48 UTC (rev 258268)
@@ -0,0 +1,4 @@
+FAILED (This TC requires _javascript_ enabled)
+
+FAIL  scheduler: async script and slow-loading defer script assert_array_equals: property 0, expected "external script #2" but got "external script #1"
+

Modified: trunk/Source/WebCore/ChangeLog (258267 => 258268)


--- trunk/Source/WebCore/ChangeLog	2020-03-11 17:05:28 UTC (rev 258267)
+++ trunk/Source/WebCore/ChangeLog	2020-03-11 17:30:48 UTC (rev 258268)
@@ -1,3 +1,19 @@
+2020-03-11  Chris Dumez  <[email protected]>
+
+        Defer async scripts until DOMContentLoaded or first paint, whichever comes first
+        https://bugs.webkit.org/show_bug.cgi?id=208896
+
+        Reviewed by Darin Adler.
+
+        Defer async scripts until DOMContentLoaded or first paint, whichever comes first. In
+        Bug 207698, we deferred them until DOMContentLoaded, as a first-paint optimization.
+        However, this seems overly aggressive on pages like wikipedia and it is sufficient
+        to defer those scripts until first-paint to get the performance win.
+
+        * dom/Document.cpp:
+        (WebCore::Document::shouldDeferAsynchronousScriptsUntilParsingFinishes const):
+        * page/Settings.yaml:
+
 2020-03-11  Jack Lee  <[email protected]>
 
         Consolidate detachment of document timeline into Document::commonTeardown.

Modified: trunk/Source/WebCore/dom/Document.cpp (258267 => 258268)


--- trunk/Source/WebCore/dom/Document.cpp	2020-03-11 17:05:28 UTC (rev 258267)
+++ trunk/Source/WebCore/dom/Document.cpp	2020-03-11 17:30:48 UTC (rev 258268)
@@ -5524,7 +5524,10 @@
 
 bool Document::shouldDeferAsynchronousScriptsUntilParsingFinishes() const
 {
-    return parsing() && settings().shouldDeferAsynchronousScriptsUntilAfterDocumentLoad();
+    if (!settings().shouldDeferAsynchronousScriptsUntilAfterDocumentLoadOrFirstPaint())
+        return false;
+
+    return parsing() && !(view() && view()->hasEverPainted());
 }
 
 #if ENABLE(XSLT)

Modified: trunk/Source/WebCore/page/Settings.yaml (258267 => 258268)


--- trunk/Source/WebCore/page/Settings.yaml	2020-03-11 17:05:28 UTC (rev 258267)
+++ trunk/Source/WebCore/page/Settings.yaml	2020-03-11 17:30:48 UTC (rev 258268)
@@ -858,7 +858,7 @@
 incompleteImageBorderEnabled:
   initial: false
 
-shouldDeferAsynchronousScriptsUntilAfterDocumentLoad:
+shouldDeferAsynchronousScriptsUntilAfterDocumentLoadOrFirstPaint:
   initial: true
 
 shouldIgnoreMetaViewport:

Modified: trunk/Source/WebKit/ChangeLog (258267 => 258268)


--- trunk/Source/WebKit/ChangeLog	2020-03-11 17:05:28 UTC (rev 258267)
+++ trunk/Source/WebKit/ChangeLog	2020-03-11 17:30:48 UTC (rev 258268)
@@ -1,3 +1,19 @@
+2020-03-11  Chris Dumez  <[email protected]>
+
+        Defer async scripts until DOMContentLoaded or first paint, whichever comes first
+        https://bugs.webkit.org/show_bug.cgi?id=208896
+
+        Reviewed by Darin Adler.
+
+        Defer async scripts until DOMContentLoaded or first paint, whichever comes first. In
+        Bug 207698, we deferred them until DOMContentLoaded, as a first-paint optimization.
+        However, this seems overly aggressive on pages like wikipedia and it is sufficient
+        to defer those scripts until first-paint to get the performance win.
+
+        * Shared/WebPreferences.yaml:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _setupPageConfiguration:]):
+
 2020-03-11  Commit Queue  <[email protected]>
 
         Unreviewed, reverting r258263.

Modified: trunk/Source/WebKit/Shared/WebPreferences.yaml (258267 => 258268)


--- trunk/Source/WebKit/Shared/WebPreferences.yaml	2020-03-11 17:05:28 UTC (rev 258267)
+++ trunk/Source/WebKit/Shared/WebPreferences.yaml	2020-03-11 17:30:48 UTC (rev 258268)
@@ -1207,9 +1207,12 @@
   type: bool
   defaultValue: false
 
-ShouldDeferAsynchronousScriptsUntilAfterDocumentLoad:
+ShouldDeferAsynchronousScriptsUntilAfterDocumentLoadOrFirstPaint:
   type: bool
-  defaultValue: false
+  defaultValue: true
+  humanReadableName: "Defer async scripts until DOMContentLoaded or first-paint"
+  humanReadableDescription: "Defer async scripts until DOMContentLoaded or first-paint"
+  category: experimental
 
 StorageAccessAPIEnabled:
   type: bool

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (258267 => 258268)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-03-11 17:05:28 UTC (rev 258267)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-03-11 17:30:48 UTC (rev 258268)
@@ -454,7 +454,7 @@
     pageConfiguration->setDrawsBackground([_configuration _drawsBackground]);
     pageConfiguration->setControlledByAutomation([_configuration _isControlledByAutomation]);
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::incompleteImageBorderEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _incompleteImageBorderEnabled]));
-    pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::shouldDeferAsynchronousScriptsUntilAfterDocumentLoadKey(), WebKit::WebPreferencesStore::Value(!![_configuration _shouldDeferAsynchronousScriptsUntilAfterDocumentLoad]));
+    pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::shouldDeferAsynchronousScriptsUntilAfterDocumentLoadOrFirstPaintKey(), WebKit::WebPreferencesStore::Value(!![_configuration _shouldDeferAsynchronousScriptsUntilAfterDocumentLoad]));
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::shouldRestrictBaseURLSchemesKey(), WebKit::WebPreferencesStore::Value(shouldRestrictBaseURLSchemes()));
 
 #if PLATFORM(MAC)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to