React-native-snap-carousel: [ANDROID] Carousel crashing on data reload with FATAL EXCEPTION: main java.lang.ArrayIndexOutOfBoundsException: length=1; index=1

Created on 1 Jun 2020  路  4Comments  路  Source: meliorence/react-native-snap-carousel

Is this a bug report, a feature request, or a question?

A bug report

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

Android only (checked ios and everything is fine)

Is the bug reproductible in a production environment (not a debug one)?

Yes

Environment

Environment:
React: 16.11.0
React native: 0.62.2
react-native-snap-carousel: 4.0.0-beta.4

Target Platform:
Android (9.0)
iOS (13)

Expected Behavior

The carousel never crashes

Actual Behavior

When refreshing the data list (on reaching the end, i had elements to the carousel), it crash after i try to view one of the new item I just added. The native error stack is here:

```FATAL EXCEPTION: main
Process: com.app.example, PID: 5357
java.lang.RuntimeException: com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 543
detail: View tag:545
children(0): [
],
viewsToAdd(1): [
[0,543],
],

at com.facebook.react.bridge.ReactContext.handleException(ReactContext.java:370)
at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:31)
at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:965)
at android.view.Choreographer.doCallbacks(Choreographer.java:791)
at android.view.Choreographer.doFrame(Choreographer.java:722)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Caused by: com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 543
detail: View tag:545
children(0): [
],
viewsToAdd(1): [
[0,543],
],

at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:513)
at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:206)
at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:792)
at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:903)
at com.facebook.react.uimanager.UIViewOperationQueue.access$2400(UIViewOperationQueue.java:43)
at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:963)
at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
... 13 more

````

Steps to Reproduce

  1. Instantiate a carousel
  2. Add elements to the data list
  3. navigate to newly added elements. It crashes :-(

Most helpful comment

@CarbonC @bfaulk96 Just published 4.0.0-beta.5 that should fix the issue.

Not very proud of the workaround, but at least it shouldn't have any side effect. Had to fall back on this after scrutinizing every change made between RN 0.61 and RN 0.62 that could explain this new error but not finding anything...

All 4 comments

Just to clarify, it was working perfectly fine on version 3.9, but 3.9 was not really fluid as you know :/

I am also getting this issue on 4.0.0-beta.4, as well as on 4.0.0-beta.2.

WORKAROUND: this is caused by zindex style property. If you remove this line: { zIndex: this._getCustomDataLength() - index } line 574 of carousel.js the crash stops. But im not sure what are the consequences of that since the original issue that justify this code is still open on react native :/ @bfaulk96 you might be interested

@CarbonC @bfaulk96 Just published 4.0.0-beta.5 that should fix the issue.

Not very proud of the workaround, but at least it shouldn't have any side effect. Had to fall back on this after scrutinizing every change made between RN 0.61 and RN 0.62 that could explain this new error but not finding anything...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

niloufarMakhzani picture niloufarMakhzani  路  4Comments

AndrePech picture AndrePech  路  4Comments

littlehome-eugene picture littlehome-eugene  路  3Comments

amyogiji picture amyogiji  路  5Comments

Murena7 picture Murena7  路  3Comments