Skip to content

Commit d3068e8

Browse files
author
Brian Vaughn
committed
Removed some version 0 backwards compat checks in preprocessData
1 parent ee7f3f2 commit d3068e8

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

packages/react-devtools-scheduling-profiler/src/import-worker/preprocessData.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import type {
1717
BatchUID,
1818
Flamechart,
1919
NativeEvent,
20+
Phase,
2021
ReactLane,
2122
ReactComponentMeasure,
2223
ReactMeasureType,
@@ -315,6 +316,7 @@ function processTimelineEvent(
315316
let warning = null;
316317
if (state.measureStack.find(({type}) => type === 'commit')) {
317318
// TODO (scheduling profiler) Only warn if the subsequent update is longer than some threshold.
319+
// This might be easier to do if we separated warnings into a second pass.
318320
warning = WARNING_STRINGS.NESTED_UPDATE;
319321
}
320322

@@ -331,6 +333,7 @@ function processTimelineEvent(
331333
let warning = null;
332334
if (state.measureStack.find(({type}) => type === 'commit')) {
333335
// TODO (scheduling profiler) Only warn if the subsequent update is longer than some threshold.
336+
// This might be easier to do if we separated warnings into a second pass.
334337
warning = WARNING_STRINGS.NESTED_UPDATE;
335338
}
336339

@@ -345,25 +348,18 @@ function processTimelineEvent(
345348

346349
// React Events - suspense
347350
else if (name.startsWith('--suspense-suspend-')) {
348-
const [id, componentName, ...rest] = name.substr(19).split('-');
351+
const [id, componentName, phase, laneBitmaskString] = name
352+
.substr(19)
353+
.split('-');
354+
const lanes = getLanesFromTransportDecimalBitmask(laneBitmaskString);
349355

350-
// Older versions of the scheduling profiler data didn't contain phase or lane values.
351-
let phase = null;
356+
// TODO It's possible we don't have lane-to-label mapping yet (since it's logged during commit phase)
357+
// We may need to do this sort of error checking in a separate pass.
352358
let warning = null;
353-
if (rest.length === 3) {
354-
switch (rest[0]) {
355-
case 'mount':
356-
case 'update':
357-
phase = rest[0];
358-
break;
359-
}
360-
361-
if (phase === 'update') {
362-
const laneLabels = rest[2];
363-
// HACK This is a bit gross but the numeric lane value might change between render versions.
364-
if (!laneLabels.includes('Transition')) {
365-
warning = WARNING_STRINGS.SUSPENDD_DURING_UPATE;
366-
}
359+
if (phase === 'update') {
360+
// HACK This is a bit gross but the numeric lane value might change between render versions.
361+
if (lanes.some(lane => laneToLabelMap.get(lane) === 'Transition')) {
362+
warning = WARNING_STRINGS.SUSPENDD_DURING_UPATE;
367363
}
368364
}
369365

@@ -392,7 +388,7 @@ function processTimelineEvent(
392388
depth,
393389
duration: null,
394390
id,
395-
phase,
391+
phase: ((phase: any): Phase),
396392
resolution: 'unresolved',
397393
resuspendTimestamps: null,
398394
timestamp: startTime,

packages/react-devtools-scheduling-profiler/src/types.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ export type ReactScheduleForceUpdateEvent = {|
5252
+type: 'schedule-force-update',
5353
|};
5454

55+
export type Phase = 'mount' | 'update';
56+
5557
export type SuspenseEvent = {|
5658
...BaseReactEvent,
5759
depth: number,
5860
duration: number | null,
5961
+id: string,
60-
+phase: 'mount' | 'update' | null,
62+
+phase: Phase | null,
6163
resolution: 'rejected' | 'resolved' | 'unresolved',
6264
resuspendTimestamps: Array<number> | null,
6365
+type: 'suspense',

0 commit comments

Comments
 (0)