Open Beanyy opened 1 month ago
Thanks for reporting this, it certainly seems like a bug when this codepath is hit, since the timestamp is uninitialised. However, I'm slightly surprised that you're hitting it at all, given that there aren't really any cases where the profiler is suspended but there is no recorded stack available. Could you share more about how you're getting into that state?
Bug Description
When using the Profiler, sometimes the first sample has a timestamp of zero, where the other samples have a timestamp very far off from zero. When viewing the trace, the total duration ends up being very long (like 100s) even though the capture of the trace was just 5s long.
I've narrowed down the issue to right here: https://github.com/facebook/hermes/blob/main/lib/VM/Profiler/SamplingProfilerSampler.cpp#L74
If the code path reaches here for the first sample,
sampleStorage_
is still in its initial state without being assigned a new sample, and then that is appended to thesampledStacks_
array. Locally, I have fixed this issue by just addingreturn true
aftersampledStackDepth_ = 0;
, but I'm unsure if that's the right approach to resolving this issue and would like some guidance on how you think this should be resolved.Thanks
gradle clean
and confirmed this bug does not occur with JSCHermes git revision (if applicable): React Native version: OS: Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64):
Steps To Reproduce
1. 2.
code example:
The Expected Behavior