Title: [225818] trunk/Source/WebKit
Revision
225818
Author
[email protected]
Date
2017-12-12 15:54:34 -0800 (Tue, 12 Dec 2017)

Log Message

Dispatch resource load statistics telemetry on the main thread
https://bugs.webkit.org/show_bug.cgi?id=180602
<rdar://problem/35942205>

Reviewed by Brent Fulgham.

* UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
(WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
    Now switches to the main thread for the telemetry submission
    through a webpage proxy. The reason is that the webpage we
    use may go away while we're still using it. This kind of
    telemetry isn't associated with a specific webpage but the
    infrastructure requires a webpage proxy.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (225817 => 225818)


--- trunk/Source/WebKit/ChangeLog	2017-12-12 23:41:26 UTC (rev 225817)
+++ trunk/Source/WebKit/ChangeLog	2017-12-12 23:54:34 UTC (rev 225818)
@@ -1,3 +1,19 @@
+2017-12-12  John Wilander  <[email protected]>
+
+        Dispatch resource load statistics telemetry on the main thread
+        https://bugs.webkit.org/show_bug.cgi?id=180602
+        <rdar://problem/35942205>
+
+        Reviewed by Brent Fulgham.
+
+        * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
+        (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
+            Now switches to the main thread for the telemetry submission
+            through a webpage proxy. The reason is that the webpage we
+            use may go away while we're still using it. This kind of
+            telemetry isn't associated with a specific webpage but the
+            infrastructure requires a webpage proxy.
+
 2017-12-12  Myles C. Maxfield  <[email protected]>
 
         IPC code doesn't understand NSDictionaries with non-NSString keys

Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsTelemetry.cpp (225817 => 225818)


--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsTelemetry.cpp	2017-12-12 23:41:26 UTC (rev 225817)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsTelemetry.cpp	2017-12-12 23:54:34 UTC (rev 225818)
@@ -246,28 +246,31 @@
             sortedPrevalentResourcesWithoutUserInteraction.uncheckedAppend(prevalentResource);
     }
     
-    auto webPageProxy = nonEphemeralWebPageProxy();
-    if (!webPageProxy) {
-        if (notifyPagesWhenTelemetryWasCaptured)
-            notifyPages(0, 0, 0);
-        return;
-    }
-    
-    if (notifyPagesWhenTelemetryWasCaptured) {
-        notifyPages(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, prevalentResourcesDaysSinceUserInteraction.size());
-        // The notify pages function is for testing so we don't need to do an actual submission.
-        return;
-    }
-    
-    webPageProxy->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), ASCIILiteral("totalNumberOfPrevalentResources"), sortedPrevalentResources.size(), significantFiguresForLoggedValues, ShouldSample::No);
-    webPageProxy->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), ASCIILiteral("totalNumberOfPrevalentResourcesWithUserInteraction"), prevalentResourcesDaysSinceUserInteraction.size(), significantFiguresForLoggedValues, ShouldSample::No);
-    
-    if (prevalentResourcesDaysSinceUserInteraction.size() > 0)
-        webPageProxy->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), ASCIILiteral("topPrevalentResourceWithUserInteractionDaysSinceUserInteraction"), prevalentResourcesDaysSinceUserInteraction[0], significantFiguresForLoggedValues, ShouldSample::No);
-    if (prevalentResourcesDaysSinceUserInteraction.size() > 1)
-        webPageProxy->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), ASCIILiteral("medianPrevalentResourcesWithUserInteractionDaysSinceUserInteraction"), median(prevalentResourcesDaysSinceUserInteraction), significantFiguresForLoggedValues, ShouldSample::No);
-    
-    submitTopLists(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, *webPageProxy);
+    // Dispatch on the main thread to make sure the WebPageProxy we're using doesn't go away.
+    RunLoop::main().dispatch([sortedPrevalentResources = WTFMove(sortedPrevalentResources), sortedPrevalentResourcesWithoutUserInteraction = WTFMove(sortedPrevalentResourcesWithoutUserInteraction), prevalentResourcesDaysSinceUserInteraction = WTFMove(prevalentResourcesDaysSinceUserInteraction)] () {
+        auto webPageProxy = nonEphemeralWebPageProxy();
+        if (!webPageProxy) {
+            if (notifyPagesWhenTelemetryWasCaptured)
+                notifyPages(0, 0, 0);
+            return;
+        }
+        
+        if (notifyPagesWhenTelemetryWasCaptured) {
+            notifyPages(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, prevalentResourcesDaysSinceUserInteraction.size());
+            // The notify pages function is for testing so we don't need to do an actual submission.
+            return;
+        }
+        
+        webPageProxy->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), ASCIILiteral("totalNumberOfPrevalentResources"), sortedPrevalentResources.size(), significantFiguresForLoggedValues, ShouldSample::No);
+        webPageProxy->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), ASCIILiteral("totalNumberOfPrevalentResourcesWithUserInteraction"), prevalentResourcesDaysSinceUserInteraction.size(), significantFiguresForLoggedValues, ShouldSample::No);
+        
+        if (prevalentResourcesDaysSinceUserInteraction.size() > 0)
+            webPageProxy->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), ASCIILiteral("topPrevalentResourceWithUserInteractionDaysSinceUserInteraction"), prevalentResourcesDaysSinceUserInteraction[0], significantFiguresForLoggedValues, ShouldSample::No);
+        if (prevalentResourcesDaysSinceUserInteraction.size() > 1)
+            webPageProxy->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), ASCIILiteral("medianPrevalentResourcesWithUserInteractionDaysSinceUserInteraction"), median(prevalentResourcesDaysSinceUserInteraction), significantFiguresForLoggedValues, ShouldSample::No);
+        
+        submitTopLists(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, *webPageProxy);
+    });
 }
     
 void WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(bool always)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to