351
_closedReason: mixed,
352
_tempRefs: void | TemporaryReferenceSet, // the set temporary references can be resolved from
353
_timeOrigin: number, // Profiling-only
354
+ _pendingInitialRender: null | TimeoutID, // Profiling-only,
355
_pendingChunks: number, // DEV-only
356
_weakResponse: WeakResponse, // DEV-only
357
_debugRootOwner?: null | ReactComponentInfo, // DEV-only
445
function createPendingChunk<T>(response: Response): PendingChunk<T> {
446
if (__DEV__) {
447
// Retain a strong reference to the Response while we wait for the result.
447
- response._pendingChunks++;
448
- response._weakResponse.response = response;
448
+ if (response._pendingChunks++ === 0) {
449
+ response._weakResponse.response = response;
450
+ if (response._pendingInitialRender !== null) {
451
+ clearTimeout(response._pendingInitialRender);
452
+ response._pendingInitialRender = null;
453
+ }
454
+ }
455
}
456
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
457
return new ReactPromise(PENDING, null, null);
463
// We're no longer waiting for any more chunks. We can release the strong reference
464
// to the response. We'll regain it if we ask for any more data later on.
465
response._weakResponse.response = null;
466
+ // Wait a short period to see if any more chunks get asked for. E.g. by a React render.
467
+ // These chunks might discover more pending chunks.
468
+ // If we don't ask for more then we assume that those chunks weren't blocking initial
469
+ // render and are excluded from the performance track.
470
+ response._pendingInitialRender = setTimeout(
471
+ flushInitialRenderPerformance.bind(null, response),
472
+ 100,
473
+ );
474
}
475
}
476
}
882
response._debugChannel = undefined;
883
}
884
}
871
- if (enableProfilerTimer && enableComponentPerformanceTrack) {
872
- if (response._replayConsole) {
873
- markAllTracksInOrder();
874
- flushComponentPerformance(
875
- response,
876
- getChunk(response, 0),
877
- 0,
878
- -Infinity,
879
- -Infinity,
880
- );
881
- }
882
- }
885
}
886
887
function nullRefGetter() {
2107
this._tempRefs = temporaryReferences;
2108
if (enableProfilerTimer && enableComponentPerformanceTrack) {
2109
this._timeOrigin = 0;
2110
+ this._pendingInitialRender = null;
2111
}
2112
if (__DEV__) {
2113
this._pendingChunks = 0;
3494
return previousResult;
3495
}
3496
const children = root._children;
3494
- if (root.status === RESOLVED_MODEL) {
3495
- // If the model is not initialized by now, do that now so we can find its
3496
- // children. This part is a little sketchy since it significantly changes
3497
- // the performance characteristics of the app by profiling.
3498
- initializeModelChunk(root);
3499
- }
3497
3498
// First find the start time of the first component to know if it was running
3499
// in parallel with the previous.
3700
return result;
3701
}
3702
3703
+function flushInitialRenderPerformance(response: Response): void {
3704
+ if (
3705
+ enableProfilerTimer &&
3706
+ enableComponentPerformanceTrack &&
3707
+ response._replayConsole
3708
+ ) {
3709
+ const rootChunk = getChunk(response, 0);
3710
+ if (isArray(rootChunk._children)) {
3711
+ markAllTracksInOrder();
3712
+ flushComponentPerformance(response, rootChunk, 0, -Infinity, -Infinity);
3713
+ }
3714
+ }
3715
+}
3716
+
3717
function processFullBinaryRow(
3718
response: Response,
3719
id: number,