mapzen / eraser-map

Privacy-focused mapping application for Android
GNU General Public License v3.0
75 stars 24 forks source link

HTTP SocketException When Loading Map Tiles #792

Closed bleege closed 7 years ago

bleege commented 7 years ago
11-23 10:27:03.163 8823-9573/com.mapzen.erasermap I/OkHttpClient: Callback failure for canceled call to https://tile.mapzen.com/...
                                                                  java.net.SocketException: socket is closed
                                                                      at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:752)
                                                                      at okio.Okio$2.read(Okio.java:139)
                                                                      at okio.AsyncTimeout$2.read(AsyncTimeout.java:211)
                                                                      at okio.RealBufferedSource.read(RealBufferedSource.java:50)
                                                                      at com.squareup.okhttp.internal.http.HttpConnection$FixedLengthSource.read(HttpConnection.java:418)
                                                                      at okio.RealBufferedSource.read(RealBufferedSource.java:50)
                                                                      at com.squareup.okhttp.internal.http.HttpEngine$2.read(HttpEngine.java:944)
                                                                      at okio.RealBufferedSource.read(RealBufferedSource.java:50)
                                                                      at okio.RealBufferedSource.exhausted(RealBufferedSource.java:60)
                                                                      at okio.InflaterSource.refill(InflaterSource.java:101)
                                                                      at okio.InflaterSource.read(InflaterSource.java:62)
                                                                      at okio.GzipSource.read(GzipSource.java:80)
                                                                      at okio.Buffer.writeAll(Buffer.java:956)
                                                                      at okio.RealBufferedSource.readByteArray(RealBufferedSource.java:92)
                                                                      at com.mapzen.tangram.MapController$9.onResponse(MapController.java:881)
                                                                      at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:168)
                                                                      at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
                                                                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                      at java.lang.Thread.run(Thread.java:761)

This looks like it may be an issue within Tangram instead of Eraser Map, but this is the app where I first experienced this problem so I'm reporting it here. Eraser Map continues to function with no noticeable degrade in performance in the UX / UI, so this looks like something that likely just needs to be cleaned up with the HTTP request threading / canceling logic to keep the overall runtime health of implementing apps in good shape.

/cc @sarahlensing @ecgreb

ecgreb commented 7 years ago

Thanks for the report @bleege.

Looks like the socket is getting closed between when the request is made and when we attempt to read the response. Perhaps the request is canceled on another thread when Tangram detects the tile is no longer needed but not before the callback has begun to execute.

Maybe there is something in the OkHttp Response object we can check before attempting to read the byte array?

https://github.com/square/okhttp/blob/f36bed41a87296d8cd641b5c0602fcb860fe7043/okhttp/src/main/java/com/squareup/okhttp/Response.java

Otherwise I guess we'll need to take more of a manual approach of tracking which tile requests have been canceled.

Copying Tangram ES folks @blair1618 @tallytalwar @karimnaaji

sarahsnow1 commented 7 years ago

Closing due to inactivity