react-native-mapbox-gl icon indicating copy to clipboard operation
react-native-mapbox-gl copied to clipboard

Invalid Index errors from ShapeSourceManager / RCTSource

Open hampelm opened this issue 6 years ago • 7 comments

I'm getting these errors when swapping out layers on devices running old versions of android (eg KitKat 4.4). I'm working to isolate this in my code (and hopefully have a more reproducible bug) but it looks like maybe there could be an array length check to defend against this in RCTSource.java:169, similar to that in removeLayer in RCTSource.java:161?

Invalid index 0, size is 0
throwIndexOutOfBoundsException
    ArrayList.java:255
get
    ArrayList.java:308
getLayerAt
    RCTSource.java:169
getChildAt
    RCTMGLShapeSourceManager.java:58
getChildAt
    RCTMGLShapeSourceManager.java:35
manageChildren
    NativeViewHierarchyManager.java:370
execute
    UIViewOperationQueue.java:179
run
    UIViewOperationQueue.java:821
flushPendingBatches
    UIViewOperationQueue.java:928
access$2100
    UIViewOperationQueue.java:46
doFrameGuarded
    UIViewOperationQueue.java:988
doFrame
    GuardedFrameCallback.java:29
doFrame
    ReactChoreographer.java:134
doFrame
    ChoreographerCompat.java:105
run
    Choreographer.java:759
doCallbacks
    Choreographer.java:574
doFrame
    Choreographer.java:543
run
    Choreographer.java:747
handleCallback
    Handler.java:733
dispatchMessage
    Handler.java:95
loop
    Looper.java:136
main
    ActivityThread.java:5017
invokeNative
    Method.java
invoke
    Method.java:515
run
    ZygoteInit.java:779
main
    ZygoteInit.java:595
main
    NativeStart.java

Also seeing a variant here:

Invalid index 1, size is 0
throwIndexOutOfBoundsException
    ArrayList.java:255
add
    ArrayList.java:147
addFeature
    RCTMGLMapView.java:258
addView
    RCTMGLMapViewManager.java:75
addView
    RCTMGLMapViewManager.java:37
manageChildren
    NativeViewHierarchyManager.java:400
execute
    UIViewOperationQueue.java:179
run
    UIViewOperationQueue.java:821
flushPendingBatches
    UIViewOperationQueue.java:928
access$2100
    UIViewOperationQueue.java:46
doFrameGuarded
    UIViewOperationQueue.java:988
doFrame
    GuardedFrameCallback.java:29
doFrame
    ReactChoreographer.java:134
doFrame
    ChoreographerCompat.java:105
run
    Choreographer.java:759
doCallbacks
    Choreographer.java:574
doFrame
    Choreographer.java:543
run
    Choreographer.java:747
handleCallback
    Handler.java:733
dispatchMessage
    Handler.java:95
loop
    Looper.java:136
main
    ActivityThread.java:5017
invokeNative
    Method.java
invoke
    Method.java:515
run
    ZygoteInit.java:779
main
    ZygoteInit.java:595
main
    NativeStart.java

hampelm avatar May 23 '18 17:05 hampelm

I'm also seeing this fairly ofter. Any guidance would be appreciated! Saw it in current master build as well.

dorthwein avatar Jun 14 '18 14:06 dorthwein

I had to disable Android 4.x distribution with our app which is fair, it's ancient and didn't impact a lot of users. Would be nice to still support those devices if possible.

hampelm avatar Jun 15 '18 14:06 hampelm

I am having same crash. on Android. Model- Pixel Android version- 7.1.2 Here is the log- Here is the crash.

Could you please help me resolve this?

07-10 12:57:42.365 9511-9511/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.aws.android, PID: 9511 java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 11, Size: 0 at com.facebook.react.bridge.ReactContext.handleException(Unknown Source) at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(Unknown Source) at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(Unknown Source) at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(Unknown Source) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:872) at android.view.Choreographer.doCallbacks(Choreographer.java:686) at android.view.Choreographer.doFrame(Choreographer.java:618) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6121) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) Caused by: java.lang.IndexOutOfBoundsException: Index: 11, Size: 0 at java.util.ArrayList.get(ArrayList.java:411) at com.mapbox.rctmgl.components.styles.sources.RCTSource.getLayerAt(Unknown Source) at com.mapbox.rctmgl.components.styles.sources.RCTMGLShapeSourceManager.getChildAt(Unknown Source) at com.mapbox.rctmgl.components.styles.sources.RCTMGLShapeSourceManager.getChildAt(Unknown Source) at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(Unknown Source) at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(Unknown Source) at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(Unknown Source) at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(Unknown Source) at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(Unknown Source) at com.facebook.react.uimanager.UIViewOperationQueue$1.run(Unknown Source) at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(Unknown Source) at com.facebook.react.uimanager.UIViewOperationQueue.access$2100(Unknown Source) at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(Unknown Source) at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(Unknown Source) at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(Unknown Source) at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(Unknown Source) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:872) at android.view.Choreographer.doCallbacks(Choreographer.java:686) at android.view.Choreographer.doFrame(Choreographer.java:618) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6121) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

img

fnusneha avatar Jul 16 '18 16:07 fnusneha

Hi all, I have kit kat on my android and i am using after release an apk with "gradlew assembleRelease" under ur_project/android. And it is working. I advise you to try this. I was getting error kind of like this error(I dont remember exactly)...

scalactic avatar Aug 02 '18 15:08 scalactic

Ran into this sporatically when a component was being re-rendered due to props changing. Quick fix was to override shouldComponentUpdate.

It seems there might be some sort of race condition in the android side of things here.

macobo avatar Oct 16 '19 20:10 macobo

This can also be caused by MapView having non react-native-mapbox-gl components as children.

anlai2 avatar Dec 20 '19 18:12 anlai2

This can also be caused by MapView having non react-native-mapbox-gl components as children.

Thank you! this is resolve my problem.

ruanlinos avatar Jul 20 '20 18:07 ruanlinos