Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 32baab3

Browse filesBrowse files
authored
[Transition Tracing] Add Tag Field to Marker Instance (#25085)
We were previously using `markerInstance.name` to figure out whether the marker instance was on the tracing marker or the root, but this is unsustainable. This adds a tag field so we can explicitly check this.
1 parent 8ef3a7c commit 32baab3
Copy full SHA for 32baab3

8 files changed

+48-8Lines changed: 48 additions & 8 deletions
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-reconciler/src/ReactFiber.new.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiber.new.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ import {
9898
REACT_CACHE_TYPE,
9999
REACT_TRACING_MARKER_TYPE,
100100
} from 'shared/ReactSymbols';
101+
import {TransitionTracingMarker} from './ReactFiberTracingMarkerComponent.new';
101102

102103
export type {Fiber};
103104

@@ -770,6 +771,7 @@ export function createFiberFromTracingMarker(
770771
fiber.elementType = REACT_TRACING_MARKER_TYPE;
771772
fiber.lanes = lanes;
772773
const tracingMarkerInstance: TracingMarkerInstance = {
774+
tag: TransitionTracingMarker,
773775
transitions: null,
774776
pendingBoundaries: null,
775777
};
Collapse file

‎packages/react-reconciler/src/ReactFiber.old.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiber.old.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ import {
9898
REACT_CACHE_TYPE,
9999
REACT_TRACING_MARKER_TYPE,
100100
} from 'shared/ReactSymbols';
101+
import {TransitionTracingMarker} from './ReactFiberTracingMarkerComponent.old';
101102

102103
export type {Fiber};
103104

@@ -770,6 +771,7 @@ export function createFiberFromTracingMarker(
770771
fiber.elementType = REACT_TRACING_MARKER_TYPE;
771772
fiber.lanes = lanes;
772773
const tracingMarkerInstance: TracingMarkerInstance = {
774+
tag: TransitionTracingMarker,
773775
transitions: null,
774776
pendingBoundaries: null,
775777
};
Collapse file

‎packages/react-reconciler/src/ReactFiberBeginWork.new.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberBeginWork.new.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ import {
268268
getMarkerInstances,
269269
pushMarkerInstance,
270270
pushRootMarkerInstance,
271+
TransitionTracingMarker,
271272
} from './ReactFiberTracingMarkerComponent.new';
272273

273274
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
@@ -976,6 +977,7 @@ function updateTracingMarkerComponent(
976977
const currentTransitions = getPendingTransitions();
977978
if (currentTransitions !== null) {
978979
const markerInstance: TracingMarkerInstance = {
980+
tag: TransitionTracingMarker,
979981
transitions: new Set(currentTransitions),
980982
pendingBoundaries: new Map(),
981983
name: workInProgress.pendingProps.name,
Collapse file

‎packages/react-reconciler/src/ReactFiberBeginWork.old.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberBeginWork.old.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ import {
268268
getMarkerInstances,
269269
pushMarkerInstance,
270270
pushRootMarkerInstance,
271+
TransitionTracingMarker,
271272
} from './ReactFiberTracingMarkerComponent.old';
272273

273274
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
@@ -976,6 +977,7 @@ function updateTracingMarkerComponent(
976977
const currentTransitions = getPendingTransitions();
977978
if (currentTransitions !== null) {
978979
const markerInstance: TracingMarkerInstance = {
980+
tag: TransitionTracingMarker,
979981
transitions: new Set(currentTransitions),
980982
pendingBoundaries: new Map(),
981983
name: workInProgress.pendingProps.name,
Collapse file

‎packages/react-reconciler/src/ReactFiberCommitWork.new.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberCommitWork.new.js
+14-4Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ import {
177177
OffscreenVisible,
178178
OffscreenPassiveEffectsConnected,
179179
} from './ReactFiberOffscreenComponent';
180+
import {
181+
TransitionRoot,
182+
TransitionTracingMarker,
183+
} from './ReactFiberTracingMarkerComponent.new';
180184

181185
let didWarnAboutUndefinedSnapshotBeforeUpdate: Set<mixed> | null = null;
182186
if (__DEV__) {
@@ -1184,13 +1188,16 @@ function commitTransitionProgress(offscreenFiber: Fiber) {
11841188
name,
11851189
});
11861190
if (transitions !== null) {
1187-
if (markerInstance.name) {
1191+
if (
1192+
markerInstance.tag === TransitionTracingMarker &&
1193+
markerInstance.name !== undefined
1194+
) {
11881195
addMarkerProgressCallbackToPendingTransition(
11891196
markerInstance.name,
11901197
transitions,
11911198
pendingBoundaries,
11921199
);
1193-
} else {
1200+
} else if (markerInstance.tag === TransitionRoot) {
11941201
transitions.forEach(transition => {
11951202
addTransitionProgressCallbackToPendingTransition(
11961203
transition,
@@ -1216,13 +1223,16 @@ function commitTransitionProgress(offscreenFiber: Fiber) {
12161223
) {
12171224
pendingBoundaries.delete(offscreenInstance);
12181225
if (transitions !== null) {
1219-
if (markerInstance.name) {
1226+
if (
1227+
markerInstance.tag === TransitionTracingMarker &&
1228+
markerInstance.name !== undefined
1229+
) {
12201230
addMarkerProgressCallbackToPendingTransition(
12211231
markerInstance.name,
12221232
transitions,
12231233
pendingBoundaries,
12241234
);
1225-
} else {
1235+
} else if (markerInstance.tag === TransitionRoot) {
12261236
transitions.forEach(transition => {
12271237
addTransitionProgressCallbackToPendingTransition(
12281238
transition,
Collapse file

‎packages/react-reconciler/src/ReactFiberCommitWork.old.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberCommitWork.old.js
+14-4Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ import {
177177
OffscreenVisible,
178178
OffscreenPassiveEffectsConnected,
179179
} from './ReactFiberOffscreenComponent';
180+
import {
181+
TransitionRoot,
182+
TransitionTracingMarker,
183+
} from './ReactFiberTracingMarkerComponent.old';
180184

181185
let didWarnAboutUndefinedSnapshotBeforeUpdate: Set<mixed> | null = null;
182186
if (__DEV__) {
@@ -1184,13 +1188,16 @@ function commitTransitionProgress(offscreenFiber: Fiber) {
11841188
name,
11851189
});
11861190
if (transitions !== null) {
1187-
if (markerInstance.name) {
1191+
if (
1192+
markerInstance.tag === TransitionTracingMarker &&
1193+
markerInstance.name !== undefined
1194+
) {
11881195
addMarkerProgressCallbackToPendingTransition(
11891196
markerInstance.name,
11901197
transitions,
11911198
pendingBoundaries,
11921199
);
1193-
} else {
1200+
} else if (markerInstance.tag === TransitionRoot) {
11941201
transitions.forEach(transition => {
11951202
addTransitionProgressCallbackToPendingTransition(
11961203
transition,
@@ -1216,13 +1223,16 @@ function commitTransitionProgress(offscreenFiber: Fiber) {
12161223
) {
12171224
pendingBoundaries.delete(offscreenInstance);
12181225
if (transitions !== null) {
1219-
if (markerInstance.name) {
1226+
if (
1227+
markerInstance.tag === TransitionTracingMarker &&
1228+
markerInstance.name !== undefined
1229+
) {
12201230
addMarkerProgressCallbackToPendingTransition(
12211231
markerInstance.name,
12221232
transitions,
12231233
pendingBoundaries,
12241234
);
1225-
} else {
1235+
} else if (markerInstance.tag === TransitionRoot) {
12261236
transitions.forEach(transition => {
12271237
addTransitionProgressCallbackToPendingTransition(
12281238
transition,
Collapse file

‎packages/react-reconciler/src/ReactFiberTracingMarkerComponent.new.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberTracingMarkerComponent.new.js
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ export type BatchConfigTransition = {
3737
};
3838

3939
export type TracingMarkerInstance = {|
40+
tag?: TracingMarkerTag,
4041
pendingBoundaries: PendingBoundaries | null,
4142
transitions: Set<Transition> | null,
4243
name?: string,
4344
|};
4445

46+
export const TransitionRoot = 0;
47+
export const TransitionTracingMarker = 1;
48+
export type TracingMarkerTag = 0 | 1;
49+
4550
export type PendingBoundaries = Map<OffscreenInstance, SuspenseInfo>;
4651

4752
export function processTransitionCallbacks(
@@ -146,6 +151,7 @@ export function pushRootMarkerInstance(workInProgress: Fiber): void {
146151
transitions.forEach(transition => {
147152
if (!root.incompleteTransitions.has(transition)) {
148153
const markerInstance: TracingMarkerInstance = {
154+
tag: TransitionRoot,
149155
transitions: new Set([transition]),
150156
pendingBoundaries: null,
151157
};
Collapse file

‎packages/react-reconciler/src/ReactFiberTracingMarkerComponent.old.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberTracingMarkerComponent.old.js
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ export type BatchConfigTransition = {
3737
};
3838

3939
export type TracingMarkerInstance = {|
40+
tag?: TracingMarkerTag,
4041
pendingBoundaries: PendingBoundaries | null,
4142
transitions: Set<Transition> | null,
4243
name?: string,
4344
|};
4445

46+
export const TransitionRoot = 0;
47+
export const TransitionTracingMarker = 1;
48+
export type TracingMarkerTag = 0 | 1;
49+
4550
export type PendingBoundaries = Map<OffscreenInstance, SuspenseInfo>;
4651

4752
export function processTransitionCallbacks(
@@ -146,6 +151,7 @@ export function pushRootMarkerInstance(workInProgress: Fiber): void {
146151
transitions.forEach(transition => {
147152
if (!root.incompleteTransitions.has(transition)) {
148153
const markerInstance: TracingMarkerInstance = {
154+
tag: TransitionRoot,
149155
transitions: new Set([transition]),
150156
pendingBoundaries: null,
151157
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.