Skip to content

Commit d504824

Browse files
author
Brian Vaughn
authored
Enable scheduling profiler flag in react-dom/testing builds (#23142)
1 parent 790b524 commit d504824

File tree

5 files changed

+33
-23
lines changed

5 files changed

+33
-23
lines changed

packages/react-devtools-shared/src/backend/profilingHooks.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function createProfilingHooks({
7575
reactVersion,
7676
}: {|
7777
getDisplayNameForFiber: (fiber: Fiber) => string | null,
78-
getLaneLabelMap?: () => Map<Lane, string>,
78+
getLaneLabelMap?: () => Map<Lane, string> | null,
7979
reactVersion: string,
8080
|}): DevToolsProfilingHooks {
8181
function markMetadata() {
@@ -108,8 +108,10 @@ export function createProfilingHooks({
108108

109109
if (typeof getLaneLabelMap === 'function') {
110110
const map = getLaneLabelMap();
111-
const labels = Array.from(map.values()).join(',');
112-
markAndClear(`--react-lane-labels-${labels}`);
111+
if (map != null) {
112+
const labels = Array.from(map.values()).join(',');
113+
markAndClear(`--react-lane-labels-${labels}`);
114+
}
113115
}
114116
}
115117

packages/react-devtools-shared/src/backend/types.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export type ReactRenderer = {
152152
scheduleRefresh?: Function,
153153
// 18.0+
154154
injectProfilingHooks?: (profilingHooks: DevToolsProfilingHooks) => void,
155-
getLaneLabelMap?: () => Map<Lane, string>,
155+
getLaneLabelMap?: () => Map<Lane, string> | null,
156156
...
157157
};
158158

packages/react-reconciler/src/ReactFiberDevToolsHook.new.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,21 @@ function injectProfilingHooks(profilingHooks: DevToolsProfilingHooks): void {
230230
injectedProfilingHooks = profilingHooks;
231231
}
232232

233-
function getLaneLabelMap(): Map<Lane, string> {
234-
const map: Map<Lane, string> = new Map();
233+
function getLaneLabelMap(): Map<Lane, string> | null {
234+
if (enableSchedulingProfiler) {
235+
const map: Map<Lane, string> = new Map();
235236

236-
let lane = 1;
237-
for (let index = 0; index < TotalLanes; index++) {
238-
const label = ((getLabelForLane(lane): any): string);
239-
map.set(lane, label);
240-
lane *= 2;
241-
}
237+
let lane = 1;
238+
for (let index = 0; index < TotalLanes; index++) {
239+
const label = ((getLabelForLane(lane): any): string);
240+
map.set(lane, label);
241+
lane *= 2;
242+
}
242243

243-
return map;
244+
return map;
245+
} else {
246+
return null;
247+
}
244248
}
245249

246250
export function markCommitStarted(lanes: Lanes): void {

packages/react-reconciler/src/ReactFiberDevToolsHook.old.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,21 @@ function injectProfilingHooks(profilingHooks: DevToolsProfilingHooks): void {
230230
injectedProfilingHooks = profilingHooks;
231231
}
232232

233-
function getLaneLabelMap(): Map<Lane, string> {
234-
const map: Map<Lane, string> = new Map();
233+
function getLaneLabelMap(): Map<Lane, string> | null {
234+
if (enableSchedulingProfiler) {
235+
const map: Map<Lane, string> = new Map();
235236

236-
let lane = 1;
237-
for (let index = 0; index < TotalLanes; index++) {
238-
const label = ((getLabelForLane(lane): any): string);
239-
map.set(lane, label);
240-
lane *= 2;
241-
}
237+
let lane = 1;
238+
for (let index = 0; index < TotalLanes; index++) {
239+
const label = ((getLabelForLane(lane): any): string);
240+
map.set(lane, label);
241+
lane *= 2;
242+
}
242243

243-
return map;
244+
return map;
245+
} else {
246+
return null;
247+
}
244248
}
245249

246250
export function markCommitStarted(lanes: Lanes): void {

packages/shared/forks/ReactFeatureFlags.testing.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import typeof * as ExportsType from './ReactFeatureFlags.testing';
1212

1313
export const debugRenderPhaseSideEffectsForStrictMode = false;
1414
export const enableDebugTracing = false;
15-
export const enableSchedulingProfiler = false;
15+
export const enableSchedulingProfiler = __PROFILE__;
1616
export const warnAboutDeprecatedLifecycles = true;
1717
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
1818
export const enableProfilerTimer = __PROFILE__;

0 commit comments

Comments
 (0)