Add logging to identify when the Page suspends scripted animations
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Jun 2017 18:37:02 +0000 (18:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Jun 2017 18:37:02 +0000 (18:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173626

Patch by Antoine Quint <graouts@apple.com> on 2017-06-21
Reviewed by Tim Horton.

Source/WebCore:

We have a longstanding issue that some media/modern-media-controls tests time out due to
requestAnimationFrame callbacks not being serviced, which is tracked by webkit.org/b/173628.
We added some logging to identify when ScriptedAnimationController would get suspended in
webkit.org/b/173326. This logging points to the fact that the reason rAF callbacks aren't
serviced is because Document::requestAnimationFrame() suspends rAF when the page reports
that scripted animations ought to be suspended, which is true when m_scriptedAnimationsSuspended
is true. This patch adds logging that tracks when this flag is set, provided a new setting
shouldLogScriptedAnimationControllerSuspensionChange is true.

* dom/ScriptedAnimationController.cpp:
(WebCore::ScriptedAnimationController::logSuspendCount):
* page/Page.cpp:
(WebCore::Page::suspendScriptedAnimations):
(WebCore::Page::resumeScriptedAnimations):
* page/Settings.in:

Source/WebKit/mac:

Add a new preference to control the new shouldLogScriptedAnimationControllerSuspensionChange settings
through WebKit. This is specific to WK1 since the issue we're trying to pinpoint only occurs on WK1 bots.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences shouldLogScriptedAnimationControllerSuspensionChange]):
(-[WebPreferences setShouldLogScriptedAnimationControllerSuspensionChange:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Tools:

Turn the new logging on for WK1/DRT since the issue we're trying to pinpoint only occurs on WK1 bots.

* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebPreferencesToConsistentValues):

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

Source/WebCore/ChangeLog
Source/WebCore/dom/ScriptedAnimationController.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/Settings.in
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKit/mac/WebView/WebPreferences.mm
Source/WebKit/mac/WebView/WebPreferencesPrivate.h
Source/WebKit/mac/WebView/WebView.mm
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm

index fd45444..ba8590e 100644 (file)
@@ -1,3 +1,26 @@
+2017-06-21  Antoine Quint  <graouts@apple.com>
+
+        Add logging to identify when the Page suspends scripted animations
+        https://bugs.webkit.org/show_bug.cgi?id=173626
+
+        Reviewed by Tim Horton.
+
+        We have a longstanding issue that some media/modern-media-controls tests time out due to
+        requestAnimationFrame callbacks not being serviced, which is tracked by webkit.org/b/173628.
+        We added some logging to identify when ScriptedAnimationController would get suspended in
+        webkit.org/b/173326. This logging points to the fact that the reason rAF callbacks aren't
+        serviced is because Document::requestAnimationFrame() suspends rAF when the page reports
+        that scripted animations ought to be suspended, which is true when m_scriptedAnimationsSuspended
+        is true. This patch adds logging that tracks when this flag is set, provided a new setting
+        shouldLogScriptedAnimationControllerSuspensionChange is true.
+
+        * dom/ScriptedAnimationController.cpp:
+        (WebCore::ScriptedAnimationController::logSuspendCount):
+        * page/Page.cpp:
+        (WebCore::Page::suspendScriptedAnimations):
+        (WebCore::Page::resumeScriptedAnimations):
+        * page/Settings.in:
+
 2017-06-21  Basuke Suzuki  <Basuke.Suzuki@sony.com>
 
         [Curl] Extract CurlDownloadManager as shared background task handler
index aa6342b..174cc01 100644 (file)
@@ -93,10 +93,11 @@ void ScriptedAnimationController::resume()
 
 void ScriptedAnimationController::logSuspendCount()
 {
-#if !defined(NDEBUG)
-    WTFLogAlways("ScriptedAnimationController::m_suspendCount = %d", m_suspendCount);
+    if (!m_document || !m_document->frame() || !m_document->frame()->settings().shouldLogScriptedAnimationControllerSuspensionChange())
+        return;
+
+    WTFLogAlways("\nScriptedAnimationController::m_suspendCount = %d", m_suspendCount);
     WTFReportBacktrace();
-#endif
 }
 
 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) && !RELEASE_LOG_DISABLED
index 74a19e8..16a04cd 100644 (file)
@@ -1145,6 +1145,11 @@ void Page::removeActivityStateChangeObserver(ActivityStateChangeObserver& observ
 
 void Page::suspendScriptedAnimations()
 {
+    if (settings().shouldLogScriptedAnimationControllerSuspensionChange()) {
+        WTFLogAlways("\nPage::suspendScriptedAnimations()");
+        WTFReportBacktrace();
+    }
+
     m_scriptedAnimationsSuspended = true;
     for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
         if (frame->document())
@@ -1154,6 +1159,11 @@ void Page::suspendScriptedAnimations()
 
 void Page::resumeScriptedAnimations()
 {
+    if (settings().shouldLogScriptedAnimationControllerSuspensionChange()) {
+        WTFLogAlways("\nPage::resumeScriptedAnimations()");
+        WTFReportBacktrace();
+    }
+
     m_scriptedAnimationsSuspended = false;
     for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
         if (frame->document())
index 29f4385..b5080e2 100644 (file)
@@ -299,3 +299,5 @@ subresourceIntegrityEnabled initial=true
 constantPropertiesEnabled initial=false
 
 viewportFitEnabled initial=false
+
+shouldLogScriptedAnimationControllerSuspensionChange initial=false
index 00bbf4b..daa9c48 100644 (file)
@@ -1,3 +1,22 @@
+2017-06-21  Antoine Quint  <graouts@apple.com>
+
+        Add logging to identify when the Page suspends scripted animations
+        https://bugs.webkit.org/show_bug.cgi?id=173626
+
+        Reviewed by Tim Horton.
+
+        Add a new preference to control the new shouldLogScriptedAnimationControllerSuspensionChange settings
+        through WebKit. This is specific to WK1 since the issue we're trying to pinpoint only occurs on WK1 bots.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences shouldLogScriptedAnimationControllerSuspensionChange]):
+        (-[WebPreferences setShouldLogScriptedAnimationControllerSuspensionChange:]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2017-06-20  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Disable font variations on macOS Sierra and iOS 10
index 08ee13f..7da4ab2 100644 (file)
 #define WebKitUserTimingEnabledPreferenceKey @"WebKitUserTimingEnabled"
 #define WebKitResourceTimingEnabledPreferenceKey @"WebKitResourceTimingEnabled"
 #define WebKitMediaContentTypesRequiringHardwareSupportPreferenceKey @"WebKitMediaContentTypesRequiringHardwareSupport"
+#define WebKitShouldLogScriptedAnimationControllerSuspensionChangePreferenceKey @"WebKitShouldLogScriptedAnimationControllerSuspensionChange"
index a6e2357..b498ba0 100644 (file)
@@ -671,6 +671,7 @@ public:
         @NO, WebKitMediaUserGestureInheritsFromDocument,
         @NO, WebKitIsSecureContextAttributeEnabledPreferenceKey,
         (NSString *)Settings::defaultMediaContentTypesRequiringHardwareSupport(), WebKitMediaContentTypesRequiringHardwareSupportPreferenceKey,
+        @NO, WebKitShouldLogScriptedAnimationControllerSuspensionChangePreferenceKey,
         nil];
 
 #if !PLATFORM(IOS)
@@ -3137,6 +3138,16 @@ static NSString *classIBCreatorID = nil;
     [self _setBoolValue:flag forKey:WebKitIsSecureContextAttributeEnabledPreferenceKey];
 }
 
+- (BOOL)shouldLogScriptedAnimationControllerSuspensionChange
+{
+    return [self _boolValueForKey:WebKitShouldLogScriptedAnimationControllerSuspensionChangePreferenceKey];
+}
+
+- (void)setShouldLogScriptedAnimationControllerSuspensionChange:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitShouldLogScriptedAnimationControllerSuspensionChangePreferenceKey];
+}
+
 @end
 
 @implementation WebPreferences (WebInternal)
index ee1695a..a97c6cc 100644 (file)
@@ -584,4 +584,7 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification;
 
 @property (nonatomic) NSString *mediaContentTypesRequiringHardwareSupport;
 
+- (void)setShouldLogScriptedAnimationControllerSuspensionChange:(BOOL)flag;
+- (BOOL)shouldLogScriptedAnimationControllerSuspensionChange;
+
 @end
index 3a7155d..7429c10 100644 (file)
@@ -2846,6 +2846,7 @@ static bool needsSelfRetainWhileLoadingQuirk()
 
     settings.setVisualViewportEnabled([preferences visualViewportEnabled]);
     settings.setMediaContentTypesRequiringHardwareSupport([preferences mediaContentTypesRequiringHardwareSupport]);
+    settings.setShouldLogScriptedAnimationControllerSuspensionChange([preferences shouldLogScriptedAnimationControllerSuspensionChange]);
 
     switch ([preferences storageBlockingPolicy]) {
     case WebAllowAllStorage:
index 92beaaf..86769a0 100644 (file)
@@ -1,3 +1,15 @@
+2017-06-21  Antoine Quint  <graouts@apple.com>
+
+        Add logging to identify when the Page suspends scripted animations
+        https://bugs.webkit.org/show_bug.cgi?id=173626
+
+        Reviewed by Tim Horton.
+
+        Turn the new logging on for WK1/DRT since the issue we're trying to pinpoint only occurs on WK1 bots.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (resetWebPreferencesToConsistentValues):
+
 2017-06-21  Chris Fleizach  <cfleizach@apple.com>
 
         AX: Cannot call setValue() on contenteditable or ARIA text controls
index 523f3f3..a18b250 100644 (file)
@@ -966,6 +966,8 @@ static void resetWebPreferencesToConsistentValues()
     [preferences setResourceTimingEnabled:YES];
     [preferences setUserTimingEnabled:YES];
 
+    [preferences setShouldLogScriptedAnimationControllerSuspensionChange:YES];
+
     [WebPreferences _clearNetworkLoaderSession];
     [WebPreferences _setCurrentNetworkLoaderSessionCookieAcceptPolicy:NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain];
 }