Title: [288940] trunk/Source/WebKit
Revision
288940
Author
simon.fra...@apple.com
Date
2022-02-01 21:00:13 -0800 (Tue, 01 Feb 2022)

Log Message

Share more WebPage code related to marking layers volatile
https://bugs.webkit.org/show_bug.cgi?id=235985

Reviewed by Chris Dumez.

Factor code common between WebPage::layerVolatilityTimerFired() and WebPage::markLayersVolatile()
into a helper function, using an enum for the "stop reason" to allow for descriptive logging.

No behavior change.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::markLayersVolatileImmediatelyIfPossible):
(WebKit::WebPage::layerVolatilityTimerFired):
(WebKit::WebPage::markLayersVolatile):
(WebKit::WebPage::markLayersVolatileOrRetry):
* WebProcess/WebPage/WebPage.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (288939 => 288940)


--- trunk/Source/WebKit/ChangeLog	2022-02-02 04:04:26 UTC (rev 288939)
+++ trunk/Source/WebKit/ChangeLog	2022-02-02 05:00:13 UTC (rev 288940)
@@ -1,3 +1,22 @@
+2022-02-01  Simon Fraser  <simon.fra...@apple.com>
+
+        Share more WebPage code related to marking layers volatile
+        https://bugs.webkit.org/show_bug.cgi?id=235985
+
+        Reviewed by Chris Dumez.
+
+        Factor code common between WebPage::layerVolatilityTimerFired() and WebPage::markLayersVolatile()
+        into a helper function, using an enum for the "stop reason" to allow for descriptive logging.
+
+        No behavior change.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::markLayersVolatileImmediatelyIfPossible):
+        (WebKit::WebPage::layerVolatilityTimerFired):
+        (WebKit::WebPage::markLayersVolatile):
+        (WebKit::WebPage::markLayersVolatileOrRetry):
+        * WebProcess/WebPage/WebPage.h:
+
 2022-02-01  Chris Dumez  <cdu...@apple.com>
 
         Rename ServiceWorkerFetchResult to WorkerFetchResult and make it more generic

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (288939 => 288940)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2022-02-02 04:04:26 UTC (rev 288939)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2022-02-02 05:00:13 UTC (rev 288940)
@@ -2819,6 +2819,11 @@
     m_drawingArea->setLayerTreeStateIsFrozen(!!m_layerTreeFreezeReasons);
 }
 
