Native will get destroyed before the Java HTTPRequest and asynchronous requests might still get answered. If the request gets canceled, we now clear the reference to the native code and it will never reach it. Lock is needed because OkHTTP replies on its own thread, so we need to guard the access to the variable we use for checking if the Request was canceled. In the future we could remove the lock and use Runnable when we move Android main loop to Looper instead of libuv. Like the other implementations of HTTPRequest on Mapbox GL Native, the request is destroyed synchronously on ::cancel().
6.0 KiB
6.0 KiB