Diff
Modified: trunk/Source/WTF/ChangeLog (197900 => 197901)
--- trunk/Source/WTF/ChangeLog 2016-03-10 00:40:30 UTC (rev 197900)
+++ trunk/Source/WTF/ChangeLog 2016-03-10 00:45:35 UTC (rev 197901)
@@ -1,3 +1,16 @@
+2016-03-09 Keith Rollin <[email protected]>
+
+ Add state dumping facility
+ https://bugs.webkit.org/show_bug.cgi?id=154930
+ <rdar://problem/24939135>
+
+ Reviewed by Anders Carlsson.
+
+ Add an OS_STATE flag to control the inclusion of process state dumping
+ functionality.
+
+ * wtf/Platform.h:
+
2016-03-09 Oliver Hunt <[email protected]>
Fix old iOS
Modified: trunk/Source/WTF/wtf/Platform.h (197900 => 197901)
--- trunk/Source/WTF/wtf/Platform.h 2016-03-10 00:40:30 UTC (rev 197900)
+++ trunk/Source/WTF/wtf/Platform.h 2016-03-10 00:45:35 UTC (rev 197901)
@@ -1136,7 +1136,10 @@
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)
#define USE_OS_LOG 1
+#if USE(APPLE_INTERNAL_SDK)
+#define USE_OS_STATE 1
#endif
+#endif
#if defined(ENABLE_SEPARATED_WX_HEAP)
#if !(CPU(ARM64) && ((PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)))
Modified: trunk/Source/WebKit2/ChangeLog (197900 => 197901)
--- trunk/Source/WebKit2/ChangeLog 2016-03-10 00:40:30 UTC (rev 197900)
+++ trunk/Source/WebKit2/ChangeLog 2016-03-10 00:45:35 UTC (rev 197901)
@@ -1,3 +1,23 @@
+2016-03-09 Keith Rollin <[email protected]>
+
+ Add state dumping facility
+ https://bugs.webkit.org/show_bug.cgi?id=154930
+ <rdar://problem/24939135>
+
+ Reviewed by Anders Carlsson.
+
+ Collect the times at which pages are loaded. Dump them when an OS
+ state dump is triggered.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::didCommitLoad):
+ * WebProcess/WebPage/WebPage.h:
+ (WebKit::WebPage::lastPageLoadTime):
+ * WebProcess/WebProcess.h:
+ * WebProcess/cocoa/WebProcessCocoa.mm:
+ (WebKit::WebProcess::registerWithStateDumper):
+ (WebKit::WebProcess::platformInitializeProcess):
+
2016-03-09 Anders Carlsson <[email protected]>
_WKWebsiteDataSize.h should be an SPI header.
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (197900 => 197901)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2016-03-10 00:40:30 UTC (rev 197900)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2016-03-10 00:45:35 UTC (rev 197901)
@@ -4828,6 +4828,10 @@
resetPrimarySnapshottedPlugIn();
#endif
+#if USE(OS_STATE)
+ m_loadCommitTime = std::chrono::system_clock::now();
+#endif
+
WebProcess::singleton().updateActivePages();
updateMainFrameScrollOffsetPinning();
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (197900 => 197901)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2016-03-10 00:40:30 UTC (rev 197900)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2016-03-10 00:45:35 UTC (rev 197901)
@@ -934,6 +934,10 @@
void insertNewlineInQuotedContent();
+#if USE(OS_STATE)
+ std::chrono::system_clock::time_point loadCommitTime() const { return m_loadCommitTime; }
+#endif
+
private:
WebPage(uint64_t pageID, const WebPageCreationParameters&);
@@ -1442,6 +1446,10 @@
#if ENABLE(VIDEO) && USE(GSTREAMER)
RefPtr<WebCore::MediaPlayerRequestInstallMissingPluginsCallback> m_installMediaPluginsCallback;
#endif
+
+#if USE(OS_STATE)
+ std::chrono::system_clock::time_point m_loadCommitTime;
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (197900 => 197901)
--- trunk/Source/WebKit2/WebProcess/WebProcess.h 2016-03-10 00:40:30 UTC (rev 197900)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h 2016-03-10 00:45:35 UTC (rev 197901)
@@ -216,6 +216,10 @@
void initializeWebProcess(WebProcessCreationParameters&&);
void platformInitializeWebProcess(WebProcessCreationParameters&&);
+#if USE(OS_STATE)
+ void registerWithStateDumper();
+#endif
+
void clearCachedCredentials();
void platformTerminate();
Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm (197900 => 197901)
--- trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm 2016-03-10 00:40:30 UTC (rev 197900)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm 2016-03-10 00:45:35 UTC (rev 197901)
@@ -66,6 +66,10 @@
#import <WebCore/GraphicsServicesSPI.h>
#endif
+#if USE(OS_STATE)
+#include <os/state_private.h>
+#endif
+
using namespace WebCore;
namespace WebKit {
@@ -206,10 +210,81 @@
#endif
}
+#if USE(OS_STATE)
+void WebProcess::registerWithStateDumper()
+{
+ dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
+ os_state_add_handler(queue, ^(os_state_hints_t hints) {
+
+ @autoreleasepool {
+ os_state_data_t os_state = nil;
+
+ // Only gather state on faults and sysdiagnose. It's overkill for
+ // general error messages.
+ if (hints->osh_api == OS_STATE_API_ERROR)
+ return os_state;
+
+ // Create a dictionary to contain the collected state. This
+ // dictionary will be serialized and passed back to os_state.
+ auto stateDict = adoptNS([[NSMutableDictionary alloc] init]);
+
+ auto pageLoadTimes = adoptNS([[NSMutableArray alloc] init]);
+ for (auto& page : m_pageMap.values()) {
+ if (page->usesEphemeralSession())
+ continue;
+
+ NSDate* date = [NSDate dateWithTimeIntervalSince1970:std::chrono::system_clock::to_time_t(page->loadCommitTime())];
+ [pageLoadTimes addObject:date];
+ }
+
+ // Adding an empty array to the process state may provide an
+ // indication of the existance of private sessions, which we'd like
+ // to hide, so don't add empty arrays.
+ if ([pageLoadTimes count])
+ [stateDict setObject:pageLoadTimes.get() forKey:@"Page Load Times"];
+
+ // --- Possibly add other state here as other entries in the dictionary. ---
+
+ // Submitting an empty process state object may provide an
+ // indication of the existance of private sessions, which we'd like
+ // to hide, so don't return empty dictionaries.
+ if (![stateDict count])
+ return os_state;
+
+ // Serialize the accumulated process state so that we can put the
+ // result in an os_state_data_t structure.
+ NSError* error = nil;
+ NSData* data = "" dataWithPropertyList:stateDict.get() format:NSPropertyListBinaryFormat_v1_0 options:0 error:&error];
+
+ if (!data) {
+ ASSERT(data);
+ return os_state;
+ }
+
+ size_t neededSize = OS_STATE_DATA_SIZE_NEEDED(data.length);
+ os_state = (os_state_data_t)malloc(neededSize);
+ if (os_state) {
+ memset(os_state, 0, neededSize);
+ os_state->osd_type = OS_STATE_DATA_SERIALIZED_NSCF_OBJECT;
+ os_state->osd_data_size = data.length;
+ strcpy(os_state->osd_title, "WebContent state"); // NB: Only 64 bytes of buffer here.
+ memcpy(os_state->osd_data, data.bytes, data.length);
+ }
+
+ return os_state;
+ }
+ });
+}
+#endif
+
void WebProcess::platformInitializeProcess(const ChildProcessInitializationParameters&)
{
registerWithAccessibility();
+#if USE(OS_STATE)
+ registerWithStateDumper();
+#endif
+
#if ENABLE(SEC_ITEM_SHIM)
SecItemShim::singleton().initialize(this);
#endif