summaryrefslogtreecommitdiff
path: root/platform/android/src/map_renderer_runnable.hpp
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-11-08 15:28:03 +0200
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-11-09 15:24:34 +0200
commitc30161e4c8d7cbc95b84f1b8dea8f5c7abe242a2 (patch)
tree3ac3eb39645d13ec13b653b06d83b0e372e9fd92 /platform/android/src/map_renderer_runnable.hpp
parent43f89d6b6a040fea97a882ca620ca7c890afd364 (diff)
downloadqtlocation-mapboxgl-c30161e4c8d7cbc95b84f1b8dea8f5c7abe242a2.tar.gz
[android] MapRendererRunnable - avoid weak reference table overflow
Apparently on some devices the weak reference table is limited (numbers around 52000). Even though we don't use that many weak references, when GC is not called for a while they can stack up and a crash will occur before the GC has had the time to clear the references. The C++ peer now holds on to a global ref (strong) which can be obtained to queue the java peer and then release automatically so that the GC can take over after the runnable has been executed.
Diffstat (limited to 'platform/android/src/map_renderer_runnable.hpp')
-rw-r--r--platform/android/src/map_renderer_runnable.hpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/platform/android/src/map_renderer_runnable.hpp b/platform/android/src/map_renderer_runnable.hpp
index 75646a442d..46fb028d26 100644
--- a/platform/android/src/map_renderer_runnable.hpp
+++ b/platform/android/src/map_renderer_runnable.hpp
@@ -8,8 +8,6 @@
#include <jni/jni.hpp>
-#include "jni/generic_global_ref_deleter.hpp"
-
namespace mbgl {
namespace android {
@@ -39,10 +37,11 @@ public:
void run(jni::JNIEnv&);
- jni::Object<MapRendererRunnable> getPeer();
+ // Transfers ownership of the Peer object to the caller
+ jni::UniqueObject<MapRendererRunnable> peer();
private:
- GenericUniqueWeakObject<MapRendererRunnable> javaPeer;
+ jni::UniqueObject<MapRendererRunnable> javaPeer;
std::weak_ptr<Mailbox> mailbox;
};