Open benjaminkoetting opened 6 years ago
@bemazo yes this looks like we're trying to send an event up to the Javascript and when we create the bounds we're only passing in one lat/lng, we should add better logic to prevent this from ever attempting to create a bound.
Do you know what steps you need to take to hit this scenario it's happening, all in the native Android SDK, so I'm wondering if we're calling a method before the projection object is actually ready.
Thanks for reporting!
@nitaliano sorry at the moment I cannot reproduce it, I see it only sometimes in our sentry system with the stacktrace. So it must something during the runtime. Can it happend when we call setCamera
with wrong parameters?
We're seeing a lot of these (Android only) now after upgrading to RN 0.59. We currently have a dependency to this commit: https://github.com/nitaliano/react-native-mapbox-gl/commit/7ed29351081d5e34e895c95cb28b823f19d6b327. I know this is an old issue, but is there any pointer now to how we can solve this @nitaliano?
@KimAM I'm using this hack https://github.com/janicduplessis/react-native-mapbox-gl/commit/4edfefe0f52e26db49fefa652cc2a73bb2ffa0c4#diff-83bd90811e16ee14c9357ca5dd70f50cR1294, doesn't seem to cause issues but is definitely not a proper fix.
Thanks @janicduplessis 🙌
As per discussion in #586, the root cause is likely an onRegionDidChange
event that should/may be triggered as the Mapbox view is dismounted.
To all who have reported this issue, can you confirm that you are dismounting a Mapbox.MapView
, for instance by having the view inside a nested navigator or another conditional render?
My hypothesis is that as RN is dismounting the view, onCameraIdle
may be triggered by the native SDK. This will in turn create a race condition where the view dimensions can be [0, 0], making getVisibleRegion
only return a single coordinate instead of a pair.
Imo, the proper fix should be to check map dimensions and only return the callback if both dimensions are > 0.
@kristfal This was also our conclusion in a past we did last year to solve this error: https://github.com/innovactorybv/react-native-mapbox-gl/commit/b19842b9d5dafc651841746182ec6fe4a25d7908#diff-83bd90811e16ee14c9357ca5dd70f50cR1015
...
} catch (exception: InvalidLatLngBoundsException) {
// ignore invalid latlng exceptions, was seen happening during component unmounts
}
I agree with a better check 👍 I just wanted to confirm that, at the time, we've seen the same correlation with the component being unmounted.
Can confirm that this crash occurs when the component is being unmounted 👍
Ah well, it's a little bit diffent when unmounting. It does not have: Cannot create a LatLngBounds from 1 items
com.mapbox.mapboxsdk.exceptions.InvalidLatLngBoundsException:
at com.mapbox.mapboxsdk.geometry.LatLngBounds$Builder.build (LatLngBounds.java:440)
at com.mapbox.mapboxsdk.maps.Projection.getVisibleRegion (Projection.java:112)
at com.mapbox.rctmgl.components.mapview.RCTMGLMapView.makeRegionPayload (RCTMGLMapView.java:1263)
at com.mapbox.rctmgl.components.mapview.RCTMGLMapView.handleMapChangedEvent (RCTMGLMapView.java:1473)
at com.mapbox.rctmgl.components.mapview.RCTMGLMapView.access$1000 (RCTMGLMapView.java:91)
at com.mapbox.rctmgl.components.mapview.RCTMGLMapView$7.onCameraMove (RCTMGLMapView.java:485)
at com.mapbox.mapboxsdk.maps.CameraChangeDispatcher$2.run (CameraChangeDispatcher.java:67)
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:6944)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)
No fix on this issue?
we got this exception sometimes on a production build:
at the moment it is 100% Android, how we can catch this exception?
Thanks, Ben