nitaliano / react-native-mapbox-gl

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

NullPointer: fatalAttempt to invoke virtual method 'double com.mapbox.mapboxsdk.geometry.LatLng.getLatitude()' on a null object reference #1283

Open Gp2mv3 opened 6 years ago

Gp2mv3 commented 6 years ago

Hey, Some of our users on Android are experiencing this error:

Attempt to invoke virtual method 'double com.mapbox.mapboxsdk.geometry.LatLng.getLatitude()' on a null object reference

And here is the call stack:

java.lang.NullPointerException: Attempt to invoke virtual method 'double com.mapbox.mapboxsdk.geometry.LatLng.getLatitude()' on a null object reference
    at com.mapbox.rctmgl.components.mapview.RCTMGLMapView.makeRegionPayload(RCTMGLMapView.java:1168)
    at com.mapbox.rctmgl.components.mapview.RCTMGLMapView.sendRegionChangeEvent(RCTMGLMapView.java:1373)
    at com.mapbox.rctmgl.components.mapview.RCTMGLMapView.access$700(RCTMGLMapView.java:90)
    at com.mapbox.rctmgl.components.mapview.RCTMGLMapView$3.onCameraIdle(RCTMGLMapView.java:418)
    at com.mapbox.mapboxsdk.maps.CameraChangeDispatcher$4.run(CameraChangeDispatcher.java:106)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:7331)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

What's the reason of that error ? It seems to be related to GetLatitude but I don't see what they did wrong, this error happens when calling map.moveTo().

Gp2mv3 commented 6 years ago

I've noticed the same error but in a different function, here it happens when the map is mounted. The stacktrace is exactly the same.

Maybe it's more relevant to post those in the android SDK's repo ?

Regards,

Gp2mv3

nitaliano commented 6 years ago

Are you trying to make calls to the map before you get the events that it is ready?

Gp2mv3 commented 6 years ago

That's a good question, I don't check the event so it's more than probable ! I'll check for the next release of our app.

Thanks

Gp2mv3 commented 6 years ago

Looking at the events, what's the event saying that the map is ready ?...

nitaliano commented 6 years ago

you can try onDidFinishRenderingMap or onDidFinishLoadingMap you can see the description of the events here https://github.com/mapbox/react-native-mapbox-gl/blob/master/docs/MapView.md

also could be useful if you can track down what is causing this on your end from the JS side so maybe we can add it to the pre method queue