summaryrefslogtreecommitdiff
path: root/platform/android/src/style/sources/custom_geometry_source.cpp
diff options
context:
space:
mode:
authorŁukasz Paczos <lukas.paczos@gmail.com>2019-08-16 14:54:36 +0200
committerŁukasz Paczos <lukasz.paczos@mapbox.com>2019-08-19 10:22:45 +0200
commitbf34fb01900cb513dcc0fa5728f06504b62a7e26 (patch)
tree341d5fb5a765e636776cfcbd49826fe6a4e849cf /platform/android/src/style/sources/custom_geometry_source.cpp
parent98dbed241b94ac78dde001d58a3598ec01535bb6 (diff)
downloadqtlocation-mapboxgl-bf34fb01900cb513dcc0fa5728f06504b62a7e26.tar.gz
[android] check if the CustomGeometrySource's java peer is valid when the thread is shutting down
Diffstat (limited to 'platform/android/src/style/sources/custom_geometry_source.cpp')
-rw-r--r--platform/android/src/style/sources/custom_geometry_source.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/platform/android/src/style/sources/custom_geometry_source.cpp b/platform/android/src/style/sources/custom_geometry_source.cpp
index 057f5c99ba..dccca4cf46 100644
--- a/platform/android/src/style/sources/custom_geometry_source.cpp
+++ b/platform/android/src/style/sources/custom_geometry_source.cpp
@@ -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);