Follow through all the phases when an error happens during snapshotting (#32803)

This can happen for example if you have duplicate names in the "old"
state. This errors the transition before the updateCallback is invoked
so we haven't yet applied mutations etc.

This runs through those phases after the error to get us back to a
consistent state.
This commit is contained in:
Sebastian Markbåge 2025-04-02 10:49:44 -04:00 committed by GitHub
parent 450f8df886
commit 040f8286e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1802,6 +1802,12 @@ export function startViewTransition(
}
} finally {
// Continue the reset of the work.
// If the error happened in the snapshot phase before the update callback
// was invoked, then we need to first finish the mutation and layout phases.
// If they're already invoked it's still safe to call them due the status check.
mutationCallback();
layoutCallback();
// Skip afterMutationCallback() since we're not animating.
spawnedWorkCallback();
}
};
@ -2137,7 +2143,13 @@ export function startGestureTransition(
}
} finally {
// Continue the reset of the work.
readyCallback();
// If the error happened in the snapshot phase before the update callback
// was invoked, then we need to first finish the mutation and layout phases.
// If they're already invoked it's still safe to call them due the status check.
mutationCallback();
// Skip readyCallback() and go straight to animateCallbck() since we're not animating.
// animateCallback() is still required to restore states.
animateCallback();
}
};
transition.ready.then(readyForAnimations, handleError);