@@ -2190,8 +2190,6 @@ export function startViewTransition(
21902190 // $FlowFixMe[prop-missing]
21912191 ownerDocument . __reactViewTransition = transition ;
21922192
2193- // Cached for cancellation in finished callback. Calling getAnimations() after
2194- // the transition finishes crashes Safari due to stale element references.
21952193 const viewTransitionAnimations : Array < Animation > = [ ] ;
21962194
21972195 const readyCallback = ( ) = > {
@@ -2300,8 +2298,10 @@ export function startViewTransition(
23002298 } ;
23012299 transition . ready . then ( readyCallback , handleError ) ;
23022300 transition . finished . finally ( ( ) => {
2303- // Cancel animations from cached list to avoid getAnimations() crash in Safari.
23042301 for ( let i = 0 ; i < viewTransitionAnimations . length ; i ++ ) {
2302+ // In Safari, we need to manually cancel all manually started animations
2303+ // or it'll block or interfer with future transitions.
2304+ // We can't use getAnimations() due to #35336 so we collect them in an array.
23052305 viewTransitionAnimations [ i ] . cancel ( ) ;
23062306 }
23072307 // $FlowFixMe[prop-missing]
@@ -2537,8 +2537,6 @@ export function startGestureTransition(
25372537 // $FlowFixMe[prop-missing]
25382538 ownerDocument . __reactViewTransition = transition ;
25392539 const customTimelineCleanup : Array < ( ) => void > = [ ] ; // Cleanup Animations started in a CustomTimeline
2540- // Cached for cancellation in finished callback. Calling getAnimations() after
2541- // the transition finishes crashes Safari due to stale element references.
25422540 const viewTransitionAnimations : Array < Animation > = [ ] ;
25432541 const readyCallback = ( ) => {
25442542 const documentElement : Element = ( ownerDocument . documentElement : any ) ;
@@ -2735,8 +2733,10 @@ export function startGestureTransition(
27352733 } ;
27362734 transition . ready . then ( readyForAnimations , handleError ) ;
27372735 transition .finished . finally ( ( ) => {
2738- // Cancel animations from cached list to avoid getAnimations() crash in Safari.
27392736 for ( let i = 0 ; i < viewTransitionAnimations . length ; i ++ ) {
2737+ // In Safari, we need to manually cancel all manually started animations
2738+ // or it'll block or interfer with future transitions.
2739+ // We can't use getAnimations() due to #35336 so we collect them in an array.
27402740 viewTransitionAnimations [ i ] . cancel ( ) ;
27412741 }
27422742 for ( let i = 0 ; i < customTimelineCleanup . length ; i ++ ) {
0 commit comments