Diff
Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (227886 => 227887)
--- branches/safari-605-branch/Source/WebCore/ChangeLog 2018-01-31 09:09:31 UTC (rev 227886)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog 2018-01-31 09:09:35 UTC (rev 227887)
@@ -1,5 +1,37 @@
2018-01-31 Jason Marcell <[email protected]>
+ Cherry-pick r227755. rdar://problem/37050332
+
+ 2018-01-29 Brent Fulgham <[email protected]>
+
+ Add telemetry to track storage access API adoption
+ https://bugs.webkit.org/show_bug.cgi?id=182197
+ <rdar://problem/35803309>
+
+ Reviewed by Chris Dumez.
+
+ Part 1: Add telemetry for the user interaction case
+
+ This patch adds telemetry to track how frequently third-party cookies are
+ used in a first party context due to user interaction. This will help
+ understand cases where the new Storage Access API can help, and to help
+ us understand if we have considered relevant use cases in its design.
+
+ * loader/ResourceLoadObserver.cpp:
+ (WebCore::ResourceLoadObserver::setTimeToLivePartitionFree): Let the observer
+ know the first party interaction duration.
+ (WebCore::ResourceLoadObserver::wasAccessedWithinInteractionWindow const): Added.
+ (WebCore::ResourceLoadObserver::logFrameNavigation): Note when a third party
+ resource is accessed as a first party due to user interaction.
+ (WebCore::ResourceLoadObserver::logSubresourceLoading): Ditto.
+ * loader/ResourceLoadObserver.h:
+ * loader/ResourceLoadStatistics.cpp:
+ (WebCore::ResourceLoadStatistics::encode const): Handle new fields.
+ (WebCore::ResourceLoadStatistics::decode): Ditto.
+ * loader/ResourceLoadStatistics.h:
+
+2018-01-31 Jason Marcell <[email protected]>
+
Cherry-pick r227858. rdar://problem/37049295
2018-01-30 Ryosuke Niwa <[email protected]>
Modified: branches/safari-605-branch/Source/WebCore/loader/ResourceLoadObserver.cpp (227886 => 227887)
--- branches/safari-605-branch/Source/WebCore/loader/ResourceLoadObserver.cpp 2018-01-31 09:09:31 UTC (rev 227886)
+++ branches/safari-605-branch/Source/WebCore/loader/ResourceLoadObserver.cpp 2018-01-31 09:09:35 UTC (rev 227887)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -132,6 +132,16 @@
return WallTime::fromRawSeconds(std::floor(time.secondsSinceEpoch() / timestampResolution) * timestampResolution.seconds());
}
+void ResourceLoadObserver::setTimeToLivePartitionFree(Seconds value)
+{
+ m_timeToLiveCookiePartitionFree = value;
+}
+
+bool ResourceLoadObserver::wasAccessedWithinInteractionWindow(const ResourceLoadStatistics& statistic) const
+{
+ return WallTime::now() <= statistic.mostRecentUserInteractionTime + m_timeToLiveCookiePartitionFree;
+}
+
void ResourceLoadObserver::logFrameNavigation(const Frame& frame, const Frame& topFrame, const ResourceRequest& newRequest, const URL& redirectUrl)
{
ASSERT(frame.document());
@@ -171,6 +181,8 @@
&& !(areDomainsAssociated(page, targetPrimaryDomain, mainFramePrimaryDomain) || areDomainsAssociated(page, targetPrimaryDomain, sourcePrimaryDomain))) {
auto& targetStatistics = ensureResourceStatisticsForPrimaryDomain(targetPrimaryDomain);
targetStatistics.lastSeen = reduceToHourlyTimeResolution(WallTime::now());
+ if (targetStatistics.hadUserInteraction && wasAccessedWithinInteractionWindow(targetStatistics))
+ targetStatistics.timesAccessedAsFirstPartyDueToUserInteraction++;
if (targetStatistics.subframeUnderTopFrameOrigins.add(mainFramePrimaryDomain).isNewEntry)
shouldCallNotificationCallback = true;
}
@@ -228,6 +240,8 @@
{
auto& targetStatistics = ensureResourceStatisticsForPrimaryDomain(targetPrimaryDomain);
targetStatistics.lastSeen = reduceToHourlyTimeResolution(WallTime::now());
+ if (targetStatistics.hadUserInteraction && wasAccessedWithinInteractionWindow(targetStatistics))
+ targetStatistics.timesAccessedAsFirstPartyDueToUserInteraction++;
if (targetStatistics.subresourceUnderTopFrameOrigins.add(mainFramePrimaryDomain).isNewEntry)
shouldCallNotificationCallback = true;
}
Modified: branches/safari-605-branch/Source/WebCore/loader/ResourceLoadObserver.h (227886 => 227887)
--- branches/safari-605-branch/Source/WebCore/loader/ResourceLoadObserver.h 2018-01-31 09:09:31 UTC (rev 227886)
+++ branches/safari-605-branch/Source/WebCore/loader/ResourceLoadObserver.h 2018-01-31 09:09:35 UTC (rev 227887)
@@ -64,11 +64,14 @@
WEBCORE_EXPORT void notifyObserver();
WEBCORE_EXPORT void clearState();
+ WEBCORE_EXPORT void setTimeToLivePartitionFree(Seconds);
+
private:
ResourceLoadObserver();
bool shouldLog(Page*) const;
ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);
+ bool wasAccessedWithinInteractionWindow(const ResourceLoadStatistics&) const;
void scheduleNotificationIfNeeded();
Vector<ResourceLoadStatistics> takeStatistics();
@@ -77,6 +80,7 @@
HashMap<String, WTF::WallTime> m_lastReportedUserInteractionMap;
WTF::Function<void (Vector<ResourceLoadStatistics>&&)> m_notificationCallback;
Timer m_notificationTimer;
+ Seconds m_timeToLiveCookiePartitionFree { 24_h };
URL nonNullOwnerURL(const Document&) const;
};
Modified: branches/safari-605-branch/Source/WebCore/loader/ResourceLoadStatistics.cpp (227886 => 227887)
--- branches/safari-605-branch/Source/WebCore/loader/ResourceLoadStatistics.cpp 2018-01-31 09:09:31 UTC (rev 227886)
+++ branches/safari-605-branch/Source/WebCore/loader/ResourceLoadStatistics.cpp 2018-01-31 09:09:35 UTC (rev 227887)
@@ -80,6 +80,9 @@
// Prevalent Resource
encoder.encodeBool("isPrevalentResource", isPrevalentResource);
encoder.encodeUInt32("dataRecordsRemoved", dataRecordsRemoved);
+
+ encoder.encodeUInt32("timesAccessedAsFirstPartyDueToUserInteraction", timesAccessedAsFirstPartyDueToUserInteraction);
+ encoder.encodeUInt32("timesAccessedAsFirstPartyDueToStorageAccessAPI", timesAccessedAsFirstPartyDueToStorageAccessAPI);
}
static void decodeHashCountedSet(KeyedDecoder& decoder, const String& label, HashCountedSet<String>& hashCountedSet)
@@ -148,7 +151,12 @@
if (!decoder.decodeDouble("lastSeen", lastSeenTimeAsDouble))
return false;
lastSeen = WallTime::fromRawSeconds(lastSeenTimeAsDouble);
-
+
+ if (!decoder.decodeUInt32("timesAccessedAsFirstPartyDueToUserInteraction", timesAccessedAsFirstPartyDueToUserInteraction))
+ timesAccessedAsFirstPartyDueToUserInteraction = 0;
+ if (!decoder.decodeUInt32("timesAccessedAsFirstPartyDueToStorageAccessAPI", timesAccessedAsFirstPartyDueToStorageAccessAPI))
+ timesAccessedAsFirstPartyDueToStorageAccessAPI = 0;
+
return true;
}
Modified: branches/safari-605-branch/Source/WebCore/loader/ResourceLoadStatistics.h (227886 => 227887)
--- branches/safari-605-branch/Source/WebCore/loader/ResourceLoadStatistics.h 2018-01-31 09:09:31 UTC (rev 227886)
+++ branches/safari-605-branch/Source/WebCore/loader/ResourceLoadStatistics.h 2018-01-31 09:09:35 UTC (rev 227887)
@@ -83,6 +83,8 @@
// Prevalent resource stats
bool isPrevalentResource { false };
unsigned dataRecordsRemoved { 0 };
+ unsigned timesAccessedAsFirstPartyDueToUserInteraction { 0 };
+ unsigned timesAccessedAsFirstPartyDueToStorageAccessAPI { 0 };
// In-memory only
bool isMarkedForCookiePartitioning { false };
Modified: branches/safari-605-branch/Source/WebKit/ChangeLog (227886 => 227887)
--- branches/safari-605-branch/Source/WebKit/ChangeLog 2018-01-31 09:09:31 UTC (rev 227886)
+++ branches/safari-605-branch/Source/WebKit/ChangeLog 2018-01-31 09:09:35 UTC (rev 227887)
@@ -1,5 +1,37 @@
2018-01-31 Jason Marcell <[email protected]>
+ Cherry-pick r227755. rdar://problem/37050332
+
+ 2018-01-29 Brent Fulgham <[email protected]>
+
+ Add telemetry to track storage access API adoption
+ https://bugs.webkit.org/show_bug.cgi?id=182197
+ <rdar://problem/35803309>
+
+ Reviewed by Chris Dumez.
+
+ Part 1: Add telemetry for the user interaction case
+
+ This patch adds telemetry to track how frequently third-party cookies are
+ used in a first party context due to user interaction. This will help
+ understand cases where the new Storage Access API can help, and to help
+ us understand if we have considered relevant use cases in its design.
+
+ * Shared/WebProcessCreationParameters.cpp:
+ (WebKit::WebProcessCreationParameters::encode const):
+ (WebKit::WebProcessCreationParameters::decode):
+ * Shared/WebProcessCreationParameters.h:
+ * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+ (WebKit::WebProcessPool::platformInitializeWebProcess):
+ * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
+ (WebKit::sortedPrevalentResourceTelemetry): Update for new telemetry.
+ (WebKit::submitTopList): Update for new data types.
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::initializeWebProcess): Handle the partitioning time
+ passed from the UIProcess.
+
+2018-01-31 Jason Marcell <[email protected]>
+
Cherry-pick r227869. rdar://problem/37059542
2018-01-30 Tim Horton <[email protected]>
Modified: branches/safari-605-branch/Source/WebKit/Shared/WebProcessCreationParameters.cpp (227886 => 227887)
--- branches/safari-605-branch/Source/WebKit/Shared/WebProcessCreationParameters.cpp 2018-01-31 09:09:31 UTC (rev 227886)
+++ branches/safari-605-branch/Source/WebKit/Shared/WebProcessCreationParameters.cpp 2018-01-31 09:09:35 UTC (rev 227887)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -150,6 +150,8 @@
#if USE(SOUP)
encoder << proxySettings;
#endif
+
+ encoder << cookiePartitionTimeToLive;
}
bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreationParameters& parameters)
@@ -391,6 +393,9 @@
return false;
#endif
+ if (!decoder.decode(parameters.cookiePartitionTimeToLive))
+ return false;
+
return true;
}
Modified: branches/safari-605-branch/Source/WebKit/Shared/WebProcessCreationParameters.h (227886 => 227887)
--- branches/safari-605-branch/Source/WebKit/Shared/WebProcessCreationParameters.h 2018-01-31 09:09:31 UTC (rev 227886)
+++ branches/safari-605-branch/Source/WebKit/Shared/WebProcessCreationParameters.h 2018-01-31 09:09:35 UTC (rev 227887)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -184,6 +184,7 @@
#if USE(SOUP)
WebCore::SoupNetworkProxySettings proxySettings;
#endif
+ Seconds cookiePartitionTimeToLive;
};
} // namespace WebKit
Modified: branches/safari-605-branch/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (227886 => 227887)
--- branches/safari-605-branch/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2018-01-31 09:09:31 UTC (rev 227886)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2018-01-31 09:09:35 UTC (rev 227887)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -275,6 +275,11 @@
if (isSafari && !parameters.shouldCaptureAudioInUIProcess && mediaDevicesEnabled)
SandboxExtension::createHandleForGenericExtension("com.apple.webkit.microphone", parameters.audioCaptureExtensionHandle);
#endif
+
+ Seconds timeToLiveUserInteraction([[NSUserDefaults standardUserDefaults] doubleForKey:@"ResourceLoadStatisticsTimeToLiveUserInteraction"]);
+ if (timeToLiveUserInteraction < 0_s || timeToLiveUserInteraction > 24_h * 30)
+ timeToLiveUserInteraction = 24_h;
+ parameters.cookiePartitionTimeToLive = timeToLiveUserInteraction;
}
void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationParameters& parameters)
Modified: branches/safari-605-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsTelemetry.cpp (227886 => 227887)
--- branches/safari-605-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsTelemetry.cpp 2018-01-31 09:09:31 UTC (rev 227886)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsTelemetry.cpp 2018-01-31 09:09:35 UTC (rev 227887)
@@ -51,6 +51,8 @@
unsigned subframeUnderTopFrameOrigins;
unsigned subresourceUnderTopFrameOrigins;
unsigned subresourceUniqueRedirectsTo;
+ unsigned timesAccessedAsFirstPartyDueToUserInteraction;
+ unsigned timesAccessedAsFirstPartyDueToStorageAccessAPI;
};
static Vector<PrevalentResourceTelemetry> sortedPrevalentResourceTelemetry(const WebResourceLoadStatisticsStore& store)
@@ -68,7 +70,9 @@
daysSinceUserInteraction,
statistic.subframeUnderTopFrameOrigins.size(),
statistic.subresourceUnderTopFrameOrigins.size(),
- statistic.subresourceUniqueRedirectsTo.size()
+ statistic.subresourceUniqueRedirectsTo.size(),
+ statistic.timesAccessedAsFirstPartyDueToUserInteraction,
+ statistic.timesAccessedAsFirstPartyDueToStorageAccessAPI
});
});
@@ -146,25 +150,33 @@
static void submitTopList(unsigned numberOfResourcesFromTheTop, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, WebPageProxy& webPageProxy)
{
- WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> subframeUnderTopFrameOriginsGetter = [] (const PrevalentResourceTelemetry& t) {
+ WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> subframeUnderTopFrameOriginsGetter = [] (auto& t) {
return t.subframeUnderTopFrameOrigins;
};
- WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> subresourceUnderTopFrameOriginsGetter = [] (const PrevalentResourceTelemetry& t) {
+ WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> subresourceUnderTopFrameOriginsGetter = [] (auto& t) {
return t.subresourceUnderTopFrameOrigins;
};
- WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> subresourceUniqueRedirectsToGetter = [] (const PrevalentResourceTelemetry& t) {
+ WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> subresourceUniqueRedirectsToGetter = [] (auto& t) {
return t.subresourceUniqueRedirectsTo;
};
- WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> numberOfTimesDataRecordsRemovedGetter = [] (const PrevalentResourceTelemetry& t) {
+ WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> numberOfTimesDataRecordsRemovedGetter = [] (auto& t) {
return t.numberOfTimesDataRecordsRemoved;
};
-
+ WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> numberOfTimesAccessedAsFirstPartyDueToUserInteractionGetter = [] (auto& t) {
+ return t.timesAccessedAsFirstPartyDueToUserInteraction;
+ };
+ WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> numberOfTimesAccessedAsFirstPartyDueToStorageAccessAPIGetter = [] (auto& t) {
+ return t.timesAccessedAsFirstPartyDueToStorageAccessAPI;
+ };
+
unsigned topPrevalentResourcesWithUserInteraction = numberOfResourcesWithUserInteraction(sortedPrevalentResources, 0, numberOfResourcesFromTheTop - 1);
unsigned topSubframeUnderTopFrameOrigins = median(sortedPrevalentResourcesWithoutUserInteraction, 0, numberOfResourcesFromTheTop - 1, subframeUnderTopFrameOriginsGetter);
unsigned topSubresourceUnderTopFrameOrigins = median(sortedPrevalentResourcesWithoutUserInteraction, 0, numberOfResourcesFromTheTop - 1, subresourceUnderTopFrameOriginsGetter);
unsigned topSubresourceUniqueRedirectsTo = median(sortedPrevalentResourcesWithoutUserInteraction, 0, numberOfResourcesFromTheTop - 1, subresourceUniqueRedirectsToGetter);
unsigned topNumberOfTimesDataRecordsRemoved = median(sortedPrevalentResourcesWithoutUserInteraction, 0, numberOfResourcesFromTheTop - 1, numberOfTimesDataRecordsRemovedGetter);
-
+ unsigned topNumberOfTimesAccessedAsFirstPartyDueToUserInteraction = median(sortedPrevalentResourcesWithoutUserInteraction, 0, numberOfResourcesFromTheTop - 1, numberOfTimesAccessedAsFirstPartyDueToUserInteractionGetter);
+ unsigned topNumberOfTimesAccessedAsFirstPartyDueToStorageAccessAPI = median(sortedPrevalentResourcesWithoutUserInteraction, 0, numberOfResourcesFromTheTop - 1, numberOfTimesAccessedAsFirstPartyDueToStorageAccessAPIGetter);
+
StringBuilder preambleBuilder;
preambleBuilder.appendLiteral("top");
preambleBuilder.appendNumber(numberOfResourcesFromTheTop);
@@ -180,6 +192,10 @@
topSubresourceUniqueRedirectsTo, significantFiguresForLoggedValues, ShouldSample::No);
webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesDataRecordsRemoved",
topNumberOfTimesDataRecordsRemoved, significantFiguresForLoggedValues, ShouldSample::No);
+ webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesAccessedAsFirstPartyDueToUserInteraction",
+ topNumberOfTimesAccessedAsFirstPartyDueToUserInteraction, significantFiguresForLoggedValues, ShouldSample::No);
+ webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesAccessedAsFirstPartyDueToStorageAccessAPI",
+ topNumberOfTimesAccessedAsFirstPartyDueToStorageAccessAPI, significantFiguresForLoggedValues, ShouldSample::No);
}
static void submitTopLists(const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, WebPageProxy& webPageProxy)
Modified: branches/safari-605-branch/Source/WebKit/WebProcess/WebProcess.cpp (227886 => 227887)
--- branches/safari-605-branch/Source/WebKit/WebProcess/WebProcess.cpp 2018-01-31 09:09:31 UTC (rev 227886)
+++ branches/safari-605-branch/Source/WebKit/WebProcess/WebProcess.cpp 2018-01-31 09:09:35 UTC (rev 227887)
@@ -429,6 +429,8 @@
#if ENABLE(WEBASSEMBLY)
JSC::Wasm::enableFastMemory();
#endif
+
+ ResourceLoadObserver::shared().setTimeToLivePartitionFree(parameters.cookiePartitionTimeToLive);
}
void WebProcess::registerURLSchemeAsEmptyDocument(const String& urlScheme)