Skip to content

Conversation

sebmarkbage
Copy link
Collaborator

This adds early logging when two ViewTransitions with the same name are mounted at the same time. Whether they're part of a View Transition or not.

This lets us include the owner stack of each one. I do two logs so that you can get the stack trace of each one of the duplicates.

It currently only logs once for each name which also avoids the scenario when you have many hits for the same name in one commit. However, we could also possibly log a stack for each of them but seems noisy.

Currently we don't log if a SwipeTransition is the first time the pair gets mounted which could lead to a View Transition error before we've warned. That could be a separate improvement.

@sebmarkbage sebmarkbage requested review from jackpope and eps1lon March 26, 2025 00:54
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Mar 26, 2025
untrackNamedViewTransition(deletedFiber);
}
}
safelyDetachRef(deletedFiber, nearestMountedAncestor);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also noticed that we weren't detaching ViewTransition refs when unmounting. Only hiding.

nearestMountedAncestor,
deletedFiber,
);
return;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can safe some bytes by falling through but it really only works for one case and it's easy to get wrong when copying it so I made this explicit.

@react-sizebot
Copy link

Comparing: 4845e16...78a6542

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 515.14 kB 515.14 kB = 91.74 kB 91.74 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB +0.05% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js +0.06% 614.35 kB 614.70 kB = 108.76 kB 108.77 kB
facebook-www/ReactDOM-prod.classic.js +0.07% 650.34 kB 650.77 kB +0.03% 114.79 kB 114.83 kB
facebook-www/ReactDOM-prod.modern.js +0.07% 640.62 kB 641.05 kB +0.03% 113.23 kB 113.26 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
test_utils/ReactAllWarnings.js +0.54% 63.93 kB 64.27 kB +0.70% 16.00 kB 16.12 kB
oss-experimental/react-art/cjs/react-art.development.js +0.38% 632.08 kB 634.48 kB +0.41% 100.44 kB 100.86 kB
facebook-www/ReactART-dev.modern.js +0.36% 697.64 kB 700.15 kB +0.41% 109.18 kB 109.62 kB
facebook-www/ReactART-dev.classic.js +0.35% 707.13 kB 709.64 kB +0.40% 111.02 kB 111.46 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js +0.32% 757.38 kB 759.78 kB +0.34% 119.22 kB 119.62 kB
facebook-www/ReactReconciler-dev.modern.js +0.31% 805.62 kB 808.12 kB +0.33% 125.87 kB 126.28 kB
facebook-www/ReactReconciler-dev.classic.js +0.31% 814.82 kB 817.33 kB +0.33% 127.53 kB 127.94 kB
oss-experimental/react-dom/cjs/react-dom-client.development.js +0.22% 1,100.54 kB 1,102.95 kB +0.20% 183.94 kB 184.32 kB
oss-experimental/react-dom/cjs/react-dom-profiling.development.js +0.22% 1,116.94 kB 1,119.34 kB +0.21% 186.77 kB 187.16 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js +0.22% 1,117.09 kB 1,119.49 kB +0.20% 187.58 kB 187.96 kB
facebook-www/ReactDOM-dev.modern.js +0.21% 1,166.92 kB 1,169.42 kB +0.23% 193.68 kB 194.13 kB
facebook-www/ReactDOM-dev.classic.js +0.21% 1,176.06 kB 1,178.56 kB +0.24% 195.36 kB 195.84 kB
facebook-www/ReactDOMTesting-dev.modern.js +0.21% 1,183.45 kB 1,185.96 kB +0.24% 197.44 kB 197.91 kB
facebook-www/ReactDOMTesting-dev.classic.js +0.21% 1,192.59 kB 1,195.10 kB +0.26% 199.18 kB 199.70 kB

Generated by 🚫 dangerJS against 78a6542

});
runWithFiberInDEV(existing, () => {
console.error(
'The existing <ViewTransition name=%s> duplicate has this stack trace.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to phrase this so it's not to repetitive when shown together but also somewhat makes sense in isolation if they're show independently. This log entry has the other Fiber's owner/async stack trace. I think we have this pattern of two logs somewhere else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're logging the other component stack. Might be weird to see this in places where the component stack is less visible/collapsed? Could we add the owner component name?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing <ViewTransition name=%s> duplicate rendered in Parent.

@sebmarkbage sebmarkbage merged commit 8ac25e5 into facebook:main Mar 26, 2025
243 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 26, 2025
This adds early logging when two ViewTransitions with the same name are
mounted at the same time. Whether they're part of a View Transition or
not.

This lets us include the owner stack of each one. I do two logs so that
you can get the stack trace of each one of the duplicates.

It currently only logs once for each name which also avoids the scenario
when you have many hits for the same name in one commit. However, we
could also possibly log a stack for each of them but seems noisy.

Currently we don't log if a SwipeTransition is the first time the pair
gets mounted which could lead to a View Transition error before we've
warned. That could be a separate improvement.

DiffTrain build for [8ac25e5](8ac25e5)
eps1lon pushed a commit to vercel/next.js that referenced this pull request Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants