Skip to content

Commit

Permalink
Cancel and dispose network requestHandles onDestroy (#1899)
Browse files Browse the repository at this point in the history
* Cancel and dispose network requestHandles onDestroy

* Cleanup - addressing review comments

- removing accidental @keep
- use httpHandler directly
  • Loading branch information
tallytalwar committed Oct 11, 2018
1 parent c793609 commit 319a09e
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -275,6 +275,7 @@ void UIThreadInit(@NonNull final GLSurfaceView view, @Nullable final HttpHandler
*/
protected void dispose() {

cancelAllNetworkRequests();
httpHandler = null;

// Prevent any other calls to native functions during dispose
Expand Down Expand Up @@ -1428,6 +1429,18 @@ public void onSurfaceCreated(final GL10 gl, final EGLConfig config) {
// Networking methods
// ==================

void cancelAllNetworkRequests() {
if (httpHandler == null) {
return;
}
synchronized (httpRequestHandles) {
for (int i = 0; i < httpRequestHandles.size(); i++) {
httpHandler.cancelRequest(httpRequestHandles.valueAt(i));
}
httpRequestHandles.clear();
}
}

@Keep
void cancelUrlRequest(final long requestHandle) {
final HttpHandler handler = httpHandler;
Expand Down

0 comments on commit 319a09e

Please sign in to comment.