diff options
author | Łukasz Paczos <lukas.paczos@gmail.com> | 2019-08-16 14:54:36 +0200 |
---|---|---|
committer | Łukasz Paczos <lukas.paczos@gmail.com> | 2019-08-16 14:54:36 +0200 |
commit | 1e9ea4dc548cc48a174b487a22c12bd94362e246 (patch) | |
tree | a8e22fb6ba9e0725a9847464d8d4680567a4fe47 /platform/android/src/style/sources/custom_geometry_source.cpp | |
parent | 0f34eb7b253e83b8c4aef7ed6c83cd7b3801fa4c (diff) | |
download | qtlocation-mapboxgl-1e9ea4dc548cc48a174b487a22c12bd94362e246.tar.gz |
[android] check if the CustomGeometrySource's java peer is valid when the thread is shutting downupstream/lp-cgs-peer-reference-12551
Diffstat (limited to 'platform/android/src/style/sources/custom_geometry_source.cpp')
-rw-r--r-- | platform/android/src/style/sources/custom_geometry_source.cpp | 14 |
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); |