nitaliano / react-native-mapbox-gl

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

Android Crash when custom icon cannot load for Annotation #1309

Open Gp2mv3 opened 6 years ago

Gp2mv3 commented 6 years ago

Hey, We are adding custom icons, from our server to the map. We want to be able to change the icons remotely.

When the image isn't loadable (because there is not connexion for instance), we have a crash. Here is the stacktrace:

07-26 16:49:55.607 25341  3526 W BitmapUtils: Failed to connect to /192.168.1.1:80
07-26 16:49:55.617 25341 25341 E AndroidRuntime: FATAL EXCEPTION: main
07-26 16:49:55.617 25341 25341 E AndroidRuntime: Process: com.sparks, PID: 25341
07-26 16:49:55.617 25341 25341 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Bitmap$Config android.graphics.Bitmap.getConfig()' on a null object reference
07-26 16:49:55.617 25341 25341 E AndroidRuntime:    at com.mapbox.mapboxsdk.maps.NativeMapView.addImage(NativeMapView.java:761)
07-26 16:49:55.617 25341 25341 E AndroidRuntime:    at com.mapbox.mapboxsdk.maps.MapboxMap.addImage(MapboxMap.java:464)
07-26 16:49:55.617 25341 25341 E AndroidRuntime:    at com.mapbox.rctmgl.utils.DownloadMapImageTask.onPostExecute(DownloadMapImageTask.java:73)
07-26 16:49:55.617 25341 25341 E AndroidRuntime:    at com.mapbox.rctmgl.utils.DownloadMapImageTask.onPostExecute(DownloadMapImageTask.java:22)
07-26 16:49:55.617 25341 25341 E AndroidRuntime:    at android.os.AsyncTask.finish(AsyncTask.java:695)
07-26 16:49:55.617 25341 25341 E AndroidRuntime:    at android.os.AsyncTask.-wrap1(Unknown Source:0)
07-26 16:49:55.617 25341 25341 E AndroidRuntime:    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712)
07-26 16:49:55.617 25341 25341 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)
07-26 16:49:55.617 25341 25341 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:164)
07-26 16:49:55.617 25341 25341 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:6753)
07-26 16:49:55.617 25341 25341 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
07-26 16:49:55.617 25341 25341 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
07-26 16:49:55.617 25341 25341 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

I think it should be less hard when an image isn't loading. No ?

Regards,

Gp2mv3

onitzschke commented 5 years ago

@Gp2mv3 if the bug fixed with the PR then please close this issue.