Skip to content

Commit 548235d

Browse files
eps1lonhoxyq
andauthored
Enable React performance tracks in Canary (#34665)
Co-authored-by: Ruslan Lesiutin <[email protected]>
1 parent 1f460f3 commit 548235d

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

packages/react-devtools-shared/src/__tests__/preprocessData-test.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,8 @@ let utils;
2424
let assertLog;
2525
let waitFor;
2626

27-
// This flag is on experimental which disables timeline profiler.
28-
const enableComponentPerformanceTrack =
29-
React.version.startsWith('19') && React.version.includes('experimental');
30-
3127
describe('Timeline profiler', () => {
32-
if (enableComponentPerformanceTrack) {
33-
test('no tests', () => {});
34-
// Ignore all tests.
35-
return;
36-
}
37-
3828
describe('User Timing API', () => {
39-
if (enableComponentPerformanceTrack) {
40-
return;
41-
}
4229
let currentlyNotClearedMarks;
4330
let registeredMarks;
4431
let featureDetectionMarkName = null;
@@ -168,6 +155,7 @@ describe('Timeline profiler', () => {
168155
});
169156

170157
// @reactVersion >= 18.0
158+
// @reactVersion < 19.2
171159
it('should return array of lane numbers from bitmask string', () => {
172160
expect(getLanesFromTransportDecimalBitmask('1')).toEqual([0]);
173161
expect(getLanesFromTransportDecimalBitmask('512')).toEqual([9]);
@@ -184,6 +172,7 @@ describe('Timeline profiler', () => {
184172
});
185173

186174
// @reactVersion >= 18.0
175+
// @reactVersion < 19.2
187176
it('should return empty array if laneBitmaskString is not a bitmask', () => {
188177
expect(getLanesFromTransportDecimalBitmask('')).toEqual([]);
189178
expect(getLanesFromTransportDecimalBitmask('hello')).toEqual([]);
@@ -192,6 +181,7 @@ describe('Timeline profiler', () => {
192181
});
193182

194183
// @reactVersion >= 18.0
184+
// @reactVersion < 19.2
195185
it('should ignore lanes outside REACT_TOTAL_NUM_LANES', () => {
196186
const REACT_TOTAL_NUM_LANES =
197187
require('react-devtools-timeline/src/constants').REACT_TOTAL_NUM_LANES;
@@ -317,11 +307,13 @@ describe('Timeline profiler', () => {
317307
});
318308

319309
// @reactVersion >= 18.0
310+
// @reactVersion < 19.2
320311
it('should throw given an empty timeline', async () => {
321312
await expect(async () => preprocessData([])).rejects.toThrow();
322313
});
323314

324315
// @reactVersion >= 18.0
316+
// @reactVersion < 19.2
325317
it('should throw given a timeline with no Profile event', async () => {
326318
const randomSample = createUserTimingEntry({
327319
dur: 100,
@@ -338,6 +330,7 @@ describe('Timeline profiler', () => {
338330
});
339331

340332
// @reactVersion >= 18.0
333+
// @reactVersion < 19.2
341334
it('should throw given a timeline without an explicit profiler version mark nor any other React marks', async () => {
342335
const cpuProfilerSample = creactCpuProfilerSample();
343336

@@ -349,6 +342,7 @@ describe('Timeline profiler', () => {
349342
});
350343

351344
// @reactVersion >= 18.0
345+
// @reactVersion < 19.2
352346
it('should throw given a timeline with React scheduling marks, but without an explicit profiler version mark', async () => {
353347
const cpuProfilerSample = creactCpuProfilerSample();
354348
const scheduleRenderSample = createUserTimingEntry({
@@ -363,6 +357,7 @@ describe('Timeline profiler', () => {
363357
});
364358

365359
// @reactVersion >= 18.0
360+
// @reactVersion < 19.2
366361
it('should return empty data given a timeline with no React scheduling profiling marks', async () => {
367362
const cpuProfilerSample = creactCpuProfilerSample();
368363
const randomSample = createUserTimingEntry({
@@ -467,6 +462,7 @@ describe('Timeline profiler', () => {
467462
});
468463

469464
// @reactVersion >= 18.0
465+
// @reactVersion < 19.2
470466
it('should process legacy data format (before lane labels were added)', async () => {
471467
const cpuProfilerSample = creactCpuProfilerSample();
472468

@@ -854,6 +850,7 @@ describe('Timeline profiler', () => {
854850
`);
855851
});
856852

853+
// @reactVersion < 19.2
857854
it('should process a sample createRoot render sequence', async () => {
858855
function App() {
859856
const [didMount, setDidMount] = React.useState(false);
@@ -1190,6 +1187,7 @@ describe('Timeline profiler', () => {
11901187
});
11911188

11921189
// @reactVersion >= 18.0
1190+
// @reactVersion < 19.2
11931191
it('should populate other user timing marks', async () => {
11941192
const userTimingData = createUserTimingData([]);
11951193
userTimingData.push(
@@ -1240,6 +1238,7 @@ describe('Timeline profiler', () => {
12401238
});
12411239

12421240
// @reactVersion >= 18.0
1241+
// @reactVersion < 19.2
12431242
it('should include a suspended resource "displayName" if one is set', async () => {
12441243
let promise = null;
12451244
let resolvedValue = null;
@@ -1381,6 +1380,7 @@ describe('Timeline profiler', () => {
13811380
});
13821381

13831382
// @reactVersion >= 18.2
1383+
// @reactVersion < 19.2
13841384
it('should not warn when React finishes a previously long (async) update with a short (sync) update inside of an event', async () => {
13851385
function Yield({id, value}) {
13861386
Scheduler.log(`${id}:${value}`);
@@ -1443,6 +1443,7 @@ describe('Timeline profiler', () => {
14431443

14441444
describe('nested updates', () => {
14451445
// @reactVersion >= 18.2
1446+
// @reactVersion < 19.2
14461447
it('should not warn about short nested (state) updates during layout effects', async () => {
14471448
function Component() {
14481449
const [didMount, setDidMount] = React.useState(false);
@@ -1474,6 +1475,7 @@ describe('Timeline profiler', () => {
14741475
});
14751476

14761477
// @reactVersion >= 18.2
1478+
// @reactVersion < 19.2
14771479
it('should not warn about short (forced) updates during layout effects', async () => {
14781480
class Component extends React.Component {
14791481
_didMount: boolean = false;
@@ -1629,6 +1631,7 @@ describe('Timeline profiler', () => {
16291631
});
16301632

16311633
// @reactVersion >= 18.2
1634+
// @reactVersion < 19.2
16321635
it('should not warn about transition updates scheduled during commit phase', async () => {
16331636
function Component() {
16341637
const [value, setValue] = React.useState(0);
@@ -1770,6 +1773,7 @@ describe('Timeline profiler', () => {
17701773

17711774
describe('errors thrown while rendering', () => {
17721775
// @reactVersion >= 18.0
1776+
// @reactVersion < 19.2
17731777
it('shoult parse Errors thrown during render', async () => {
17741778
jest.spyOn(console, 'error');
17751779

@@ -1818,6 +1822,7 @@ describe('Timeline profiler', () => {
18181822
// This also tests an edge case where a component suspends while profiling
18191823
// before the first commit is logged (so the lane-to-labels map will not yet exist).
18201824
// @reactVersion >= 18.2
1825+
// @reactVersion < 19.2
18211826
it('should warn about suspending during an update', async () => {
18221827
let promise = null;
18231828
let resolvedValue = null;
@@ -1884,6 +1889,7 @@ describe('Timeline profiler', () => {
18841889
});
18851890

18861891
// @reactVersion >= 18.2
1892+
// @reactVersion < 19.2
18871893
it('should not warn about suspending during an transition', async () => {
18881894
let promise = null;
18891895
let resolvedValue = null;
@@ -2152,6 +2158,7 @@ describe('Timeline profiler', () => {
21522158
`);
21532159
});
21542160

2161+
// @reactVersion < 19.2
21552162
it('should process a sample createRoot render sequence', async () => {
21562163
function App() {
21572164
const [didMount, setDidMount] = React.useState(false);

packages/shared/ReactFeatureFlags.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export const enableProfilerTimer = __PROFILE__;
229229
// Component rendering tracks to show up in the Performance tab.
230230
// This flag will be used for both Server Component and Client Component tracks.
231231
// All calls should also be gated on enableProfilerTimer.
232-
export const enableComponentPerformanceTrack = __EXPERIMENTAL__;
232+
export const enableComponentPerformanceTrack: boolean = true;
233233

234234
// Adds user timing marks for e.g. state updates, suspense, and work loop stuff,
235235
// for an experimental timeline tool.

packages/shared/forks/ReactFeatureFlags.native-oss.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ export const enableObjectFiber: boolean = false;
4141
export const enablePostpone: boolean = false;
4242
export const enableReactTestRendererWarning: boolean = false;
4343
export const enableRetryLaneExpiration: boolean = false;
44-
export const enableSchedulingProfiler: boolean = __PROFILE__;
45-
export const enableComponentPerformanceTrack: boolean = false;
44+
export const enableComponentPerformanceTrack: boolean = true;
45+
export const enableSchedulingProfiler: boolean =
46+
!enableComponentPerformanceTrack && __PROFILE__;
4647
export const enableScopeAPI: boolean = false;
4748
export const enableEagerAlternateStateNodeCleanup: boolean = true;
4849
export const enableSuspenseAvoidThisFallback: boolean = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const enableSchedulingProfiler: boolean = false;
1515
export const enableProfilerTimer: boolean = __PROFILE__;
1616
export const enableProfilerCommitHooks: boolean = __PROFILE__;
1717
export const enableProfilerNestedUpdatePhase: boolean = __PROFILE__;
18-
export const enableComponentPerformanceTrack: boolean = false;
18+
export const enableComponentPerformanceTrack: boolean = true;
1919
export const enableUpdaterTracking: boolean = false;
2020
export const enableLegacyCache: boolean = __EXPERIMENTAL__;
2121
export const enableAsyncIterableChildren: boolean = false;

0 commit comments

Comments
 (0)