Testcase with audio worklets does not get proper stack unwinding on the Profiler
Categories
(Core :: Gecko Profiler, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox151 | --- | fixed |
People
(Reporter: mayankleoboy1, Assigned: canova, NeedInfo)
References
(Blocks 1 open bug)
Details
(Whiteboard: [fp])
Attachments
(2 files)
- Open testcase
- Enter 5000, 1
- Click Register
- Start profiler
- Click Run
- Let it run fir 30s
- Capture the profile
AR: parts of the profile on the GraphRunner thread dont seem to get stack unwinding.
ER: They should?
| Assignee | ||
Comment 1•4 days ago
|
||
Thanks for reporting! Indeed stack walking looks very broken.
Looking at the code, first I suspected that maybe we are calling an asm function without proc attributes for Windows stack walking (similar to bug 1981690) but I was wrong because I was having the same issue on macOS.
Looking at the code where we add the "Worklet Process" frame label, it looks like it's heavily JS engine related, so it's likely that some JS functions are calling and we are failing to stack walk there.
And looking at the WorkletThread.cpp around the place where we initialize the JS context, we are not actually registering that JS context with the profiler. We normally register the main thread and the worker threads. That's probably the reason why we are actually failing to stack walk here.
Validating my assumption now.
Updated•4 days ago
|
| Assignee | ||
Comment 2•4 days ago
|
||
Yep, this stack looks better: https://share.firefox.dev/4c7fIDN
| Assignee | ||
Comment 3•4 days ago
|
||
AudioWorklet's process() calls run on the GraphRunner thread (or DOM
Worklet thread), which creates a WorkletJSContext via
EnsureCycleCollectedJSContext(). But, unlike Workers and the main
thread, this context was never registered with the profiler via
PROFILER_SET_JS_CONTEXT. As a result, when the profiler sampled these
threads during JS execution, it could only unwind native frames up to
the JS entry point but not the JS frames within process() itself.
This patch fixes this by calling PROFILER_SET_JS_CONTEXT after context
initialization and PROFILER_CLEAR_JS_CONTEXT before teardown.
| Reporter | ||
Comment 6•1 day ago
|
||
On the latest Nightly, I still see incomplete stacks: https://share.firefox.dev/4dLRpgN
| Assignee | ||
Comment 7•1 day ago
|
||
Hmm, I tried on the latest Nightly again on macOS and it worked on my machine: https://share.firefox.dev/4bWcvH4 It might also be a Windows only issue. I'll check it on Windows later.
Description
•