Fix null-pointer dereference MapRenderer Android (#2631)

This commit is contained in:
Bart Louwers
2024-07-18 16:39:47 +02:00
committed by GitHub
parent 156781acd4
commit f188a65615
2 changed files with 8 additions and 2 deletions

View File

@@ -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

View File

@@ -23,7 +23,8 @@ MapRenderer::MapRenderer(jni::JNIEnv& _env,
localIdeographFontFamily(localIdeographFontFamily_ ? jni::Make<std::string>(_env, localIdeographFontFamily_)
: std::optional<std::string>{}),
threadPool(Scheduler::GetBackground(), {}),
mailboxData(this) {}
mailboxData(this),
backend(std::make_unique<AndroidRendererBackend>(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<AndroidRendererBackend>(threadPool);
}
void MapRenderer::scheduleSnapshot(std::unique_ptr<SnapshotCallback> 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<std::mutex> 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