callstack / react-native-pager-view

React Native wrapper for the Android ViewPager and iOS UIPageViewController.
MIT License
2.76k stars 422 forks source link

[iOS] ReactNativePageView.m line 154 crash #553

Open JensDeTaey27 opened 2 years ago

JensDeTaey27 commented 2 years ago

Environment

iOS

"react-native-pager-view": "^5.4.9",
"react-native": "0.66.1",

Description

We get a number of crash reports in crashlytics about next issue:

ReactNativePageView.m line 154
-[ReactNativePageView setupInitialController]
Fatal Exception: NSRangeException
*** -[__NSArrayM objectAtIndexedSubscript:]: index 18446744073709551615 beyond bounds [0 .. 0]
Fatal Exception: NSRangeException
0  CoreFoundation                 0x9270c __exceptionPreprocess
1  libobjc.A.dylib                0x14f04 objc_exception_throw
2  CoreFoundation                 0x18c984 -[__NSCFString characterAtIndex:].cold.1
3  CoreFoundation                 0x354c8 __NSDictionaryMutablePlaceholder
4  APPNAME                        0x3c513c -[ReactNativePageView setupInitialController] + 154 (ReactNativePageView.m:154)
5  APPNAME                        0x3c4884 -[ReactNativePageView didMoveToWindow] + 92 (ReactNativePageView.m:92)
6  UIKitCore                      0x29f760 -[UIView(Internal) _didMoveFromWindow:toWindow:]
7  UIKitCore                      0x29f244 -[UIView(Internal) _didMoveFromWindow:toWindow:]
8  UIKitCore                      0x29f244 -[UIView(Internal) _didMoveFromWindow:toWindow:]
9  UIKitCore                      0x29f244 -[UIView(Internal) _didMoveFromWindow:toWindow:]
10 UIKitCore                      0x29f244 -[UIView(Internal) _didMoveFromWindow:toWindow:]
11 UIKitCore                      0x1cbf00 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke
12 UIKitCore                      0x257adc -[UIView(Hierarchy) _postMovedFromSuperview:]
13 UIKitCore                      0x17a20c -[UIView(Internal) _addSubview:positioned:relativeTo:]
14 UIKitCore                      0x25f6c4 -[UITransitionView transition:fromView:toView:removeFromView:]
15 UIKitCore                      0x2bf838 -[UIViewControllerBuiltinTransitionViewAnimator animateTransition:]
16 UIKitCore                      0x48a170 ___UIViewControllerTransitioningRunCustomTransition_block_invoke_2
17 UIKitCore                      0x2c88f0 +[UIKeyboardSceneDelegate _pinInputViewsForKeyboardSceneDelegate:onBehalfOfResponder:duringBlock:]
18 UIKitCore                      0x33b35c ___UIViewControllerTransitioningRunCustomTransition_block_invoke.641
19 UIKitCore                      0x3c1d58 +[UIView(Animation) _setAlongsideAnimations:toRunByEndOfBlock:]
20 UIKitCore                      0x265698 _UIViewControllerTransitioningRunCustomTransition
21 UIKitCore                      0x88fd20 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.401
22 UIKitCore                      0x30c4cc -[_UIAfterCACommitBlock run]
23 UIKitCore                      0x227b8c -[_UIAfterCACommitQueue flush]
24 UIKitCore                      0x156518 _runAfterCACommitDeferredBlocks
25 UIKitCore                      0x156be4 _cleanUpAfterCAFlushAndRunDeferredBlocks
26 UIKitCore                      0x156db0 _afterCACommitHandler
27 CoreFoundation                 0x3e21c __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
28 CoreFoundation                 0xf454 __CFRunLoopDoObservers
29 CoreFoundation                 0xa9dc __CFRunLoopRun
30 CoreFoundation                 0x1dc30 CFRunLoopRunSpecific
31 GraphicsServices               0x1988 GSEventRunModal
32 UIKitCore                      0x4e5c50 -[UIApplication _run]
33 UIKitCore                      0x27f3d0 UIApplicationMain
34 APPNAME                       0x7044 main + 14 (main.m:14)
35 ???                            0x1058ec3d0 (Missing)

Have anybody experienced something similar and can help identifying the problem of the crash?

ghost commented 2 years ago

Experiencing same issue.

"@react-navigation/bottom-tabs": "6.3.2", "@react-navigation/native": "6.0.11", "@react-navigation/native-stack": "6.7.0", "react-native": "0.67.4", "react-native-collapsible-tab-view": "5.0.0-rc.13", "react-native-pager-view": "5.4.25",