+bool WebPage::markLayersVolatileImmediatelyIfPossible()
+{
+    return !drawingArea() || drawingArea()->markLayersVolatileImmediatelyIfPossible();
+}
+
 void WebPage::callVolatilityCompletionHandlers(bool succeeded)
 {
     auto completionHandlers = std::exchange(m_markLayersAsVolatileCompletionHandlers, { });
@@ -2829,26 +2834,9 @@
 void WebPage::layerVolatilityTimerFired()
 {
     Seconds newInterval = m_layerVolatilityTimer.repeatInterval() * 2.;
-    bool didSucceed = markLayersVolatileImmediatelyIfPossible();
-    if (didSucceed || newInterval > maximumLayerVolatilityTimerInterval) {
-        m_layerVolatilityTimer.stop();
-        if (didSucceed)
-            WEBPAGE_RELEASE_LOG(Layers, "layerVolatilityTimerFired: Succeeded in marking layers as volatile");
-        else
-            WEBPAGE_RELEASE_LOG(Layers, "layerVolatilityTimerFired: Failed to mark layers as volatile within %gms", maximumLayerVolatilityTimerInterval.milliseconds());
-        callVolatilityCompletionHandlers(didSucceed);
-        return;
-    }
-
-    WEBPAGE_RELEASE_LOG_ERROR(Layers, "layerVolatilityTimerFired: Failed to mark all layers as volatile, will retry in %g ms", newInterval.milliseconds());
-    m_layerVolatilityTimer.startRepeating(newInterval);
+    markLayersVolatileOrRetry(newInterval > maximumLayerVolatilityTimerInterval ? MarkLayersVolatileDontRetryReason::TimedOut : MarkLayersVolatileDontRetryReason::None, newInterval);
 }
 
-bool WebPage::markLayersVolatileImmediatelyIfPossible()
-{
-    return !drawingArea() || drawingArea()->markLayersVolatileImmediatelyIfPossible();
-}
-
 void WebPage::markLayersVolatile(CompletionHandler<void(bool)>&& completionHandler)
 {
     WEBPAGE_RELEASE_LOG(Layers, "markLayersVolatile:");
@@ -2859,20 +2847,34 @@
     if (completionHandler)
         m_markLayersAsVolatileCompletionHandlers.append(WTFMove(completionHandler));
 
+    markLayersVolatileOrRetry(m_isSuspendedUnderLock ? MarkLayersVolatileDontRetryReason::SuspendedUnderLock : MarkLayersVolatileDontRetryReason::None, initialLayerVolatilityTimerInterval);
+}
+
+void WebPage::markLayersVolatileOrRetry(MarkLayersVolatileDontRetryReason dontRetryReason, Seconds timerInterval)
+{
     bool didSucceed = markLayersVolatileImmediatelyIfPossible();
-    if (didSucceed || m_isSuspendedUnderLock) {
+    if (didSucceed || dontRetryReason != MarkLayersVolatileDontRetryReason::None) {
+        m_layerVolatilityTimer.stop();
         if (didSucceed)
-            WEBPAGE_RELEASE_LOG(Layers, "markLayersVolatile: Successfully marked layers as volatile");
+            WEBPAGE_RELEASE_LOG(Layers, "markLayersVolatile: Succeeded in marking layers as volatile");
         else {
-            // If we get suspended when locking the screen, it is expected that some IOSurfaces cannot be marked as purgeable so we do not keep retrying.
-            WEBPAGE_RELEASE_LOG(Layers, "markLayersVolatile: Did what we could to mark IOSurfaces as purgeable after locking the screen");
+            switch (dontRetryReason) {
+            case MarkLayersVolatileDontRetryReason::None:
+                break;
+            case MarkLayersVolatileDontRetryReason::SuspendedUnderLock:
+                WEBPAGE_RELEASE_LOG(Layers, "markLayersVolatile: Did what we could to mark IOSurfaces as purgeable after locking the screen");
+                break;
+            case MarkLayersVolatileDontRetryReason::TimedOut:
+                WEBPAGE_RELEASE_LOG(Layers, "markLayersVolatile: Failed to mark layers as volatile within %gms", maximumLayerVolatilityTimerInterval.milliseconds());
+                break;
+            }
         }
         callVolatilityCompletionHandlers(didSucceed);
         return;
     }
 
-    WEBPAGE_RELEASE_LOG(Layers, "markLayersVolatile: Failed to mark all layers as volatile, will retry in %g ms", initialLayerVolatilityTimerInterval.milliseconds());
-    m_layerVolatilityTimer.startRepeating(initialLayerVolatilityTimerInterval);
+    WEBPAGE_RELEASE_LOG(Layers, "markLayersVolatile: Failed to mark all layers as volatile, will retry in %g ms", timerInterval.milliseconds());
+    m_layerVolatilityTimer.startRepeating(timerInterval);
 }
 
 void WebPage::cancelMarkLayersVolatile()

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (288939 => 288940)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2022-02-02 04:04:26 UTC (rev 288939)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2022-02-02 05:00:13 UTC (rev 288940)
@@ -1588,7 +1588,10 @@
     void testProcessIncomingSyncMessagesWhenWaitingForSyncReply(Messages::WebPage::TestProcessIncomingSyncMessagesWhenWaitingForSyncReplyDelayedReply&&);
 
     void updateDrawingAreaLayerTreeFreezeState();
+
     bool markLayersVolatileImmediatelyIfPossible();
+    enum class MarkLayersVolatileDontRetryReason : uint8_t { None, SuspendedUnderLock, TimedOut };
+    void markLayersVolatileOrRetry(MarkLayersVolatileDontRetryReason, Seconds timerInterval);
     void layerVolatilityTimerFired();
     void callVolatilityCompletionHandlers(bool succeeded);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to