[android] check if the CustomGeometrySource's java peer is valid when the thread is shutting down

This commit is contained in:
Łukasz Paczos
2019-08-16 14:54:36 +02:00
committed by Łukasz Paczos
parent 98dbed241b
commit bf34fb0190
2 changed files with 15 additions and 10 deletions

View File

@@ -65,7 +65,12 @@ namespace android {
static auto& javaClass = jni::Class<CustomGeometrySource>::Singleton(*_env);
static auto fetchTile = javaClass.GetMethod<void (jni::jint, jni::jint, jni::jint)>(*_env, "fetchTile");
assert(javaPeer);
// The source is removed on the main thread, but it still exists on the Render thread until the frame is complete.
// This might cause fetchTile/cancelTile invocations when the Java thread is shutting down and the peer has already been released.
// See https://github.com/mapbox/mapbox-gl-native/issues/12551.
if(!javaPeer) {
return;
}
auto peer = jni::Cast(*_env, javaClass, javaPeer);
peer.Call(*_env, fetchTile, (int)tileID.z, (int)tileID.x, (int)tileID.y);
@@ -77,7 +82,12 @@ namespace android {
static auto& javaClass = jni::Class<CustomGeometrySource>::Singleton(*_env);
static auto cancelTile = javaClass.GetMethod<void (jni::jint, jni::jint, jni::jint)>(*_env, "cancelTile");
assert(javaPeer);
// The source is removed on the main thread, but it still exists on the Render thread until the frame is complete.
// This might cause fetchTile/cancelTile invocations when the Java thread is shutting down and the peer has already been released.
// See https://github.com/mapbox/mapbox-gl-native/issues/12551.
if(!javaPeer) {
return;
}
auto peer = jni::Cast(*_env, javaClass, javaPeer);
peer.Call(*_env, cancelTile, (int)tileID.z, (int)tileID.x, (int)tileID.y);