Title: [172058] branches/safari-600.1-branch/Source/WebInspectorUI
- Revision
- 172058
- Author
- lforsch...@apple.com
- Date
- 2014-08-05 13:25:26 -0700 (Tue, 05 Aug 2014)
Log Message
Merged r171881. <rdar://problem/17874168>
Modified Paths
Diff
Modified: branches/safari-600.1-branch/Source/WebInspectorUI/ChangeLog (172057 => 172058)
--- branches/safari-600.1-branch/Source/WebInspectorUI/ChangeLog 2014-08-05 20:23:06 UTC (rev 172057)
+++ branches/safari-600.1-branch/Source/WebInspectorUI/ChangeLog 2014-08-05 20:25:26 UTC (rev 172058)
@@ -1,5 +1,38 @@
2014-08-05 Lucas Forschler <lforsch...@apple.com>
+ Merge r171881
+
+ 2014-07-31 Brian J. Burg <b...@cs.washington.edu>
+
+ Web Inspector: MessageDispatcher should not synchronously dispatch all backend messages
+ https://bugs.webkit.org/show_bug.cgi?id=135427
+
+ Reviewed by Timothy Hatcher.
+
+ The frontend dispatches all queued messages from the backend synchronously, even if there are
+ hundreds of messages, or even if some of the messages take a long time (>10ms) to process.
+
+ This patch adds a time limit to the frontend's message dispatcher. If the time limit is exceeded
+ when processing the message queue, unhandled messages remain in the queue and the dispatcher goes
+ to sleep until the next run loop (obtained by a new setTimeout).
+
+ This has the effect of removing stutters when the message queue has hundreds of small messages.
+ The outliers are still the same since some single messages can take over 200ms to be handled.
+
+ This patch also improves performance logging in InspectorBackend so that it is easier to see
+ message handling times and their distribution among run loop turns.
+
+ * UserInterface/Protocol/InspectorBackend.js:
+ (InspectorBackendClass): Add a new diagnostic flag that warns about slow message handling.
+ (InspectorBackendClass.prototype._dispatchCallback.get if): Improve logging.
+ (InspectorBackendClass.prototype._dispatchCallback): Improve logging.
+ (InspectorBackendClass.prototype._dispatchEvent): Improve logging.
+ * UserInterface/Protocol/MessageDispatcher.js:
+ (WebInspector.dispatchNextQueuedMessageFromBackend): Keep track of a time limit for message
+ dispatching, and set a new timeout if we exceed the time limit.
+
+2014-08-05 Lucas Forschler <lforsch...@apple.com>
+
Merge r171869
2014-07-31 Joseph Pecoraro <pecor...@apple.com>
Modified: branches/safari-600.1-branch/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js (172057 => 172058)
--- branches/safari-600.1-branch/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js 2014-08-05 20:23:06 UTC (rev 172057)
+++ branches/safari-600.1-branch/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js 2014-08-05 20:25:26 UTC (rev 172058)
@@ -40,6 +40,8 @@
this.dumpInspectorTimeStats = false;
this.dumpInspectorProtocolMessages = false;
+ this.warnForLongMessageHandling = false;
+ this.longMessageHandlingThreshold = 10; // milliseconds.
}
InspectorBackendClass.prototype = {
@@ -171,8 +173,12 @@
console.error("Uncaught exception in inspector page while dispatching callback for command " + command.qualifiedName + ": ", e);
}
+ var processingDuration = Date.now() - processingStartTime;
+ if (this.warnForLongMessageHandling && processingDuration > this.longMessageHandlingThreshold)
+ console.warn("InspectorBackend: took " + processingDuration + "ms to handle response for command: " + command.qualifiedName);
+
if (this.dumpInspectorTimeStats)
- console.log("time-stats: " + command.qualifiedName + " = " + (processingStartTime - callbackData.sendRequestTime) + " + " + (Date.now() - processingStartTime));
+ console.log("time-stats: Handling: " + processingDuration + "ms; RTT: " + (processingStartTime - callbackData.sendRequestTime) + "ms; (command " + command.qualifiedName + ")");
this._callbackData.delete(messageObject["id"]);
}
@@ -214,8 +220,12 @@
console.error("Uncaught exception in inspector page while handling event " + qualifiedName + ": ", e);
}
+ var processingDuration = Date.now() - processingStartTime;
+ if (this.warnForLongMessageHandling && processingDuration > this.longMessageHandlingThreshold)
+ console.warn("InspectorBackend: took " + processingDuration + "ms to handle event: " + messageObject["method"]);
+
if (this.dumpInspectorTimeStats)
- console.log("time-stats: " + messageObject["method"] + " = " + (Date.now() - processingStartTime));
+ console.log("time-stats: Handling: " + processingDuration + "ms (event " + messageObject["method"] + ")");
},
_invokeCommand: function(command, parameters, callback)
Modified: branches/safari-600.1-branch/Source/WebInspectorUI/UserInterface/Protocol/MessageDispatcher.js (172057 => 172058)
--- branches/safari-600.1-branch/Source/WebInspectorUI/UserInterface/Protocol/MessageDispatcher.js 2014-08-05 20:23:06 UTC (rev 172057)
+++ branches/safari-600.1-branch/Source/WebInspectorUI/UserInterface/Protocol/MessageDispatcher.js 2014-08-05 20:25:26 UTC (rev 172058)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 University of Washington
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,12 +28,30 @@
WebInspector.dispatchNextQueuedMessageFromBackend = function()
{
- for (var i = 0; i < this.messagesToDispatch.length; ++i)
- InspectorBackend.dispatch(this.messagesToDispatch[i]);
+ var startCount = WebInspector.messagesToDispatch.length;
+ var startTime = Date.now();
+ var timeLimitPerRunLoop = 10; // milliseconds
- this.messagesToDispatch = [];
+ var i = 0;
+ for (; i < WebInspector.messagesToDispatch.length; ++i) {
+ // Defer remaining messages if we have taken too long. In practice, single
+ // messages like Page.getResourceContent blow through the time budget.
+ if (Date.now() - startTime > timeLimitPerRunLoop)
+ break;
- this._dispatchTimeout = null;
+ InspectorBackend.dispatch(WebInspector.messagesToDispatch[i]);
+ }
+
+ if (i === WebInspector.messagesToDispatch.length) {
+ WebInspector.messagesToDispatch = [];
+ WebInspector._dispatchTimeout = null;
+ } else {
+ WebInspector.messagesToDispatch = WebInspector.messagesToDispatch.slice(i);
+ WebInspector._dispatchTimeout = setTimeout(WebInspector.dispatchNextQueuedMessageFromBackend, 0);
+ }
+
+ if (InspectorBackend.dumpInspectorTimeStats)
+ console.log("time-stats: --- RunLoop duration: " + (Date.now() - startTime) + "ms; dispatched: " + (startCount - WebInspector.messagesToDispatch.length) + "; remaining: " + WebInspector.messagesToDispatch.length);
}
WebInspector.dispatchMessageFromBackend = function(message)
@@ -45,5 +64,5 @@
if (this._dispatchTimeout)
return;
- this._dispatchTimeout = setTimeout(this.dispatchNextQueuedMessageFromBackend.bind(this), 0);
+ this._dispatchTimeout = setTimeout(WebInspector.dispatchNextQueuedMessageFromBackend, 0);
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes