feat: use scoped field in trace events to propagate stack traces #213
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This updates the frontend to use the
args.data.rnStackTracefield of the trace event for displaying stack traces that were explicitly specified by the trace event engine.From my understanding, whenever there is a
console.timeStamporperformance.measurecall, Chromium asks V8 to take a sample and it receives an id in exchange. Then, this id is used for tagging samples, user timing events, and async stack tagging entries (viaconsole.createTask). In the end, the frontend will connect all these things together at the trace processing stage and will form a stack trace.Hermes doesn't have proper async stack traces, it also doesn't support sub-sampling at the moment, so there are no stable identifiers that we could use to match samples with stack traces.
There is an advantage to this approach. If you look at CDT's code, for some reason it's default behaviour is to try to guess the stack trace by looking at the sample. For Components track, this ofter points to the component definition, not the JSX declaration that we were trying point to by using
console.createTaskfor every unique JSX call.With this approach, we will actually show the correct JSX location of where the currently selected entry on a Components track was rendered in its owner, which is far more useful. You can easily grep the component implementation by its name, but it is not obvious to find where this component was rendered.
The only significant drawback is that this is yet another divergence from Web, basically if you upload RN's trace to the browser, you won't see stack traces. This is also fine, because even if we had a parity with browser, these traces won't get symbolicated.
Test plan
Upstreaming plan
devtools-frontendrepo following the contribution guide for Meta employees OR contribution guide.