This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
[android] Crash when downloading an area with bad internet connection #8786
Copy link
Copy link
Closed
Description
Trying to reproduce #8645 I got a crash when downloading an offline area using bad internet connection.
Steps to trigger behavior
- Download an offline region
- It starts downloading
04-20 17:36:02.689 28643-28643/com.mapbox.mapboxsdk.testapp D/OfflineActivity: 502/63636 resources; 29145003 bytes downloaded. - Connection stopped
04-20 17:36:03.543 3109-3227/? D/ClClient: Not sending keepalive. Current connection state=STOPPED - App crashes
logcat
04-20 17:36:13.550 3109-3227/? D/ClClient: Not sending keepalive. Current connection state=STOPPED
04-20 17:36:16.173 770-31512/? D/NetlinkSocketObserver: NeighborEvent{elapsedMs=24053586, 192.168.1.1, [E041365747F8], RTM_NEWNEIGH, NUD_STALE}
04-20 17:36:16.253 1893-1914/? D/BluetoothAdapter: stopLeScan()
04-20 17:36:16.254 1893-1914/? D/BluetoothAdapter: startLeScan(): null
04-20 17:36:16.254 1893-1914/? E/BluetoothAdapter: startLeScan: cannot get BluetoothLeScanner
04-20 17:36:16.310 28643-372/com.mapbox.mapboxsdk.testapp D/HTTPRequest: Request failed due to a temporary error: SSL handshake timed out
04-20 17:36:16.315 28643-28643/com.mapbox.mapboxsdk.testapp E/mbgl: {pboxsdk.testapp}[Setup]: loading style failed: SSL handshake timed out
04-20 17:36:17.017 28643-31546/com.mapbox.mapboxsdk.testapp I/HTTPRequest: Request failed due to a connection error: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.018 28643-372/com.mapbox.mapboxsdk.testapp I/HTTPRequest: Request failed due to a connection error: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.021 28643-31551/com.mapbox.mapboxsdk.testapp I/HTTPRequest: Request failed due to a connection error: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.021 28643-31552/com.mapbox.mapboxsdk.testapp I/HTTPRequest: Request failed due to a connection error: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.030 28643-28643/com.mapbox.mapboxsdk.testapp E/mbgl: {pboxsdk.testapp}[Style]: Failed to load sprite: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.040 28643-31552/com.mapbox.mapboxsdk.testapp I/HTTPRequest: Request failed due to a connection error: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.044 28643-31546/com.mapbox.mapboxsdk.testapp I/HTTPRequest: Request failed due to a connection error: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.051 28643-372/com.mapbox.mapboxsdk.testapp I/HTTPRequest: Request failed due to a connection error: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.055 28643-31551/com.mapbox.mapboxsdk.testapp I/HTTPRequest: Request failed due to a connection error: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.060 28643-31552/com.mapbox.mapboxsdk.testapp I/HTTPRequest: Request failed due to a connection error: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.072 28643-28643/com.mapbox.mapboxsdk.testapp E/OfflineActivity: onError reason: REASON_CONNECTION
04-20 17:36:17.074 28643-28643/com.mapbox.mapboxsdk.testapp E/OfflineActivity: onError message: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.077 28643-28643/com.mapbox.mapboxsdk.testapp E/mbgl: {pboxsdk.testapp}[Style]: Failed to load sprite: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.078 28643-28643/com.mapbox.mapboxsdk.testapp E/OfflineActivity: onError reason: REASON_CONNECTION
04-20 17:36:17.078 28643-28643/com.mapbox.mapboxsdk.testapp E/OfflineActivity: onError message: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.079 28643-28643/com.mapbox.mapboxsdk.testapp E/OfflineActivity: onError reason: REASON_CONNECTION
04-20 17:36:17.079 28643-28643/com.mapbox.mapboxsdk.testapp E/OfflineActivity: onError message: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.081 28643-31546/com.mapbox.mapboxsdk.testapp I/HTTPRequest: Request failed due to a connection error: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.082 28643-372/com.mapbox.mapboxsdk.testapp I/HTTPRequest: Request failed due to a connection error: Unable to resolve host "api.mapbox.com": No address associated with hostname
04-20 17:36:17.084 28643-28643/com.mapbox.mapboxsdk.testapp D/AndroidRuntime: Shutting down VM
--------- beginning of crash
04-20 17:36:17.084 28643-28643/com.mapbox.mapboxsdk.testapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mapbox.mapboxsdk.testapp, PID: 28643
java.lang.NullPointerException: Attempt to invoke interface method 'void com.mapbox.mapboxsdk.offline.OfflineRegion$OfflineRegionObserver.onError(com.mapbox.mapboxsdk.offline.OfflineRegionError)' on a null object reference
at com.mapbox.mapboxsdk.offline.OfflineRegion$1$2.run(OfflineRegion.java:270)
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:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
It seems a race condition when accessing STATE_ACTIVE in deliverMessages() which ends trying to call observer.onError(error); when observer is previously set to null.
cc/ @zugaldia
Activity
tobrun commentedon May 8, 2017
looked into this bug, my initial tests with enabled/disabling the connection fully doesn't show this crash. The download is correctly stopped and resumed after.
tobrun commentedon May 8, 2017
was able to reproduce this with an Emulator and playing around with connectivity status
tobrun commentedon May 8, 2017
It seems that the observer is set to null when the Internet connection is lost, while adding null checks removes the crash. It doesn't correclty restore integration after the connection is reset (the download starts to continue again but the observer isn't notified anymore for updating the UI).
tobrun commentedon May 8, 2017
Ah, it's not an SDK issue but an issue with OfflineActivity, when an timeout occurs an error occurs and we are setting the observer to null which isn't valid.
tobrun commentedon May 15, 2017
This landed in #8919 to the release branch, closing