diff --git a/android/cpp/NativeMapView.cpp b/android/cpp/NativeMapView.cpp index d46ea913c..3d9a3b89e 100644 --- a/android/cpp/NativeMapView.cpp +++ b/android/cpp/NativeMapView.cpp @@ -284,22 +284,26 @@ bool NativeMapView::createSurface(ANativeWindow* window_) { return false; } - if (!eglMakeCurrent(display, surface, surface, context)) { - LOG_ERROR("eglMakeCurrent() returned error %d", eglGetError()); - } + if (!first_time) { + first_time = true; - log_gl_string(GL_VENDOR, "Vendor"); - log_gl_string(GL_RENDERER, "Renderer"); - log_gl_string(GL_VERSION, "Version"); - log_gl_string(GL_SHADING_LANGUAGE_VERSION, "SL Version"); // In the emulator this returns NULL with error code 0? https://code.google.com/p/android/issues/detail?id=78977 - log_gl_string(GL_EXTENSIONS, "Extensions"); + if (!eglMakeCurrent(display, surface, surface, context)) { + LOG_ERROR("eglMakeCurrent() returned error %d", eglGetError()); + } - loadExtensions(); + log_gl_string(GL_VENDOR, "Vendor"); + log_gl_string(GL_RENDERER, "Renderer"); + log_gl_string(GL_VERSION, "Version"); + log_gl_string(GL_SHADING_LANGUAGE_VERSION, "SL Version"); // In the emulator this returns NULL with error code 0? https://code.google.com/p/android/issues/detail?id=78977 + log_gl_string(GL_EXTENSIONS, "Extensions"); - if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, - EGL_NO_CONTEXT)) { - LOG_ERROR("eglMakeCurrent(EGL_NO_CONTEXT) returned error %d", - eglGetError()); + loadExtensions(); + + if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, + EGL_NO_CONTEXT)) { + LOG_ERROR("eglMakeCurrent(EGL_NO_CONTEXT) returned error %d", + eglGetError()); + } } resume(); diff --git a/android/cpp/NativeMapView.hpp b/android/cpp/NativeMapView.hpp index 7a7ad1817..5e12084b3 100644 --- a/android/cpp/NativeMapView.hpp +++ b/android/cpp/NativeMapView.hpp @@ -91,6 +91,8 @@ private: std::string style_url; std::string api_key; + + bool first_time = false; }; class MBGLView: public mbgl::View { diff --git a/android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/MapView.java b/android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/MapView.java index d58bfa036..ebec3db83 100644 --- a/android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/MapView.java +++ b/android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/MapView.java @@ -374,6 +374,7 @@ public class MapView extends SurfaceView { mNativeMapView.initializeDisplay(); mNativeMapView.initializeContext(); + mNativeMapView.start(); } // Called when we need to save instance state @@ -393,6 +394,7 @@ public class MapView extends SurfaceView { // Must be called from Activity onDestroy public void onDestroy() { Log.v(TAG, "onDestroy"); + mNativeMapView.stop(); mNativeMapView.terminateContext(); mNativeMapView.terminateDisplay(); } @@ -401,14 +403,14 @@ public class MapView extends SurfaceView { // Must be called from Activity onStart public void onStart() { Log.v(TAG, "onStart"); - mNativeMapView.start(); + //mNativeMapView.start(); } // Called when we need to terminate the GL context // Must be called from Activity onPause public void onStop() { Log.v(TAG, "onStop"); - mNativeMapView.stop(); + //mNativeMapView.stop(); } // Called when we need to stop the render thread diff --git a/src/map/map.cpp b/src/map/map.cpp index ba298c00e..483ae276e 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -230,12 +230,16 @@ void Map::run() { void Map::check_for_pause() { mutex_run->lock(); while (pausing) { + view.make_inactive(); + mutex_pause->lock(); is_paused = true; cond_pause->broadcast(); mutex_pause->unlock(); cond_run->wait(*mutex_run); + + view.make_active(); } mutex_pause->lock();