Closed
Bug 1200832
Opened 10 years ago
Closed 10 years ago
Async stacks aren't working in the console or debugger with javascript.options.asyncstack=true
Categories
(DevTools :: General, defect)
DevTools
General
Tracking
(firefox43 affected, firefox44 fixed)
RESOLVED
FIXED
Firefox 44
People
(Reporter: bgrins, Assigned: tromey)
References
(Blocks 1 open bug,
URL
)
Details
(Whiteboard: [polish-backlog])
Attachments
(1 file, 5 obsolete files)
|
13.91 KB,
patch
|
tromey
:
review+
|
Details | Diff | Splinter Review |
STR:
* Make sure javascript.options.asyncstack is set to true (Nightly and Dev Edition for now have this as the default)
* Open: data:text/html,<script>setTimeout(function foo() {setTimeout(function bar() {console.trace();debugger;}, 100);}, 100);</script>
Expected - the trace shows:
bar();
foo();
Actual - the trace shows:
bar();
I've noticed the same behavior with Promise resolutions too.
Comment 1•10 years ago
|
||
Is this still an issue?
Comment 2•10 years ago
|
||
(In reply to Florian Bender from comment #1)
> Is this still an issue?
Yes.
Whiteboard: [polish-backlog]
| Assignee | ||
Comment 3•10 years ago
|
||
The debugger part is already filed as bug 1142571.
| Assignee | ||
Comment 4•10 years ago
|
||
There are two problems here. First, Console.cpp ignores async parents:
https://dxr.mozilla.org/mozilla-central/source/dom/base/Console.cpp#981
Second, Exceptions.cpp has a couple of spots where it makes an empty stack
frame rather than return null:
https://dxr.mozilla.org/mozilla-central/source/dom/bindings/Exceptions.cpp#681
https://dxr.mozilla.org/mozilla-central/source/dom/bindings/Exceptions.cpp#816
Fixing these gives me an async stack for the original example, but I don't
know what other fallout there might be. In particular I get:
console.trace():
bar() debugger eval code:1
foo() debugger eval code:1
<anonymous> debugger eval code:1
There may be other spots needing a similar change, but I am not sure.
For example, this walks the stack but does not consider async parents:
https://dxr.mozilla.org/mozilla-central/source/devtools/shared/Console.jsm#370
| Assignee | ||
Comment 5•10 years ago
|
||
| Assignee | ||
Updated•10 years ago
|
Assignee: nobody → ttromey
Status: NEW → ASSIGNED
| Assignee | ||
Comment 6•10 years ago
|
||
Now with a test case.
One thing I am wondering is whether we should add an async cause field
to ConsoleStackEntry.
Attachment #8670856 -
Attachment is obsolete: true
| Assignee | ||
Comment 7•10 years ago
|
||
I think exposing the async cause is best, and with that plus a small
client change I now get:
console.trace():
bar() debugger eval code:1
(Async: setTimeout handler) foo() debugger eval code:1
(Async: setTimeout handler) <anonymous> debugger eval code:1
| Assignee | ||
Comment 8•10 years ago
|
||
Attachment #8670974 -
Attachment is obsolete: true
| Assignee | ||
Comment 9•10 years ago
|
||
| Assignee | ||
Comment 10•10 years ago
|
||
| Assignee | ||
Comment 11•10 years ago
|
||
Attachment #8671387 -
Attachment is obsolete: true
| Assignee | ||
Comment 12•10 years ago
|
||
Comment on attachment 8672029 [details] [diff] [review]
make Console.trace follow async parents
This changes console.trace to display async stack parents.
This exposes the async cause on ConsoleStackEntry so the console can display async parents more clearly. It changes ReifyStack to follow the async parent when it exists. It also removes a "dummy frame" case from Exceptions.cpp in order to make this work properly -- but note that the corresponding dummy frame case in CreateStack does not need to change (changing this runs into crashes elsewhere; and in any case the CreateStack case corresponds to an empty stack, not a frame without a direct parent).
I think the devtools bits are relatively straightforward. The change to Widgets.Stacktrace.render came about because I happened to notice a message about stacktrace being null when playing with the console before the change; that is, it is a fix for a minor latent bug.
Attachment #8672029 -
Flags: review?(bgrinstead)
Attachment #8672029 -
Flags: review?(amarchesini)
Comment 13•10 years ago
|
||
Comment on attachment 8672029 [details] [diff] [review]
make Console.trace follow async parents
Review of attachment 8672029 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/webidl/Console.webidl
@@ +80,5 @@
> unsigned long lineNumber = 0;
> unsigned long columnNumber = 0;
> DOMString functionName = "";
> unsigned long language = 0;
> + DOMString? asyncCause;
what about: DOMString asyncCause = ""; ?
Attachment #8672029 -
Flags: review?(amarchesini) → review+
| Reporter | ||
Comment 14•10 years ago
|
||
Comment on attachment 8672029 [details] [diff] [review]
make Console.trace follow async parents
Review of attachment 8672029 [details] [diff] [review]:
-----------------------------------------------------------------
Looks great! Should we file a new bug for these async causes to bubble up in the UI when an error is thrown in an async callback?
::: devtools/client/webconsole/test/browser_webconsole_console_trace_async.js
@@ +1,1 @@
> +/* vim:set ts=2 sw=2 sts=2 et: */
This test will fail in release builds and other places where the feature is off by default. You can test this locally via:
./mach mochitest devtools/client/webconsole/test/browser_webconsole_console_trace_async.js --setpref javascript.options.asyncstack=false
This test could also take advantage of add_task and BrowserTestUtils to be easier to work with and e10s friendly. I made some updates locally to test this so I'll just paste in the work:
add_task(function* runTest() {
// Async stacks aren't on by default in all builds
yield new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [
["javascript.options.asyncstack", true]
]}, resolve);
});
let {tab} = yield loadTab("data:text/html;charset=utf8,<p>hello");
let hud = yield openConsole(tab);
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI);
let [result] = yield waitForMessages({
webconsole: hud,
messages: [{
name: "console.trace output",
consoleTrace: {
file: "test-console-trace-async.html",
fn: "inner",
},
}],
});
let node = [...result.matched][0];
ok(node, "found trace log node");
ok(node.textContent.includes("console.trace()"),
"trace log node includes console.trace()");
ok(node.textContent.includes("promise callback"),
"trace log node includes promise callback");
ok(node.textContent.includes("setTimeout handler"),
"trace log node includes setTimeout handler");
// The expected stack trace object.
let stacktrace = [
{
columnNumber: 3,
filename: TEST_URI,
functionName: "inner",
language: 2,
lineNumber: 9
},
{
asyncCause: "promise callback",
columnNumber: 1,
filename: TEST_URI,
functionName: "time1",
language: 2,
lineNumber: 13,
},
{
asyncCause: "setTimeout handler",
columnNumber: 1,
filename: TEST_URI,
functionName: "",
language: 2,
lineNumber: 18,
}
];
let obj = node._messageObject;
ok(obj, "console.trace message object");
ok(obj._stacktrace, "found stacktrace object");
is(obj._stacktrace.toSource(), stacktrace.toSource(),
"stacktrace is correct");
});
Attachment #8672029 -
Flags: review?(bgrinstead) → review+
| Assignee | ||
Comment 15•10 years ago
|
||
(In reply to Andrea Marchesini (:baku) from comment #13)
> Comment on attachment 8672029 [details] [diff] [review]
> make Console.trace follow async parents
>
> Review of attachment 8672029 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> ::: dom/webidl/Console.webidl
> @@ +80,5 @@
> > unsigned long lineNumber = 0;
> > unsigned long columnNumber = 0;
> > DOMString functionName = "";
> > unsigned long language = 0;
> > + DOMString? asyncCause;
>
> what about: DOMString asyncCause = ""; ?
I wanted asyncCause not to be present unless it was explicitly set.
This approach makes it appear as the empty string.
| Assignee | ||
Comment 16•10 years ago
|
||
Use Brian's test case.
Attachment #8672029 -
Attachment is obsolete: true
| Assignee | ||
Updated•10 years ago
|
Attachment #8675796 -
Flags: review+
| Assignee | ||
Comment 17•10 years ago
|
||
| Assignee | ||
Comment 18•10 years ago
|
||
(In reply to Brian Grinstead [:bgrins] from comment #14)
> Comment on attachment 8672029 [details] [diff] [review]
> make Console.trace follow async parents
>
> Review of attachment 8672029 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> Looks great! Should we file a new bug for these async causes to bubble up in
> the UI when an error is thrown in an async callback?
Maybe bug 1141222 is related? I am not sure.
I think it doesn't hurt to file another bug.
| Assignee | ||
Comment 19•10 years ago
|
||
This makes a trivial change to a test case that was affected by the
patch. I'm planning to carry over the r+.
Attachment #8675796 -
Attachment is obsolete: true
| Assignee | ||
Updated•10 years ago
|
Attachment #8676900 -
Flags: review+
| Assignee | ||
Comment 20•10 years ago
|
||
| Assignee | ||
Comment 21•10 years ago
|
||
| Assignee | ||
Updated•10 years ago
|
Keywords: checkin-needed
Comment 22•10 years ago
|
||
Keywords: checkin-needed
Comment 23•10 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
status-firefox44:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 44
Updated•8 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•