-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix uv_async crash (aka Option B) #2400
Comments
|
@jfirebaugh Yes let's fix the |
@kkaefer Where else have you noticed |
I should revisit this since @mikemorris updated the libuv version. |
@zugaldia I put some logging in the The thread that does the send is the OkHTTP internal Java thread (from the @kkaefer It seems the problem that even cancelled OkHTTP requests from the Java side can outlive the C++ |
|
It is still crashing. For some reason both |
@zugaldia Do you know why OkHTTP will call both I added a check to ignore the second callback and it seems to prevent crashing. |
As a side note, see that I rethrow the |
@zugaldia I think throwing an exception in I will add a null check to JNI which will switch to the failure code if it happens. |
@zugaldia can you check my latest commit. I added the null check for body. I disabled the double response workaround to see if it is still needed. I also handle exceptions in onResponse as a failure to prevent outstanding exceptions. It this all works fine, next step is to check for any memory leaks. |
@ljbade check the latest commit. Good news, I cannot reproduce the crash. |
I produced a new 11-06 17:03:39.303 31174-31274/com.mapbox.sirius I/mbgl: {Worker}[Sprite]: Can't find sprite named '-11'
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: Callback failure for canceled call to https://a.tiles.mapbox.com/...
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: java.net.ProtocolException: unexpected end of stream
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at com.squareup.okhttp.internal.http.HttpConnection$FixedLengthSource.read(HttpConnection.java:421)
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at okio.RealBufferedSource.read(RealBufferedSource.java:50)
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at okio.RealBufferedSource.exhausted(RealBufferedSource.java:60)
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at okio.InflaterSource.refill(InflaterSource.java:101)
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at okio.InflaterSource.read(InflaterSource.java:62)
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at okio.GzipSource.read(GzipSource.java:80)
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at okio.Buffer.writeAll(Buffer.java:956)
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at okio.RealBufferedSource.readByteArray(RealBufferedSource.java:92)
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at com.squareup.okhttp.ResponseBody.bytes(ResponseBody.java:57)
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at com.mapbox.mapboxsdk.http.HTTPContext$HTTPRequest.onResponse(HTTPContext.java:99)
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:168)
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
11-06 17:03:51.573 31174-31310/com.mapbox.sirius I/OkHttpClient: at java.lang.Thread.run(Thread.java:818) |
That exception looks like something @zugaldia had before. It happens if the Internet drops out during |
@ljbade So this is a known and acceptable issue then? |
@bleege I'm going to double check that first. |
The relevant code:
@bleege What is happening is some sort of IO failure in |
Next steps - rebase and condense PR into one tidy commit. Then wait for CI and merge. |
@ljbade Before you merge could you tell us more about the "some sort of IO failure in |
@bleege I realise I should have not used The line in question is mapbox-gl-native/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPContext.java Line 99 in c66aec9
That line does the actual IO work of downloading the HTTP request. If something happens during that function either because of a network failure, or a cancellation request that function will throw an You can see that the @zugaldia Do you agree with my assesment? |
I've been running some scenarios and I've added a new application interceptor to OkHttp to help us with debugging: #2905 (comment) To clarify the situation, we are not seeing the "callback gets called twice" situation anymore, instead, when we find an exception in What I'm not sure at this point is if whether we should rethrow the Another approach could be not to rethrow it and do a |
🎉
|
@zugaldia Thanks for digging into. Since it seems like everyone gets confused by OkHTTP logging the exception despite it being harmless, perhaps we should just swallow the exception? If you compare master to 2400-lock you will see I used to just |
Agreed. As the exception is directed to |
@zugaldia I just pushed a commit with return instead of rethrow... can you check it doesnt bring back double onresponse/onfailure? |
@ljbade FWIW I just did a fresh build with the latest code and I couldn't find the double callback call. |
@zugaldia Excellent I think we are ready to merge, except for figuring out how to benchmark the perf improvements. However we could do this after merge. |
While investigating #2295 @ljbade discovered that OkHttp and
uv_async
were not working properly together. The result was the decision to ship0.1.0
usingcurl
instead. This ticket will be about restoring OkHttp by working out the issues withuv_async
as documented by @ljbade. Specifically:@incanus @ljbade @kkaefer
The text was updated successfully, but these errors were encountered: