[android] check if the CustomGeometrySource's java peer is valid when the thread is shutting down
This commit is contained in:
committed by
Łukasz Paczos
parent
98dbed241b
commit
bf34fb0190
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user