Search code examples
react-native-reanimated

react-native-reanimated v3 crash: Terminating app due to uncaught exception 'NSUnknownKeyException'


after update react-native-reanimated from 2.10.0 to 3.1.0, I got this crash info:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<RNSScreen 0x7f93f03d15e0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key screenView.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001154788ab __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x0000000119bcdba3 objc_exception_throw + 48
    2   CoreFoundation                      0x000000011547851d -[NSException init] + 0
    3   Foundation                          0x000000011b687b3f -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 225
    4   Foundation                          0x000000011b686919 -[NSObject(NSKeyValueCoding) valueForKey:] + 307
    5   VedaxLink                           0x0000000104cfa6ec -[REASharedTransitionManager swizzled_viewDidLayoutSubviews] + 47
    6   UIKitCore                           0x0000000137b607b3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2837
    7   QuartzCore                          0x000000011ae5e02c _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 526
    8   QuartzCore                          0x000000011ae695b9 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 65
    9   QuartzCore                          0x000000011ad7ab0c _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 626
    10  QuartzCore                          0x000000011adb269b _ZN2CA11Transaction6commitEv + 735
    11  QuartzCore                          0x000000011ac90a89 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 1589
    12  QuartzCore                          0x000000011adb76e3 _ZL22display_timer_callbackP12__CFMachPortPvlS1_ + 395
    13  CoreFoundation                      0x00000001153a3c4f __CFMachPortPerform + 151
    14  CoreFoundation                      0x00000001153d87f4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
    15  CoreFoundation                      0x00000001153d7d3b __CFRunLoopDoSource1 + 538
    16  CoreFoundation                      0x00000001153d2538 __CFRunLoopRun + 2740
    17  CoreFoundation                      0x00000001153d16a7 CFRunLoopRunSpecific + 560
    18  GraphicsServices                    0x000000012336328a GSEventRunModal + 139
    19  UIKitCore                           0x000000013752dad3 -[UIApplication _run] + 994
    20  UIKitCore                           0x00000001375329ef UIApplicationMain + 123
    21  VedaxLink                           0x000000010456bf89 main + 72
    22  dyld                                0x0000000112d9c2bf start_sim + 10
    23  ???                                 0x000000020aa3741f 0x0 + 8768418847
)
libc++abi: terminating with uncaught exception of type NSException

I checked this lib code then found this line cause crash:

- (void)swizzled_viewDidLayoutSubviews
{
  // call original method from react-native-screens, self == RNScreen
  [self swizzled_viewDidLayoutSubviews];
  UIView *screen = [self valueForKey:@"screenView"]; => make crash
  [_sharedTransitionManager screenAddedToStack:screen];
}

I dont know how to fixed this, may be some other dependency does not work with reanimated 3.1.0, can someone help?

Here is my package

    "react": "17.0.2",
    "react-native": "^0.68.0",
    ...
    "react-native-screens": "^3.13.1",
    "@react-navigation/native": "^6.0.10",
    "@react-navigation/native-stack": "^6.6.1",
    "@react-navigation/stack": "^6.3.7",
   ...

   "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "@types/diff": "4.0.2",
    "@types/jest": "26.0.19",
    "@types/react-native-vector-icons": "^6.4.10",
    "babel-jest": "^26.6.3",
    "eslint": "^7.32.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.67.0",
    "react-test-renderer": "17.0.2"
  },

Solution

  • upgrade react-native version to 0.71.8 and react-navigation, react-native-screens, react-nagivation/stack.. to lasted work for me