Changeset 247190 in webkit


Ignore:
Timestamp:
Jul 5, 2019 5:33:44 PM (5 years ago)
Author:
Chris Dumez
Message:

Fix thread safety bug in WebResourceLoadStatisticsTelemetry::calculateAndSubmit()
https://bugs.webkit.org/show_bug.cgi?id=199536

Reviewed by Youenn Fablet.

The resourceLoadStatisticsStore is an object that is created / used / destroyed on the background
queue. It is therefore not safe to create a WeakPtr for it and use that WeakPtr on the main thread.

  • NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp:

(WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r247188 r247190  
     12019-07-05  Chris Dumez  <cdumez@apple.com>
     2
     3        Fix thread safety bug in WebResourceLoadStatisticsTelemetry::calculateAndSubmit()
     4        https://bugs.webkit.org/show_bug.cgi?id=199536
     5
     6        Reviewed by Youenn Fablet.
     7
     8        The resourceLoadStatisticsStore is an object that is created / used / destroyed on the background
     9        queue. It is therefore not safe to create a WeakPtr for it and use that WeakPtr on the main thread.
     10
     11        * NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp:
     12        (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
     13
    1142019-07-05  Michael Catanzaro  <mcatanzaro@igalia.com>
    215
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp

    r246034 r247190  
    239239   
    240240    // Dispatch on the main thread to make sure the WebPageProxy we're using doesn't go away.
    241     RunLoop::main().dispatch([sortedPrevalentResources = WTFMove(sortedPrevalentResources), sortedPrevalentResourcesWithoutUserInteraction = WTFMove(sortedPrevalentResourcesWithoutUserInteraction), prevalentResourcesDaysSinceUserInteraction = WTFMove(prevalentResourcesDaysSinceUserInteraction), resourceLoadStatisticsStore = makeWeakPtr(resourceLoadStatisticsStore)] () {
    242         if (!resourceLoadStatisticsStore)
    243             return;
    244 
     241    RunLoop::main().dispatch([sortedPrevalentResources = WTFMove(sortedPrevalentResources), sortedPrevalentResourcesWithoutUserInteraction = WTFMove(sortedPrevalentResourcesWithoutUserInteraction), prevalentResourcesDaysSinceUserInteraction = WTFMove(prevalentResourcesDaysSinceUserInteraction), store = makeRef(resourceLoadStatisticsStore.store())] () {
    245242        auto webPageProxy = WebPageProxy::nonEphemeralWebPageProxy();
    246243        if (!webPageProxy) {
    247244            if (notifyPagesWhenTelemetryWasCaptured)
    248                 notifyPages(0, 0, 0, resourceLoadStatisticsStore->store());
     245                notifyPages(0, 0, 0, store);
    249246            return;
    250247        }
    251248       
    252249        if (notifyPagesWhenTelemetryWasCaptured) {
    253             notifyPages(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, prevalentResourcesDaysSinceUserInteraction.size(), resourceLoadStatisticsStore->store());
     250            notifyPages(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, prevalentResourcesDaysSinceUserInteraction.size(), store);
    254251            // The notify pages function is for testing so we don't need to do an actual submission.
    255252            return;
     
    264261            webPageProxy->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), "medianPrevalentResourcesWithUserInteractionDaysSinceUserInteraction"_s, median(prevalentResourcesDaysSinceUserInteraction), significantFiguresForLoggedValues, ShouldSample::No);
    265262       
    266         submitTopLists(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, resourceLoadStatisticsStore->store());
     263        submitTopLists(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store);
    267264    });
    268265}
Note: See TracChangeset for help on using the changeset viewer.