Fatal Exception: NSRangeException
0  CoreFoundation                 0x99288 __exceptionPreprocess
1  libobjc.A.dylib                0x16744 objc_exception_throw
2  CoreFoundation                 0x1a4318 -[__NSCFString characterAtIndex:].cold.1
3  CoreFoundation                 0x3792c __NSDictionaryMutablePlaceholder
4  AppName                        0x70cfb8 -[ReactNativePageView setupInitialController] + 158 (ReactNativePageView.m:158)
5  AppName                        0x70c59c -[ReactNativePageView didMoveToWindow] + 93 (ReactNativePageView.m:93)
6  UIKitCore                      0x2b7588 -[UIView(Internal) _didMoveFromWindow:toWindow:]
7  UIKitCore                      0x2b706c -[UIView(Internal) _didMoveFromWindow:toWindow:]
8  UIKitCore                      0x2b706c -[UIView(Internal) _didMoveFromWindow:toWindow:]
9  UIKitCore                      0x2b706c -[UIView(Internal) _didMoveFromWindow:toWindow:]
10 UIKitCore                      0x2b706c -[UIView(Internal) _didMoveFromWindow:toWindow:]
11 UIKitCore                      0x2b706c -[UIView(Internal) _didMoveFromWindow:toWindow:]
12 UIKitCore                      0x2b706c -[UIView(Internal) _didMoveFromWindow:toWindow:]
13 UIKitCore                      0x1dd82c __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke
14 UIKitCore                      0x26d044 -[UIView(Hierarchy) _postMovedFromSuperview:]
15 UIKitCore                      0x189b90 -[UIView(Internal) _addSubview:positioned:relativeTo:]
16 UIKitCore                      0x2fedec -[UINavigationTransitionView transition:fromView:toView:]
17 UIKitCore                      0x2ab3fc -[UINavigationController _startTransition:fromViewController:toViewController:]
18 UIKitCore                      0x4d5748 -[UINavigationController _startDeferredTransitionIfNeeded:]
19 UIKitCore                      0x3aae1c -[UINavigationController __viewWillLayoutSubviews]
20 UIKitCore                      0x2d25dc -[UILayoutContainerView layoutSubviews]
21 UIKitCore                      0x18c17c -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
22 QuartzCore                     0x407fc CA::Layer::layout_if_needed(CA::Transaction*)
23 QuartzCore                     0x32c60 CA::Layer::layout_and_display_if_needed(CA::Transaction*)
24 QuartzCore                     0x475b4 CA::Context::commit_transaction(CA::Transaction*, double, double*)
25 QuartzCore                     0x504a8 CA::Transaction::commit()
26 QuartzCore                     0x323a0 CA::Transaction::flush_as_runloop_observer(bool)
27 CoreFoundation                 0x410c4 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
28 CoreFoundation                 0x10080 __CFRunLoopDoObservers
29 CoreFoundation                 0x1ec1c CFRunLoopRunSpecific
30 Foundation                     0x19444 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
31 Foundation                     0x5ae0c -[NSRunLoop(NSRunLoop) runUntilDate:]
32 AppName                        0x71a5b0 +[RNSplashScreen show] + 31 (RNSplashScreen.m:31)
33 AppName                        0x6ba0 -[AppDelegate application:didFinishLaunchingWithOptions:] + 69 (AppDelegate.m:69)
34 UIKitCore                      0x325a44 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:]
35 UIKitCore                      0x50ca78 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:]
36 UIKitCore                      0x4f5678 -[UIApplication _runWithMainScene:transitionContext:completion:]
37 UIKitCore                      0x3531a8 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:]
38 UIKitCore                      0x1ad57c _UIScenePerformActionsWithLifecycleActionMask
39 UIKitCore                      0x2d8090 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke
40 UIKitCore                      0x3f7fe0 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:]
41 UIKitCore                      0x636c58 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
42 UIKitCore                      0x5c21e0 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:]
43 UIKitCore                      0x1ae368 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke
44 UIKitCore                      0x26e3c0 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:]
45 UIKitCore                      0x1b026c _UISceneSettingsDiffActionPerformChangesWithTransitionContext
46 UIKitCore                      0x29a544 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]
47 UIKitCore                      0x71f240 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.615
48 UIKitCore                      0x1de64c -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:]
49 UIKitCore                      0x221fac -[UIScene scene:didUpdateWithDiff:transitionContext:completion:]
50 UIKitCore                      0x357fac -[UIApplication workspace:didCreateScene:withTransitionContext:completion:]
51 UIKitCore                      0x298808 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:]
52 FrontBoardServices             0x29294 -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:]
53 FrontBoardServices             0x4f090 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.215
54 FrontBoardServices             0xa308 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
55 FrontBoardServices             0xb958 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke
56 libdispatch.dylib              0x3a30 _dispatch_client_callout
57 libdispatch.dylib              0x74e0 _dispatch_block_invoke_direct
58 FrontBoardServices             0xbc70 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
59 FrontBoardServices             0xb040 -[FBSSerialQueue _targetQueue_performNextIfPossible]
60 FrontBoardServices             0xf700 -[FBSSerialQueue _performNextFromRunLoopSource]
61 CoreFoundation                 0xbb414 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
62 CoreFoundation                 0xcc1a0 __CFRunLoopDoSource0
63 CoreFoundation                 0x5694 __CFRunLoopDoSources0
64 CoreFoundation                 0xb05c __CFRunLoopRun
65 CoreFoundation                 0x1ebc8 CFRunLoopRunSpecific
66 GraphicsServices               0x1374 GSEventRunModal
67 UIKitCore                      0x514b58 -[UIApplication _run]
68 UIKitCore                      0x296090 UIApplicationMain
69 AppName                        0x7608 main + 14 (main.m:14)
70 ???                            0x105791da4 (Missing)
kjparkdavid commented 1 year ago

I ran into this issue when I set the index for initial tab but it setting to -1 because it was not found. Make sure it is not set to -1.

setIndex(index >= 0 ? index : 0);