Revert "Re-enabled DebugTracing feature for old reconciler fork (#19142)" (#19159)
This reverts commit cc7c1aece46a6b69b41958d731e0fd27c94bfc6c.
Luna Ruan committed
Jun 18, 2020 at 18:18 UTC
d1d9054e097f788eb0e5ebc45c11a2fb4603f1b6
7 files changed
+47
-189
packages/react-reconciler/src/DebugTracing.js
+12
-17
@@ -7,7 +7,6 @@
7
* @flow
8
*/
9
10
-import type {Lane, Lanes} from './ReactFiberLane';
10
import type {Wakeable} from 'shared/ReactTypes';
11
12
import {enableDebugTracing} from 'shared/ReactFeatureFlags';
@@ -18,10 +17,6 @@ let nativeConsoleLog: null | Function = null;
17
const pendingGroupArgs: Array<any> = [];
18
let printedGroupIndex: number = -1;
19
21
-function formatLanes(laneOrLanes: Lane | Lanes): string {
22
- return '0b' + (laneOrLanes: any).toString(2).padStart(31, '0');
23
-}
24
-
20
function group(...groupArgs): void {
21
pendingGroupArgs.push(groupArgs);
22
@@ -62,11 +57,11 @@ function log(...logArgs): void {
57
const REACT_LOGO_STYLE =
58
'background-color: #20232a; color: #61dafb; padding: 0 2px;';
59
65
-export function logCommitStarted(lanes: Lanes): void {
60
+export function logCommitStarted(priorityLabel: string): void {
61
if (__DEV__) {
62
if (enableDebugTracing) {
63
group(
69
- `%c⚛️%c commit%c (${formatLanes(lanes)})`,
64
+ `%c⚛️%c commit%c (priority: ${priorityLabel})`,
65
REACT_LOGO_STYLE,
66
'',
67
'font-weight: normal;',
@@ -133,11 +128,11 @@ export function logComponentSuspended(
128
}
129
}
130
136
-export function logLayoutEffectsStarted(lanes: Lanes): void {
131
+export function logLayoutEffectsStarted(priorityLabel: string): void {
132
if (__DEV__) {
133
if (enableDebugTracing) {
134
group(
140
- `%c⚛️%c layout effects%c (${formatLanes(lanes)})`,
135
+ `%c⚛️%c layout effects%c (priority: ${priorityLabel})`,
136
REACT_LOGO_STYLE,
137
'',
138
'font-weight: normal;',
@@ -154,11 +149,11 @@ export function logLayoutEffectsStopped(): void {
149
}
150
}
151
157
-export function logPassiveEffectsStarted(lanes: Lanes): void {
152
+export function logPassiveEffectsStarted(priorityLabel: string): void {
153
if (__DEV__) {
154
if (enableDebugTracing) {
155
group(
161
- `%c⚛️%c passive effects%c (${formatLanes(lanes)})`,
156
+ `%c⚛️%c passive effects%c (priority: ${priorityLabel})`,
157
REACT_LOGO_STYLE,
158
'',
159
'font-weight: normal;',
@@ -175,11 +170,11 @@ export function logPassiveEffectsStopped(): void {
170
}
171
}
172
178
-export function logRenderStarted(lanes: Lanes): void {
173
+export function logRenderStarted(priorityLabel: string): void {
174
if (__DEV__) {
175
if (enableDebugTracing) {
176
group(
182
- `%c⚛️%c render%c (${formatLanes(lanes)})`,
177
+ `%c⚛️%c render%c (priority: ${priorityLabel})`,
178
REACT_LOGO_STYLE,
179
'',
180
'font-weight: normal;',
@@ -198,12 +193,12 @@ export function logRenderStopped(): void {
193
194
export function logForceUpdateScheduled(
195
componentName: string,
201
- lane: Lane,
196
+ priorityLabel: string,
197
): void {
198
if (__DEV__) {
199
if (enableDebugTracing) {
200
log(
206
- `%c⚛️%c ${componentName} forced update %c(${formatLanes(lane)})`,
201
+ `%c⚛️%c ${componentName} forced update %c(priority: ${priorityLabel})`,
202
REACT_LOGO_STYLE,
203
'color: #db2e1f; font-weight: bold;',
204
'',
@@ -214,13 +209,13 @@ export function logForceUpdateScheduled(
209
210
export function logStateUpdateScheduled(
211
componentName: string,
217
- lane: Lane,
212
+ priorityLabel: string,
213
payloadOrAction: any,
214
): void {
215
if (__DEV__) {
216
if (enableDebugTracing) {
217
log(
223
- `%c⚛️%c ${componentName} updated state %c(${formatLanes(lane)})`,
218
+ `%c⚛️%c ${componentName} updated state %c(priority: ${priorityLabel})`,
219
REACT_LOGO_STYLE,
220
'color: #01a252; font-weight: bold;',
221
'',
packages/react-reconciler/src/ReactFiberClassComponent.old.js
+1
-30
@@ -16,7 +16,6 @@ import {Update, Snapshot} from './ReactSideEffectTags';
16
import {
17
debugRenderPhaseSideEffectsForStrictMode,
18
disableLegacyContext,
19
- enableDebugTracing,
19
warnAboutDeprecatedLifecycles,
20
} from 'shared/ReactFeatureFlags';
21
import ReactStrictModeWarnings from './ReactStrictModeWarnings.old';
@@ -28,7 +27,7 @@ import invariant from 'shared/invariant';
27
import {REACT_CONTEXT_TYPE, REACT_PROVIDER_TYPE} from 'shared/ReactSymbols';
28
29
import {resolveDefaultProps} from './ReactFiberLazyComponent.old';
31
-import {DebugTracingMode, StrictMode} from './ReactTypeOfMode';
30
+import {StrictMode} from './ReactTypeOfMode';
31
32
import {
33
enqueueUpdate,
@@ -56,7 +55,6 @@ import {
55
scheduleUpdateOnFiber,
56
} from './ReactFiberWorkLoop.old';
57
import {requestCurrentSuspenseConfig} from './ReactFiberSuspenseConfig';
59
-import {logForceUpdateScheduled, logStateUpdateScheduled} from './DebugTracing';
58
59
import {disableLogs, reenableLogs} from 'shared/ConsolePatchingDev';
60
@@ -205,15 +203,6 @@ const classComponentUpdater = {
203
204
enqueueUpdate(fiber, update);
205
scheduleUpdateOnFiber(fiber, lane, eventTime);
208
-
209
- if (__DEV__) {
210
- if (enableDebugTracing) {
211
- if (fiber.mode & DebugTracingMode) {
212
- const name = getComponentName(fiber.type) || 'Unknown';
213
- logStateUpdateScheduled(name, lane, payload);
214
- }
215
- }
216
- }
206
},
207
enqueueReplaceState(inst, payload, callback) {
208
const fiber = getInstance(inst);
@@ -234,15 +223,6 @@ const classComponentUpdater = {
223
224
enqueueUpdate(fiber, update);
225
scheduleUpdateOnFiber(fiber, lane, eventTime);
237
-
238
- if (__DEV__) {
239
- if (enableDebugTracing) {
240
- if (fiber.mode & DebugTracingMode) {
241
- const name = getComponentName(fiber.type) || 'Unknown';
242
- logStateUpdateScheduled(name, lane, payload);
243
- }
244
- }
245
- }
226
},
227
enqueueForceUpdate(inst, callback) {
228
const fiber = getInstance(inst);
@@ -262,15 +242,6 @@ const classComponentUpdater = {
242
243
enqueueUpdate(fiber, update);
244
scheduleUpdateOnFiber(fiber, lane, eventTime);
265
-
266
- if (__DEV__) {
267
- if (enableDebugTracing) {
268
- if (fiber.mode & DebugTracingMode) {
269
- const name = getComponentName(fiber.type) || 'Unknown';
270
- logForceUpdateScheduled(name, lane);
271
- }
272
- }
273
- }
245
},
246
};
247
packages/react-reconciler/src/ReactFiberHooks.old.js
+2
-15
@@ -24,12 +24,9 @@ import type {FiberRoot} from './ReactInternalTypes';
24
import type {OpaqueIDType} from './ReactFiberHostConfig';
25
26
import ReactSharedInternals from 'shared/ReactSharedInternals';
27
-import {
28
- enableDebugTracing,
29
- enableNewReconciler,
30
-} from 'shared/ReactFeatureFlags';
27
+import {enableNewReconciler} from 'shared/ReactFeatureFlags';
28
32
-import {NoMode, BlockingMode, DebugTracingMode} from './ReactTypeOfMode';
29
+import {NoMode, BlockingMode} from './ReactTypeOfMode';
30
import {
31
NoLane,
32
NoLanes,
@@ -86,7 +83,6 @@ import {
83
warnAboutMultipleRenderersDEV,
84
} from './ReactMutableSource.old';
85
import {getIsRendering} from './ReactCurrentFiber';
89
-import {logStateUpdateScheduled} from './DebugTracing';
86
87
const {ReactCurrentDispatcher, ReactCurrentBatchConfig} = ReactSharedInternals;
88
@@ -1741,15 +1737,6 @@ function dispatchAction<S, A>(
1737
}
1738
scheduleUpdateOnFiber(fiber, lane, eventTime);
1739
}
1744
-
1745
- if (__DEV__) {
1746
- if (enableDebugTracing) {
1747
- if (fiber.mode & DebugTracingMode) {
1748
- const name = getComponentName(fiber.type) || 'Unknown';
1749
- logStateUpdateScheduled(name, lane, action);
1750
- }
1751
- }
1752
- }
1740
}
1741
1742
export const ContextOnlyDispatcher: Dispatcher = {
packages/react-reconciler/src/ReactFiberThrow.old.js
+1
-12
@@ -30,8 +30,7 @@ import {
30
LifecycleEffectMask,
31
} from './ReactSideEffectTags';
32
import {shouldCaptureSuspense} from './ReactFiberSuspenseComponent.old';
33
-import {NoMode, BlockingMode, DebugTracingMode} from './ReactTypeOfMode';
34
-import {enableDebugTracing} from 'shared/ReactFeatureFlags';
33
+import {NoMode, BlockingMode} from './ReactTypeOfMode';
34
import {createCapturedValue} from './ReactCapturedValue';
35
import {
36
enqueueCapturedUpdate,
@@ -54,7 +53,6 @@ import {
53
pingSuspendedRoot,
54
} from './ReactFiberWorkLoop.old';
55
import {logCapturedError} from './ReactFiberErrorLogger';
57
-import {logComponentSuspended} from './DebugTracing';
56
57
import {
58
SyncLane,
@@ -191,15 +189,6 @@ function throwException(
189
// This is a wakeable.
190
const wakeable: Wakeable = (value: any);
191
194
- if (__DEV__) {
195
- if (enableDebugTracing) {
196
- if (sourceFiber.mode & DebugTracingMode) {
197
- const name = getComponentName(sourceFiber.type) || 'Unknown';
198
- logComponentSuspended(name, wakeable);
199
- }
200
- }
201
- }
202
-
192
if ((sourceFiber.mode & BlockingMode) === NoMode) {
193
// Reset the memoizedState to what it was before we attempted
194
// to render it.
packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+2
-86
@@ -26,7 +26,6 @@ import {
26
enableSchedulerTracing,
27
warnAboutUnmockedScheduler,
28
deferRenderPhaseUpdateToNextBatch,
29
- enableDebugTracing,
29
} from 'shared/ReactFeatureFlags';
30
import ReactSharedInternals from 'shared/ReactSharedInternals';
31
import invariant from 'shared/invariant';
@@ -46,16 +45,6 @@ import {
45
flushSyncCallbackQueue,
46
scheduleSyncCallback,
47
} from './SchedulerWithReactIntegration.old';
49
-import {
50
- logCommitStarted,
51
- logCommitStopped,
52
- logLayoutEffectsStarted,
53
- logLayoutEffectsStopped,
54
- logPassiveEffectsStarted,
55
- logPassiveEffectsStopped,
56
- logRenderStarted,
57
- logRenderStopped,
58
-} from './DebugTracing';
48
49
// The scheduler is imported here *only* to detect whether it's been mocked
50
import * as Scheduler from 'scheduler';
@@ -1455,12 +1444,6 @@ function renderRootSync(root: FiberRoot, lanes: Lanes) {
1444
1445
const prevInteractions = pushInteractions(root);
1446
1458
- if (__DEV__) {
1459
- if (enableDebugTracing) {
1460
- logRenderStarted(lanes);
1461
- }
1462
- }
1463
-
1447
do {
1448
try {
1449
workLoopSync();
@@ -1486,12 +1469,6 @@ function renderRootSync(root: FiberRoot, lanes: Lanes) {
1469
);
1470
}
1471
1489
- if (__DEV__) {
1490
- if (enableDebugTracing) {
1491
- logRenderStopped();
1492
- }
1493
- }
1494
-
1472
// Set this to null to indicate there's no in-progress render.
1473
workInProgressRoot = null;
1474
workInProgressRootRenderLanes = NoLanes;
@@ -1522,12 +1499,6 @@ function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
1499
1500
const prevInteractions = pushInteractions(root);
1501
1525
- if (__DEV__) {
1526
- if (enableDebugTracing) {
1527
- logRenderStarted(lanes);
1528
- }
1529
- }
1530
-
1502
do {
1503
try {
1504
workLoopConcurrent();
@@ -1544,12 +1515,6 @@ function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
1515
popDispatcher(prevDispatcher);
1516
executionContext = prevExecutionContext;
1517
1547
- if (__DEV__) {
1548
- if (enableDebugTracing) {
1549
- logRenderStopped();
1550
- }
1551
- }
1552
-
1518
// Check if the tree has completed.
1519
if (workInProgress !== null) {
1520
// Still work remaining.
@@ -1820,15 +1785,6 @@ function commitRoot(root) {
1785
}
1786
1787
function commitRootImpl(root, renderPriorityLevel) {
1823
- const finishedWork = root.finishedWork;
1824
- const lanes = root.finishedLanes;
1825
-
1826
- if (__DEV__) {
1827
- if (enableDebugTracing) {
1828
- logCommitStarted(lanes);
1829
- }
1830
- }
1831
-
1788
do {
1789
// `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which
1790
// means `flushPassiveEffects` will sometimes result in additional
@@ -1845,13 +1801,9 @@ function commitRootImpl(root, renderPriorityLevel) {
1801
'Should not already be working.',
1802
);
1803
1804
+ const finishedWork = root.finishedWork;
1805
+ const lanes = root.finishedLanes;
1806
if (finishedWork === null) {
1849
- if (__DEV__) {
1850
- if (enableDebugTracing) {
1851
- logCommitStopped();
1852
- }
1853
- }
1854
-
1807
return null;
1808
}
1809
root.finishedWork = null;
@@ -2136,12 +2088,6 @@ function commitRootImpl(root, renderPriorityLevel) {
2088
}
2089
2090
if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
2139
- if (__DEV__) {
2140
- if (enableDebugTracing) {
2141
- logCommitStopped();
2142
- }
2143
- }
2144
-
2091
// This is a legacy edge case. We just committed the initial mount of
2092
// a ReactDOM.render-ed root inside of batchedUpdates. The commit fired
2093
// synchronously, but layout updates should be deferred until the end
@@ -2152,12 +2098,6 @@ function commitRootImpl(root, renderPriorityLevel) {
2098
// If layout work was scheduled, flush it now.
2099
flushSyncCallbackQueue();
2100
2155
- if (__DEV__) {
2156
- if (enableDebugTracing) {
2157
- logCommitStopped();
2158
- }
2159
- }
2160
-
2101
return null;
2102
}
2103
@@ -2282,12 +2222,6 @@ function commitMutationEffects(root: FiberRoot, renderPriorityLevel) {
2222
}
2223
2224
function commitLayoutEffects(root: FiberRoot, committedLanes: Lanes) {
2285
- if (__DEV__) {
2286
- if (enableDebugTracing) {
2287
- logLayoutEffectsStarted(committedLanes);
2288
- }
2289
- }
2290
-
2225
// TODO: Should probably move the bulk of this function to commitWork.
2226
while (nextEffect !== null) {
2227
setCurrentDebugFiberInDEV(nextEffect);
@@ -2306,12 +2240,6 @@ function commitLayoutEffects(root: FiberRoot, committedLanes: Lanes) {
2240
resetCurrentDebugFiberInDEV();
2241
nextEffect = nextEffect.nextEffect;
2242
}
2309
-
2310
- if (__DEV__) {
2311
- if (enableDebugTracing) {
2312
- logLayoutEffectsStopped();
2313
- }
2314
- }
2243
}
2244
2245
export function flushPassiveEffects() {
@@ -2393,12 +2321,6 @@ function flushPassiveEffectsImpl() {
2321
'Cannot flush passive effects while already rendering.',
2322
);
2323
2396
- if (__DEV__) {
2397
- if (enableDebugTracing) {
2398
- logPassiveEffectsStarted(lanes);
2399
- }
2400
- }
2401
-
2324
if (__DEV__) {
2325
isFlushingPassiveEffects = true;
2326
}
@@ -2555,12 +2477,6 @@ function flushPassiveEffectsImpl() {
2477
isFlushingPassiveEffects = false;
2478
}
2479
2558
- if (__DEV__) {
2559
- if (enableDebugTracing) {
2560
- logPassiveEffectsStopped();
2561
- }
2562
- }
2563
-
2480
executionContext = prevExecutionContext;
2481
2482
flushSyncCallbackQueue();
packages/react-reconciler/src/__tests__/DebugTracing-test.internal.js
+27
-27
@@ -85,9 +85,9 @@ describe('DebugTracing', () => {
85
);
86
87
expect(logs).toEqual([
88
- 'group: ⚛️ render (0b0000000000000000000000000000001)',
88
+ 'group: ⚛️ render (priority: immediate)',
89
'log: ⚛️ Example suspended',
90
- 'groupEnd: ⚛️ render (0b0000000000000000000000000000001)',
90
+ 'groupEnd: ⚛️ render (priority: immediate)',
91
]);
92
93
logs.splice(0);
@@ -119,9 +119,9 @@ describe('DebugTracing', () => {
119
expect(Scheduler).toFlushUntilNextPaint([]);
120
121
expect(logs).toEqual([
122
- 'group: ⚛️ render (0b0000000000000000000001000000000)',
122
+ 'group: ⚛️ render (priority: normal)',
123
'log: ⚛️ Example suspended',
124
- 'groupEnd: ⚛️ render (0b0000000000000000000001000000000)',
124
+ 'groupEnd: ⚛️ render (priority: normal)',
125
]);
126
127
logs.splice(0);
@@ -156,11 +156,11 @@ describe('DebugTracing', () => {
156
expect(Scheduler).toFlushUntilNextPaint([]);
157
158
expect(logs).toEqual([
159
- 'group: ⚛️ commit (0b0000000000000000000001000000000)',
160
- 'group: ⚛️ layout effects (0b0000000000000000000001000000000)',
161
- 'log: ⚛️ Example updated state (0b0000000000000000000000000000001)',
162
- 'groupEnd: ⚛️ layout effects (0b0000000000000000000001000000000)',
163
- 'groupEnd: ⚛️ commit (0b0000000000000000000001000000000)',
159
+ 'group: ⚛️ commit (priority: normal)',
160
+ 'group: ⚛️ layout effects (priority: immediate)',
161
+ 'log: ⚛️ Example updated state (priority: immediate)',
162
+ 'groupEnd: ⚛️ layout effects (priority: immediate)',
163
+ 'groupEnd: ⚛️ commit (priority: normal)',
164
]);
165
});
166
@@ -192,10 +192,10 @@ describe('DebugTracing', () => {
192
}).toErrorDev('Cannot update during an existing state transition');
193
194
expect(logs).toEqual([
195
- 'group: ⚛️ render (0b0000000000000000000001000000000)',
196
- 'log: ⚛️ Example updated state (0b0000000000000000000010000000000)',
197
- 'log: ⚛️ Example updated state (0b0000000000000000000010000000000)',
198
- 'groupEnd: ⚛️ render (0b0000000000000000000001000000000)',
195
+ 'group: ⚛️ render (priority: normal)',
196
+ 'log: ⚛️ Example updated state (priority: normal)',
197
+ 'log: ⚛️ Example updated state (priority: normal)',
198
+ 'groupEnd: ⚛️ render (priority: normal)',
199
]);
200
});
201
@@ -223,11 +223,11 @@ describe('DebugTracing', () => {
223
expect(Scheduler).toFlushUntilNextPaint([]);
224
225
expect(logs).toEqual([
226
- 'group: ⚛️ commit (0b0000000000000000000001000000000)',
227
- 'group: ⚛️ layout effects (0b0000000000000000000001000000000)',
228
- 'log: ⚛️ Example updated state (0b0000000000000000000000000000001)',
229
- 'groupEnd: ⚛️ layout effects (0b0000000000000000000001000000000)',
230
- 'groupEnd: ⚛️ commit (0b0000000000000000000001000000000)',
226
+ 'group: ⚛️ commit (priority: normal)',
227
+ 'group: ⚛️ layout effects (priority: immediate)',
228
+ 'log: ⚛️ Example updated state (priority: immediate)',
229
+ 'groupEnd: ⚛️ layout effects (priority: immediate)',
230
+ 'groupEnd: ⚛️ commit (priority: normal)',
231
]);
232
});
233
@@ -250,9 +250,9 @@ describe('DebugTracing', () => {
250
);
251
});
252
expect(logs).toEqual([
253
- 'group: ⚛️ passive effects (0b0000000000000000000001000000000)',
254
- 'log: ⚛️ Example updated state (0b0000000000000000000010000000000)',
255
- 'groupEnd: ⚛️ passive effects (0b0000000000000000000001000000000)',
253
+ 'group: ⚛️ passive effects (priority: normal)',
254
+ 'log: ⚛️ Example updated state (priority: normal)',
255
+ 'groupEnd: ⚛️ passive effects (priority: normal)',
256
]);
257
});
258
@@ -275,10 +275,10 @@ describe('DebugTracing', () => {
275
);
276
});
277
expect(logs).toEqual([
278
- 'group: ⚛️ render (0b0000000000000000000001000000000)',
279
- 'log: ⚛️ Example updated state (0b0000000000000000000010000000000)',
280
- 'log: ⚛️ Example updated state (0b0000000000000000000010000000000)', // debugRenderPhaseSideEffectsForStrictMode
281
- 'groupEnd: ⚛️ render (0b0000000000000000000001000000000)',
278
+ 'group: ⚛️ render (priority: normal)',
279
+ 'log: ⚛️ Example updated state (priority: normal)',
280
+ 'log: ⚛️ Example updated state (priority: normal)', // debugRenderPhaseSideEffectsForStrictMode
281
+ 'groupEnd: ⚛️ render (priority: normal)',
282
]);
283
});
284
@@ -303,9 +303,9 @@ describe('DebugTracing', () => {
303
expect(Scheduler).toFlushUntilNextPaint([]);
304
305
expect(logs).toEqual([
306
- 'group: ⚛️ render (0b0000000000000000000001000000000)',
306
+ 'group: ⚛️ render (priority: normal)',
307
'log: Hello from user code',
308
- 'groupEnd: ⚛️ render (0b0000000000000000000001000000000)',
308
+ 'groupEnd: ⚛️ render (priority: normal)',
309
]);
310
});
311
packages/shared/forks/ReactFeatureFlags.www.js
+2
-2
@@ -78,8 +78,8 @@ export const enableModernEventSystem = true;
78
// to the correct value.
79
export const enableNewReconciler = __VARIANT__;
80
81
-// TODO: This does not currently exist in the new reconciler fork.
82
-export const enableDebugTracing = !__VARIANT__;
81
+// TODO: This does not currently exist in the Lanes implementation.
82
+export const enableDebugTracing = false;
83
84
// Flow magic to verify the exports of this file match the original version.
85
// eslint-disable-next-line no-unused-vars