- Revision
- 202657
- Author
- [email protected]
- Date
- 2016-06-29 16:05:55 -0700 (Wed, 29 Jun 2016)
Log Message
Web Inspector: Uncaught Exception page never shows if exception is thrown while processing a protocol event
https://bugs.webkit.org/show_bug.cgi?id=159182
Reviewed by Joseph Pecoraro.
Since we catch exceptions raised during the handling of protocol responses and events, there
is no way for these exceptions to trigger the global exception handler that shows the Uncaught
Exception Reporter sheet. We should show these in the sheet because it makes them get fixed faster.
Add a new entry point, WebInspector.reportInternalError, that takes an error or string and
a free-form map of strings to strings for storing additional information such as message data.
Pass the error and any other relevant details to this entry point, which decides whether to
show the uncaught exception reporter or quietly log the error to Inspector^2 console.
In future patches, I would like to do the following once the common errors are fixed:
- enable reporting via Uncaught Exception Reporter for all engineering builds
- move internal console.error call sites to use WebInspector.reportInternalError
* UserInterface/Base/Main.js: Add reportInternalError, which redirects to the uncaught
exception reporter sheet or does console.error. It also adds a console.assert that could
cause the debugger to pause if desired.
* UserInterface/Debug/UncaughtExceptionReporter.css:
(.sheet-container): Make the report scrollable now that we could potentially show a lot of text.
* UserInterface/Debug/UncaughtExceptionReporter.js:
(handleError): Also pass along the 'details' poperty.
(formattedEntry): Refactor the code so it additionally prints out the keys and values of
the 'details' property. It does not do any coercions, so callers must convert values to strings.
* UserInterface/Protocol/InspectorBackend.js:
(InspectorBackendClass.prototype._dispatchResponse): Inlined a function.
(InspectorBackendClass.prototype._dispatchResponseToCallback):
(InspectorBackendClass.prototype._dispatchEvent):
Report uncaught exceptions via WebInspector.reportInternalError.
(InspectorBackendClass.prototype._reportProtocolError): Deleted, inlined into the single use site.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (202656 => 202657)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-06-29 23:01:42 UTC (rev 202656)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-06-29 23:05:55 UTC (rev 202657)
@@ -1,3 +1,43 @@
+2016-06-29 Brian Burg <[email protected]>
+
+ Web Inspector: Uncaught Exception page never shows if exception is thrown while processing a protocol event
+ https://bugs.webkit.org/show_bug.cgi?id=159182
+
+ Reviewed by Joseph Pecoraro.
+
+ Since we catch exceptions raised during the handling of protocol responses and events, there
+ is no way for these exceptions to trigger the global exception handler that shows the Uncaught
+ Exception Reporter sheet. We should show these in the sheet because it makes them get fixed faster.
+
+ Add a new entry point, WebInspector.reportInternalError, that takes an error or string and
+ a free-form map of strings to strings for storing additional information such as message data.
+ Pass the error and any other relevant details to this entry point, which decides whether to
+ show the uncaught exception reporter or quietly log the error to Inspector^2 console.
+
+ In future patches, I would like to do the following once the common errors are fixed:
+ - enable reporting via Uncaught Exception Reporter for all engineering builds
+ - move internal console.error call sites to use WebInspector.reportInternalError
+
+ * UserInterface/Base/Main.js: Add reportInternalError, which redirects to the uncaught
+ exception reporter sheet or does console.error. It also adds a console.assert that could
+ cause the debugger to pause if desired.
+
+ * UserInterface/Debug/UncaughtExceptionReporter.css:
+ (.sheet-container): Make the report scrollable now that we could potentially show a lot of text.
+
+ * UserInterface/Debug/UncaughtExceptionReporter.js:
+ (handleError): Also pass along the 'details' poperty.
+ (formattedEntry): Refactor the code so it additionally prints out the keys and values of
+ the 'details' property. It does not do any coercions, so callers must convert values to strings.
+
+ * UserInterface/Protocol/InspectorBackend.js:
+ (InspectorBackendClass.prototype._dispatchResponse): Inlined a function.
+ (InspectorBackendClass.prototype._dispatchResponseToCallback):
+ (InspectorBackendClass.prototype._dispatchEvent):
+ Report uncaught exceptions via WebInspector.reportInternalError.
+
+ (InspectorBackendClass.prototype._reportProtocolError): Deleted, inlined into the single use site.
+
2016-06-29 Joseph Pecoraro <[email protected]>
Web Inspector: Show Shadow Root type in DOM Tree
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (202656 => 202657)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2016-06-29 23:01:42 UTC (rev 202656)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2016-06-29 23:05:55 UTC (rev 202657)
@@ -2436,6 +2436,26 @@
}
};
+WebInspector.reportInternalError = function(errorOrString, details={})
+{
+ // The 'details' object includes additional information from the caller as free-form string keys and values.
+ // Each key and value will be shown in the uncaught exception reporter, console error message, or in
+ // a pre-filled bug report generated for this internal error.
+
+ let error = (errorOrString instanceof Error) ? errorOrString : new Error(errorOrString);
+ error.details = details;
+
+ // The error will be displayed in the Uncaught Exception Reporter sheet if DebugUI is enabled.
+ if (WebInspector.isDebugUIEnabled()) {
+ // This assert allows us to stop the debugger at an internal exception. It doesn't re-throw
+ // exceptions because the original exception would be lost through window.onerror.
+ // This workaround can be removed once <https://webkit.org/b/158192> is fixed.
+ console.assert(false, "An internal exception was thrown.", error);
+ handleInternalException(error);
+ } else
+ console.error(error);
+};
+
// OpenResourceDialog delegate
WebInspector.dialogWasDismissed = function(dialog)
Modified: trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.css (202656 => 202657)
--- trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.css 2016-06-29 23:01:42 UTC (rev 202656)
+++ trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.css 2016-06-29 23:05:55 UTC (rev 202657)
@@ -31,6 +31,7 @@
bottom: 0;
z-index: var(--z-index-uncaught-exception-sheet);
background-color: hsl(0, 0%, 96%);
+ overflow: scroll;
}
.uncaught-exception-sheet {
@@ -37,7 +38,6 @@
padding: 50px 55px 50px 65px;
font-family: '-webkit-system-font';
font-size: 11pt;
- overflow-y: auto;
min-width: 400px;
color: hsl(0, 0%, 40%);
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js (202656 => 202657)
--- trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js 2016-06-29 23:01:42 UTC (rev 202656)
+++ trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js 2016-06-29 23:05:55 UTC (rev 202657)
@@ -57,6 +57,7 @@
lineNumber: error.line,
columnNumber: error.column,
stack: error.stack,
+ details: error.details,
});
}
@@ -150,22 +151,29 @@
}
function formattedEntry(entry) {
- let message = `${entry.message} (at ${entry.url}:${entry.lineNumber}:${entry.columnNumber})`;
- if (!entry.stack)
- return message;
-
const indent = " ";
- let results = [];
- let lines = entry.stack.split(/\n/g);
- for (let line of lines) {
- let atIndex = line.indexOf("@");
- let slashIndex = Math.max(line.lastIndexOf("/"), atIndex);
- let functionName = line.substring(0, atIndex) || "?";
- let location = line.substring(slashIndex + 1, line.length);
- results.push(`${indent}${functionName} @ ${location}`);
+ let lines = [`${entry.message} (at ${entry.url}:${entry.lineNumber}:${entry.columnNumber})`];
+ if (entry.stack) {
+ let stackLines = entry.stack.split(/\n/g);
+ for (let stackLine of stackLines) {
+ let atIndex = stackLine.indexOf("@");
+ let slashIndex = Math.max(stackLine.lastIndexOf("/"), atIndex);
+ let functionName = stackLine.substring(0, atIndex) || "?";
+ let location = stackLine.substring(slashIndex + 1, stackLine.length);
+ lines.push(`${indent}${functionName} @ ${location}`);
+ }
}
- return message + "\n" + results.join("\n");
+ if (entry.details) {
+ lines.push("");
+ lines.push("Additional Details:")
+ for (let key in entry.details) {
+ let value = entry.details[key];
+ lines.push(`${indent}${key} --> ${value}`);
+ }
+ }
+
+ return lines.join("\n");
}
let inspectedPageURL = null;
@@ -232,6 +240,6 @@
}
window.addEventListener("error", handleUncaughtException);
-window.handlePromiseException = handleError;
+window.handlePromiseException = window.handleInternalException = handleError;
})();
Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js (202656 => 202657)
--- trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js 2016-06-29 23:01:42 UTC (rev 202656)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js 2016-06-29 23:05:55 UTC (rev 202657)
@@ -255,7 +255,7 @@
if (messageObject["error"]) {
if (messageObject["error"].code !== -32000)
- this._reportProtocolError(messageObject);
+ console.error("Request with id = " + messageObject["id"] + " failed. " + JSON.stringify(messageObject["error"]));
}
let sequenceId = messageObject["id"];
@@ -298,7 +298,10 @@
try {
callback.apply(null, callbackArguments);
} catch (e) {
- console.error("Uncaught exception in inspector page while dispatching callback for command " + command.qualifiedName, e);
+ WebInspector.reportInternalError(e, {
+ "cause": `An uncaught exception was thrown while dispatching response callback for command ${command.qualifiedName}.`,
+ "protocol-message": JSON.stringify(messageObject),
+ });
}
}
@@ -343,9 +346,13 @@
try {
agent.dispatchEvent(eventName, eventArguments);
} catch (e) {
- console.error("Uncaught exception in inspector page while handling event " + qualifiedName, e);
for (let tracer of this.activeTracers)
tracer.logFrontendException(messageObject, e);
+
+ WebInspector.reportInternalError(e, {
+ "cause": `An uncaught exception was thrown while handling event: ${qualifiedName}`,
+ "protocol-message": JSON.stringify(messageObject),
+ });
}
let processingDuration = (timestamp() - processingStartTimestamp).toFixed(3);
@@ -353,11 +360,6 @@
tracer.logDidHandleEvent(messageObject, {dispatch: processingDuration});
}
- _reportProtocolError(messageObject)
- {
- console.error("Request with id = " + messageObject["id"] + " failed. " + JSON.stringify(messageObject["error"]));
- }
-
_flushPendingScripts()
{
console.assert(this._pendingResponses.size === 0);