Skip to content

Commit 54de776

Browse files
committed
fix: correct render start time
1 parent 1beb7bb commit 54de776

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/v3/hooks.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,8 @@ export const generateUseBeacon =
6161

6262
traceManager.processSpan(renderStartTaskEntry)
6363

64-
// React's concurrent rendering might pause and discard a render,
65-
// which would mean that an effect scheduled for that render does not execute because the render itself was not committed to the DOM.
66-
// we want to store the first time that the render was scheduled as the start time of rendering
6764
const renderStartRef = useRef<Timestamp | undefined>()
68-
if (!renderStartRef.current) {
69-
renderStartRef.current = renderStartTaskEntry.startTime
70-
}
65+
renderStartRef.current = renderStartTaskEntry.startTime
7166

7267
// Beacon effect for tracking 'component-render'. This will fire after every render as it does not have any dependencies:
7368
useEffect(() => {

src/v3/recordingComputeUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ function getComputedRenderBeaconSpans<
229229

230230
if (entry.span.type === 'component-render') {
231231
spanTimes.renderCount += 1
232-
// If there was a pending render start, include the time from that start to this render
232+
// React's concurrent rendering might pause and discard a render,
233+
// which would mean that an effect scheduled for that render does not execute because the render itself was not committed to the DOM.
234+
// we want to extend the the render span backwards, to first time that rendering was scheduled as the start time of rendering
233235
if (spanTimes.lastRenderStartTime !== undefined) {
234236
spanTimes.sumOfDurations +=
235237
start + duration - spanTimes.lastRenderStartTime

0 commit comments

Comments
 (0)