Skip to content

Commit d74f061

Browse files
authored
[Fiber] Clean up ViewTransition when it fails to start (facebook#34676)
The View Transition docs were unclear about this but apparently the `finished` promise never settles if the animation never started. So if there's an error that rejects the `ready` promise, we'll never run the clean up which can cause it to stall. Fixes facebook#34662. However, ultimately that is caused by Chrome stalling our default `onDefaultTransitionIndicator` but it should be unblocked after 10 seconds, not a minute.
1 parent f7254ef commit d74f061

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,6 +2279,11 @@ export function startViewTransition(
22792279
spawnedWorkCallback();
22802280
};
22812281
const handleError = (error: mixed) => {
2282+
// $FlowFixMe[prop-missing]
2283+
if (ownerDocument.__reactViewTransition === transition) {
2284+
// $FlowFixMe[prop-missing]
2285+
ownerDocument.__reactViewTransition = null;
2286+
}
22822287
try {
22832288
error = customizeViewTransitionError(error, false);
22842289
if (error !== null) {
@@ -2293,6 +2298,9 @@ export function startViewTransition(
22932298
layoutCallback();
22942299
// Skip afterMutationCallback() since we're not animating.
22952300
spawnedWorkCallback();
2301+
if (enableProfilerTimer) {
2302+
finishedAnimation();
2303+
}
22962304
}
22972305
};
22982306
transition.ready.then(readyCallback, handleError);
@@ -2699,6 +2707,11 @@ export function startGestureTransition(
26992707
? () => requestAnimationFrame(readyCallback)
27002708
: readyCallback;
27012709
const handleError = (error: mixed) => {
2710+
// $FlowFixMe[prop-missing]
2711+
if (ownerDocument.__reactViewTransition === transition) {
2712+
// $FlowFixMe[prop-missing]
2713+
ownerDocument.__reactViewTransition = null;
2714+
}
27022715
try {
27032716
error = customizeViewTransitionError(error, true);
27042717
if (error !== null) {
@@ -2713,6 +2726,9 @@ export function startGestureTransition(
27132726
// Skip readyCallback() and go straight to animateCallbck() since we're not animating.
27142727
// animateCallback() is still required to restore states.
27152728
animateCallback();
2729+
if (enableProfilerTimer) {
2730+
finishedAnimation();
2731+
}
27162732
}
27172733
};
27182734
transition.ready.then(readyForAnimations, handleError);

0 commit comments

Comments
 (0)