Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix null-pointer dereference MapRenderer Android #2938

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions platform/android/MapboxGLAndroidSDK/src/cpp/map_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ MapRenderer::MapRenderer(jni::JNIEnv& _env,
pixelRatio(pixelRatio_),
localIdeographFontFamily(localIdeographFontFamily_ ? jni::Make<std::string>(_env, localIdeographFontFamily_)
: optional<std::string>{}),
mailboxData(this) {}
threadPool(Scheduler::GetBackground()),
mailboxData(this),
backend(std::make_unique<AndroidRendererBackend>()) {}

MapRenderer::MailboxData::MailboxData(Scheduler* scheduler_) : scheduler(scheduler_) {
MapRenderer::MailboxData::MailboxData(Scheduler* scheduler_)
: scheduler(scheduler_) {
assert(scheduler);
}

Expand Down Expand Up @@ -143,7 +146,7 @@ void MapRenderer::requestSnapshot(SnapshotCallback callback) {

void MapRenderer::resetRenderer() {
renderer.reset();
backend.reset();
backend = std::make_unique<AndroidRendererBackend>();
}

void MapRenderer::scheduleSnapshot(std::unique_ptr<SnapshotCallback> callback) {
Expand All @@ -165,6 +168,7 @@ void MapRenderer::render(JNIEnv&) {
}

// Activate the backend
assert(backend);
gfx::BackendScope backendGuard { *backend };

// Ensure that the "current" scheduler on the render thread is
Expand All @@ -190,6 +194,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class MapRenderer : public Scheduler {
float pixelRatio;
optional<std::string> localIdeographFontFamily;

std::shared_ptr<ThreadPool> threadPool;
std::shared_ptr<Scheduler> threadPool;
const MailboxData mailboxData;

std::mutex initialisationMutex;
Expand Down
Loading