Closed Bug 1142577 Opened 9 years ago Closed 9 years ago

Use JS::AutoSetAsyncStackForNewCalls for setTimeout and setInterval

Categories

(Core :: DOM: Core & HTML, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1148593

People

(Reporter: fitzgen, Assigned: fitzgen)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Attachments

(2 files, 7 obsolete files)

16.84 KB, patch
fitzgen
: review+
Details | Diff | Splinter Review
4.66 KB, patch
fitzgen
: review+
Details | Diff | Splinter Review
This way, we will get nice stacks that span asynchronous operations.
Depends on: 1083359
Assignee: nobody → nfitzgerald
Status: NEW → ASSIGNED
Summary: Use JS::AutoSetAsyncStackForNewCalls for setTimeout, setInterval, and requestAnimationFrame → Use JS::AutoSetAsyncStackForNewCalls for setTimeout and setInterval
Just realized that this doesn't do much yet because only DOM exceptions use SavedFrame stacks at the moment. Gotta fix bug 1038238 before this is really useful.
Depends on: 1038238
Comment on attachment 8577662 [details] [diff] [review]
Part 1: Add a test for async stacks across setTimeout

Review of attachment 8577662 [details] [diff] [review]:
-----------------------------------------------------------------

Test this cross-global too, to make sure there are no compartment mismatches or anything.
Attachment #8577662 - Flags: review?(khuey) → review-
Attachment #8577662 - Attachment is obsolete: true
Attachment #8578807 - Flags: review?(khuey)
Added a version that uses setTimeout and a callback from different compartments.
Attachment #8578807 - Attachment is obsolete: true
Attachment #8586326 - Flags: review+
Rebased again and fixed a bug with interaction between the CC and the GC and a lack of mozilla::HoldJSObjects calls.

New try push: https://treeherder.mozilla.org/#/jobs?repo=try&revision=c0b24ce8735f
Looks like I just need to update a Promise + stacks test that is using setTimeout and getting more stack frames than it used to.
Depends on: 1152893
Does implementing this for setTimeout also include setImmediate as a result?
Flags: needinfo?(nfitzgerald)
(In reply to :Paolo Amadini from comment #16)
> Does implementing this for setTimeout also include setImmediate as a result?

These patches don't.

Also, it seems setImmediate is only implemented for WorkerDebuggerGlobalScope -- not for general windows. This matches my recollection that we weren't going to implement setImmediate in Gecko for some reason or other.
Flags: needinfo?(nfitzgerald)
(In reply to Nick Fitzgerald [:fitzgen] from comment #17)
> (In reply to :Paolo Amadini from comment #16)
> > Does implementing this for setTimeout also include setImmediate as a result?
> 
> These patches don't.
> 
> Also, it seems setImmediate is only implemented for
> WorkerDebuggerGlobalScope -- not for general windows. This matches my
> recollection that we weren't going to implement setImmediate in Gecko for
> some reason or other.

WorkerDebuggerGlobalScope::setImmediate is a really special case. We can't use the WorkerGlobalScope version of setTimeout and setInterval in the worker debugger, because those functions are not aware of the debugger event queue. Consequently, they won't work inside nested event loops.

We need some way to schedule a runnable on the debugger's event queue, mainly so we can use Promise.jsm promises in the worker debugger, but we don't need full timer support. Which is why setImmediate is defined on WorkerDebuggerGlobalScope, and nowhere else.

Hope that helps.
FWIW this is fixed more generically by the patch in bug 1148593.
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: