Diff
Modified: trunk/Source/WebCore/ChangeLog (227754 => 227755)
--- trunk/Source/WebCore/ChangeLog 2018-01-29 21:58:31 UTC (rev 227754)
+++ trunk/Source/WebCore/ChangeLog 2018-01-29 22:00:58 UTC (rev 227755)
@@ -1,3 +1,31 @@
+2018-01-29 Brent Fulgham <bfulg...@apple.com>
+
+ 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-29 Antti Koivisto <an...@apple.com>
CalcExpressionBlendLength::evaluate hits stack limit
Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.cpp (227754 => 227755)
--- trunk/Source/WebCore/loader/ResourceLoadObserver.cpp 2018-01-29 21:58:31 UTC (rev 227754)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.cpp 2018-01-29 22:00:58 UTC (rev 227755)
@@ -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: trunk/Source/WebCore/loader/ResourceLoadObserver.h (227754 => 227755)
--- trunk/Source/WebCore/loader/ResourceLoadObserver.h 2018-01-29 21:58:31 UTC (rev 227754)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.h 2018-01-29 22:00:58 UTC (rev 227755)
@@ -69,6 +69,7 @@
bool shouldLogUserInteraction() const { return m_shouldLogUserInteraction; }
void setShouldLogUserInteraction(bool shouldLogUserInteraction) { m_shouldLogUserInteraction = shouldLogUserInteraction; }
#endif
+ WEBCORE_EXPORT void setTimeToLivePartitionFree(Seconds);
private:
ResourceLoadObserver();
@@ -75,6 +76,7 @@
bool shouldLog(Page*) const;
ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);
+ bool wasAccessedWithinInteractionWindow(const ResourceLoadStatistics&) const;
void scheduleNotificationIfNeeded();
Vector<ResourceLoadStatistics> takeStatistics();
@@ -83,6 +85,7 @@
HashMap<String, WTF::WallTime> m_lastReportedUserInteractionMap;
WTF::Function<void (Vector<ResourceLoadStatistics>&&)> m_notificationCallback;
Timer m_notificationTimer;
+ Seconds m_timeToLiveCookiePartitionFree { 24_h };
#if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
uint64_t m_loggingCounter { 0 };
bool m_shouldLogUserInteraction { false };
Modified: trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp (227754 => 227755)
--- trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp 2018-01-29 21:58:31 UTC (rev 227754)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp 2018-01-29 22:00:58 UTC (rev 227755)
@@ -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: trunk/Source/WebCore/loader/ResourceLoadStatistics.h (227754 => 227755)
--- trunk/Source/WebCore/loader/ResourceLoadStatistics.h 2018-01-29 21:58:31 UTC (rev 227754)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.h 2018-01-29 22:00:58 UTC (rev 227755)
@@ -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: trunk/Source/WebKit/ChangeLog (227754 => 227755)
--- trunk/Source/WebKit/ChangeLog 2018-01-29 21:58:31 UTC (rev 227754)
+++ trunk/Source/WebKit/ChangeLog 2018-01-29 22:00:58 UTC (rev 227755)
@@ -1,3 +1,31 @@
+2018-01-29 Brent Fulgham <bfulg...@apple.com>
+
+ 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-29 Alex Christensen <achristen...@webkit.org>
Fix crash when during canAuthenticateAgainstProtectionSpace
Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (227754 => 227755)
--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp 2018-01-29 21:58:31 UTC (rev 227754)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp 2018-01-29 22:00:58 UTC (rev 227755)
@@ -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
@@ -154,6 +154,8 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
encoder << shouldLogUserInteraction;
#endif
+
+ encoder << cookiePartitionTimeToLive;
}
bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreationParameters& parameters)
@@ -400,6 +402,9 @@
return false;
#endif
+ if (!decoder.decode(parameters.cookiePartitionTimeToLive))
+ return false;
+
return true;
}
Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (227754 => 227755)
--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h 2018-01-29 21:58:31 UTC (rev 227754)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h 2018-01-29 22:00:58 UTC (rev 227755)
@@ -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
@@ -188,6 +188,7 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
bool shouldLogUserInteraction { false };
#endif
+ Seconds cookiePartitionTimeToLive;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (227754 => 227755)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2018-01-29 21:58:31 UTC (rev 227754)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2018-01-29 22:00:58 UTC (rev 227755)
@@ -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
@@ -279,6 +279,11 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
parameters.shouldLogUserInteraction = [defaults boolForKey:WebKitLogCookieInformationDefaultsKey];
#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: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsTelemetry.cpp (227754 => 227755)
--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsTelemetry.cpp 2018-01-29 21:58:31 UTC (rev 227754)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsTelemetry.cpp 2018-01-29 22:00:58 UTC (rev 227755)
@@ -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: trunk/Source/WebKit/WebProcess/WebProcess.cpp (227754 => 227755)
--- trunk/Source/WebKit/WebProcess/WebProcess.cpp 2018-01-29 21:58:31 UTC (rev 227754)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp 2018-01-29 22:00:58 UTC (rev 227755)
@@ -424,6 +424,8 @@
ResourceLoadObserver::shared().setShouldLogUserInteraction(parameters.shouldLogUserInteraction);
#endif
+ ResourceLoadObserver::shared().setTimeToLivePartitionFree(parameters.cookiePartitionTimeToLive);
+
RELEASE_LOG(Process, "%p - WebProcess::initializeWebProcess: Presenting process = %d", this, WebCore::presentingApplicationPID());
}