react-scan icon indicating copy to clipboard operation
react-scan copied to clipboard

Bug: under tracking javascript time

Open RobPruzan opened this issue 11 months ago • 0 comments

React Scan tracks the JavaScript phase of interaction times by tracking the time from the first event handler, to the last event handler. This misses async work done in things like requestAnimationFrom.

For example:

requestAnimationFrame(() => setState(prev => prev + 1))

Would not get tracked under JS time, but would get tracked under render time. This makes it possible to violate the invariant that JavaScript time must be a superset of render time.

This can be partially fixed by "backfilling" js time by the render time accumulated during the requestAnimationFrame stage, and monkey patching requestAnimationFrame (and other async API's) to track the time of the callbacks, and back filling that into JS time.

RobPruzan avatar Feb 28 '25 01:02 RobPruzan