nitaliano / react-native-mapbox-gl

A Mapbox GL react native module for creating custom maps
Other
2.16k stars 697 forks source link

java.lang.IndexOutOfBoundsException - com.mapbox.rctmgl.components.styles.sources.RCTSource.getLayerAt #924

Closed butchmarshall closed 5 years ago

butchmarshall commented 6 years ago

Just reported today. Only one so far.

Samsung Galaxy Note8 (greatqltecs), 6144MB RAM, Android 7.1
Report 1 of 1
java.lang.IndexOutOfBoundsException: 
  at java.util.ArrayList.get (ArrayList.java:411)
  at com.mapbox.rctmgl.components.styles.sources.RCTSource.getLayerAt (RCTSource.java:169)
  at com.mapbox.rctmgl.components.styles.sources.RCTMGLShapeSourceManager.getChildAt (RCTMGLShapeSourceManager.java:58)
  at com.mapbox.rctmgl.components.styles.sources.RCTMGLShapeSourceManager.getChildAt (RCTMGLShapeSourceManager.java:35)
  at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren (NativeViewHierarchyManager.java:371)
  at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute (UIViewOperationQueue.java:180)
  at com.facebook.react.uimanager.UIViewOperationQueue$1.run (UIViewOperationQueue.java:819)
  at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches (UIViewOperationQueue.java:926)
  at com.facebook.react.uimanager.UIViewOperationQueue.access$2100 (UIViewOperationQueue.java:47)
  at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded (UIViewOperationQueue.java:986)
  at com.facebook.react.uimanager.GuardedFrameCallback.doFrame (GuardedFrameCallback.java:31)
  at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame (ReactChoreographer.java:136)
  at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame (ChoreographerCompat.java:107)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:928)
  at android.view.Choreographer.doCallbacks (Choreographer.java:705)
  at android.view.Choreographer.doFrame (Choreographer.java:637)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:916)
  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:6823)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1563)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1451)
phuochau commented 6 years ago

Same error but in different function. I'm sure that I have data

13 5109-5109/com.petroninja.debug E/unknown:ReactNative: Exception in native call
                                                                         java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
                                                                             at java.util.ArrayList.add(ArrayList.java:457)
                                                                             at com.mapbox.rctmgl.components.mapview.RCTMGLMapView.addFeature(RCTMGLMapView.java:198)
                                                                             at com.mapbox.rctmgl.components.mapview.RCTMGLMapViewManager.addView(RCTMGLMapViewManager.java:51)
                                                                             at com.mapbox.rctmgl.components.mapview.RCTMGLMapViewManager.addView(RCTMGLMapViewManager.java:27)
                                                                             at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:395)
                                                                             at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:177)
                                                                             at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:776)
                                                                             at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:855)
                                                                             at com.facebook.react.uimanager.UIViewOperationQueue.access$1600(UIViewOperationQueue.java:46)
                                                                             at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:900)
                                                                             at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:31)
                                                                             at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:136)
                                                                             at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:107)
                                                                             at android.view.Choreographer$CallbackRecord.run(Choreographer.java:869)
                                                                             at android.view.Choreographer.doCallbacks(Choreographer.java:683)
                                                                             at android.view.Choreographer.doFrame(Choreographer.java:616)
                                                                             at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
                                                                             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:6077)
                                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

Render method

renderPhotos () {
    const { myPhotos } = this.state

    if (!myPhotos) return null
    if (myPhotos.length === 0) return null

    console.log('myPhotos', myPhotos)

    return myPhotos.map(p => {
      return (
        <MapboxGL.PointAnnotation
          key={p.Id}
          id={p.Id.toString()}
          coordinate={[p.Long, p.Lat]}
        >
          <View>
            <Image
              source={{ uri: 'photo' }}
              style={{ width: 15, height: 15 }}
            />
          </View>
        </MapboxGL.PointAnnotation>
      )
    })
  }
fnusneha commented 6 years ago

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

tlenclos commented 6 years ago

Same here with "@mapbox/react-native-mapbox-gl": "^6.1".

