diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index 1d326b4e1..843c0e9b6 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -6,9 +6,12 @@ - Avoid logging error for onMove(0,0) on Android ([#2580](https://github.com/maplibre/maplibre-native/pull/2580)). - Experimental API to toggle tile cache in map view ([#2590](https://github.com/maplibre/maplibre-native/pull/2590)). This can reduce memory usage at the cost of having to parse tile data again when the zoom level changes. +- Add TaggedScheduler, couple lifetime of tasks and orchestrator ([#2398](https://github.com/maplibre/maplibre-native/pull/2398)). ### 🐞 Bug fixes +- Fix null pointer dereference MapRenderer Android. + ## 11.0.2-pre0 ### ✨ Features and improvements diff --git a/platform/android/MapLibreAndroid/src/cpp/map_renderer.cpp b/platform/android/MapLibreAndroid/src/cpp/map_renderer.cpp index 174f10572..80009ffe5 100644 --- a/platform/android/MapLibreAndroid/src/cpp/map_renderer.cpp +++ b/platform/android/MapLibreAndroid/src/cpp/map_renderer.cpp @@ -23,7 +23,8 @@ MapRenderer::MapRenderer(jni::JNIEnv& _env, localIdeographFontFamily(localIdeographFontFamily_ ? jni::Make(_env, localIdeographFontFamily_) : std::optional{}), threadPool(Scheduler::GetBackground(), {}), - mailboxData(this) {} + mailboxData(this), + backend(std::make_unique(threadPool)) {} MapRenderer::MailboxData::MailboxData(Scheduler* scheduler_) : scheduler(scheduler_) { @@ -159,7 +160,7 @@ void MapRenderer::requestSnapshot(SnapshotCallback callback) { void MapRenderer::resetRenderer() { renderer.reset(); - backend.reset(); + backend = std::make_unique(threadPool); } void MapRenderer::scheduleSnapshot(std::unique_ptr callback) { @@ -181,6 +182,7 @@ void MapRenderer::render(JNIEnv&) { } // Activate the backend + assert(backend); gfx::BackendScope backendGuard{*backend}; // Ensure that the "current" scheduler on the render thread is @@ -206,6 +208,7 @@ void MapRenderer::onSurfaceCreated(JNIEnv&) { std::lock_guard lock(initialisationMutex); // The GL context is already active if get a new surface. + assert(backend); gfx::BackendScope backendGuard{*backend, gfx::BackendScope::ScopeType::Implicit}; // The android system will have already destroyed the underlying