software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
9.11k stars 1.32k forks source link

[iOS] Shared Element Transition SIGABRT crashes (reparentSharedViewsForCurrentTransition) #4916

Open andreialecu opened 1 year ago

andreialecu commented 1 year ago

Description

Been experimenting with Shared Element Transitions and have been getting this crash.

0   CoreFoundation                      0x000000010a98a330 __exceptionPreprocess + 172
1   libobjc.A.dylib                     0x0000000109529274 objc_exception_throw + 56
2   CoreFoundation                      0x000000010a98a240 -[NSException initWithCoder:] + 0
3   UIKitCore                           0x0000000135af0a70 -[UIView(Hierarchy) _associatedViewControllerForwardsAppearanceCallbacks:performHierarchyCheck:isRoot:] + 216
4   UIKitCore                           0x0000000135af1150 -[UIView(Hierarchy) _willMoveToWindow:withAncestorView:] + 184
5   UIKitCore                           0x0000000135af1b28 _makeSubTreePerformSelector + 428
6   UIKitCore                           0x0000000135af1b64 _makeSubTreePerformSelector + 488
7   UIKitCore                           0x0000000135af1b64 _makeSubTreePerformSelector + 488
8   UIKitCore                           0x0000000135af1b64 _makeSubTreePerformSelector + 488
9   UIKitCore                           0x0000000135af1b64 _makeSubTreePerformSelector + 488
10  UIKitCore                           0x0000000135af1b64 _makeSubTreePerformSelector + 488
11  UIKitCore                           0x0000000135af1b64 _makeSubTreePerformSelector + 488
12  UIKitCore                           0x0000000135af1b64 _makeSubTreePerformSelector + 488
13  UIKitCore                           0x0000000135af1b64 _makeSubTreePerformSelector + 488
14  UIKitCore                           0x0000000135afda04 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 388
15  LetsPoker                           0x000000010487bef8 -[REASharedTransitionManager reparentSharedViewsForCurrentTransition:] + 1112
16  LetsPoker                           0x0000000104878dac -[REASharedTransitionManager configureAndStartSharedTransitionForViews:isInteractive:] + 240
17  LetsPoker                           0x000000010487b590 -[REASharedTransitionManager runSharedTransitionForSharedViewsOnScreen:isInteractive:] + 228
18  LetsPoker                           0x000000010487a820 -[REASharedTransitionManager screenRemovedFromStack:] + 440
19  LetsPoker                           0x000000010487a5dc -[REASharedTransitionManager reanimated_notifyWillDisappear] + 52
20  LetsPoker                           0x00000001048b9834 -[RNSScreen viewWillDisappear:] + 820
21  UIKitCore                           0x0000000134fcd20c -[UIViewController _setViewAppearState:isAnimating:] + 1216
22  UIKitCore                           0x0000000134fcdbb4 -[UIViewController __viewWillDisappear:] + 92
23  UIKitCore                           0x0000000134f1ffc8 -[UINavigationController _startCustomTransition:] + 1040
24  UIKitCore                           0x0000000134f31634 -[UINavigationController _startDeferredTransitionIfNeeded:] + 492
25  UIKitCore                           0x0000000134f32504 -[UINavigationController __viewWillLayoutSubviews] + 92
26  UIKitCore                           0x0000000134f19c1c -[UILayoutContainerView layoutSubviews] + 168
27  UIKit                               0x000000014e645d4c -[UILayoutContainerViewAccessibility layoutSubviews] + 48
28  UIKitCore                           0x0000000135b02c00 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1860
29  QuartzCore                          0x000000010a51c528 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 440
30  QuartzCore                          0x000000010a527288 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 128
31  QuartzCore                          0x000000010a451130 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 440
32  QuartzCore                          0x000000010a47c0f4 _ZN2CA11Transaction6commitEv + 636
33  QuartzCore                          0x000000010a47d518 _ZN2CA11Transaction25flush_as_runloop_observerEb + 68
34  CoreFoundation                      0x000000010a8ecc10 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
35  CoreFoundation                      0x000000010a8e757c __CFRunLoopDoObservers + 512
36  CoreFoundation                      0x000000010a8e7a20 __CFRunLoopRun + 948
37  CoreFoundation                      0x000000010a8e7254 CFRunLoopRunSpecific + 584
38  GraphicsServices                    0x00000001145dfc9c GSEventRunModal + 160
39  UIKitCore                           0x000000013565eff0 -[UIApplication _run] + 868
40  UIKitCore                           0x0000000135662f3c UIApplicationMain + 124
41  LetsPoker                           0x00000001041cdb54 main + 96
42  dyld                                0x00000001088e1514 start_sim + 20
43  ???                                 0x0000000108b0de50 0x0 + 4440776272
44  ???                                 0x5a6d000000000000 0x0 + 6515864235874975744

I think a variant of this also happens on Android, but it only occurs when going from Screen A to B to C, then back to B, then A. There's a freeze of the entire screen and it cannot be interacted with any more. If I hit the physical back button this is logged:

CleanShot 2023-08-11 at 12 01 08@2x

Steps to reproduce

I can reproduce this with React Navigation when using a custom headerBackground for a bunch of screens. It occurs when navigating from screen A > B then back to A. Note that this was just an experiment to see if I could transition the header.

import React from 'react';
import {StyleSheet} from 'react-native';
import Animated from 'react-native-reanimated';

export const LPHeaderGradient = ({
  children,
}: {
  children?: React.ReactNode;
}) => {
  return (
    <Animated.View
      sharedTransitionTag="bg123"
      style={StyleSheet.absoluteFill}
    >
       {children} 
    </Animated.View>
  );
};

Snack or a link to a repository

n/a

Reanimated version

3.4.2

React Native version

0.71.6

Platforms

iOS

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

github-actions[bot] commented 1 year ago

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

piaskowyk commented 1 year ago

I know how to fix it, the PR will be available soon 👍

AndreiBehel commented 1 year ago

Our QA team also observed such freeze issues during navigation in release android app

erikkjernlie commented 1 year ago

Great! Is it fixed @piaskowyk? I am experiencing the same issue with react-native 0.67.5 and react-native-reanimated 3.3.0.

erikkjernlie commented 1 year ago

If I upgrade to react-native-reanimate 3.4.2 or above, I am getting a type error, so as of now, I have to stick to 3.3.0... simulator_screenshot_C881E9E9-6E6E-485E-98D4-9A1F9B17B1DB