07-20 14:39:02.780 10195-10195/com.orpi.aroundme E/unknown:ReactNative: Exception in native call
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.get(ArrayList.java:437)
        at com.mapbox.rctmgl.components.styles.sources.RCTSource.getLayerAt(RCTSource.java:169)
        at com.mapbox.rctmgl.components.styles.sources.RCTMGLShapeSourceManager.getChildAt(RCTMGLShapeSourceManager.java:58)
        at com.mapbox.rctmgl.components.styles.sources.RCTMGLShapeSourceManager.getChildAt(RCTMGLShapeSourceManager.java:35)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:536)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:538)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:538)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:538)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:538)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:538)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:538)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:538)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:431)
        at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:180)
        at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:822)
        at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:929)
        at com.facebook.react.uimanager.UIViewOperationQueue.access$2100(UIViewOperationQueue.java:47)
        at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:989)
        at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:31)
        at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:136)
        at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:107)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:909)
        at android.view.Choreographer.doCallbacks(Choreographer.java:723)
        at android.view.Choreographer.doFrame(Choreographer.java:655)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
tlenclos commented 6 years ago

The issue for me was that I included <MapboxGL.ShapeSource> component outside of the MapView component. My bad ;)

fnusneha commented 6 years ago

In my case I have MapboxGL.ShapeSource> component inside of the MapView , still i am getting the crash- const map = <Mapbox.MapView styleURL={Mapbox.StyleURL.SatelliteStreet} zoomLevel={3} centerCoordinate={centerCoordinates} style={mapStyle} ref={ref => (this.map = ref)} zoomEnabled={this.state.showCallouts} pitchEnabled={false} scrollEnabled={this.state.showCallouts} rotateEnabled={false} onPress={() => {this.onPress();}} minZoomLevel={1} maxZoomLevel={10}> <Mapbox.ShapeSource id='hurricaneSource' shape={***}

nitaliano commented 6 years ago

@fnusneha can you post your full render method here, we'll need to see what layers you're using.

fnusneha commented 6 years ago

@nitaliano Shared in email with you. Thanks.

kristfal commented 5 years ago

Hey,

in an effort to clean out old tickets, I'm closing this one.

The crash is likely caused by using belowLayerId or aboveLayerId with layer references that does not exist in the current style.

There may be race conditions in the ways layers are created at runtime, so you should be careful about specifying these layers.

If you are not using these props, please reopen the ticket again and we'll have a look.

yurilawnguru commented 5 years ago

I'm still getting this error

/unknown:ReactNative: Exception in native call
    java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
        at java.util.ArrayList.get(ArrayList.java:437)
        at com.mapbox.rctmgl.components.mapview.RCTMGLMapView.getFeatureAt(RCTMGLMapView.java:311)
        at com.mapbox.rctmgl.components.mapview.RCTMGLMapViewManager.getChildAt(RCTMGLMapViewManager.java:85)
        at com.mapbox.rctmgl.components.mapview.RCTMGLMapViewManager.getChildAt(RCTMGLMapViewManager.java:37)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:580)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:584)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:584)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:584)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:584)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:584)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:584)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:584)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:584)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:584)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:584)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:468)
        at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:227)
        at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:917)
        at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1025)
        at com.facebook.react.uimanager.UIViewOperationQueue.access$2600(UIViewOperationQueue.java:46)
        at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1085)
        at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
        at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:166)
        at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:84)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:909)
        at android.view.Choreographer.doCallbacks(Choreographer.java:723)
        at android.view.Choreographer.doFrame(Choreographer.java:655)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6592)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:769)

That's my code:

         <MapboxGL.MapView
                    zoomLevel={8}
                    style={{ flex: 1 }}
                    styleURL={MapboxGL.StyleURL.Light}
                    scrollEnabled={true}
                    centerCoordinate={center}
                    ref={refmap => {
                        this.map = refmap;
                    }}
                    logoEnabled={true}
                    pitchEnabled={false}
                    rotateEnabled={true}
                    contentInset={[0, 0, 25, 0]}>
                        {
                        (!!listPin && listPin !== []) && listPin.map(pin => {
                            return <MapboxGL.ShapeSource
                                    id={pin.id}
                                    shape={pin.shape}>
                                    <MapboxGL.SymbolLayer
                                        id={pin.symbolId}
                                        style={pin.symbol} />
                                </MapboxGL.ShapeSource>
                            })
                        }
          </MapboxGL.MapView>

Dependencies:

"react": "16.8.3",
"react-native": "0.59.5",
"@mapbox/react-native-mapbox-gl": "https://github.com/nitaliano/react-native-mapbox-gl.git#master"
iGroza commented 2 years ago

same issue