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
committerGuardiola31337 <pablo.guardiola@mapbox.com>2017-11-10 10:08:32 +0100
commit1b17e3f4936e866a55bc905a8664309ded97d225 (patch)
tree2070ffb6e52b62860785a777227867c899697d85 /platform/android/src/map_renderer_runnable.hpp
parent60cf834ee9bd7ff960c673eadf42ebf8b100cdd2 (diff)
downloadqtlocation-mapboxgl-upstream/pg-cherry-picks.tar.gz
[android] MapRendererRunnable - avoid weak reference table overflowupstream/pg-cherry-picks
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;
};