diff --git a/android/cpp/NativeMapView.cpp b/android/cpp/NativeMapView.cpp index 6761f3ede..d046642dd 100644 --- a/android/cpp/NativeMapView.cpp +++ b/android/cpp/NativeMapView.cpp @@ -479,7 +479,7 @@ void NativeMapView::start() { LOG_ASSERT(display != EGL_NO_DISPLAY); LOG_ASSERT(context != EGL_NO_CONTEXT); - map->start(); + map->start(true); } void NativeMapView::loadExtensions() { 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 2b150e8ba..d58bfa036 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 @@ -401,7 +401,6 @@ public class MapView extends SurfaceView { // Must be called from Activity onStart public void onStart() { Log.v(TAG, "onStart"); - mNativeMapView.pause(); mNativeMapView.start(); } diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index f2f10665e..6dbcd3550 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -36,7 +36,7 @@ public: ~Map(); // Start the map render thread. It is asynchronous. - void start(); + void start(bool start_paused = false); // Stop the map render thread. This call will block until the map rendering thread stopped. // The optional callback function will be invoked repeatedly until the map thread is stopped. @@ -46,7 +46,7 @@ public: void stop(stop_callback cb = nullptr, void *data = nullptr); // Pauses the render thread. The render thread will stop running but will not be terminated and will not lose state until resumed. - void pause(); + void pause(bool wait_for_pause = false); // Resumes a paused render thread void resume(); diff --git a/src/map/map.cpp b/src/map/map.cpp index ed105375f..2de77cd3c 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -78,7 +78,7 @@ uv::worker &Map::getWorker() { return *workers; } -void Map::start() { // TODO add pause arg +void Map::start(bool start_paused) { assert(uv_thread_self() == main_thread); assert(!async); @@ -89,6 +89,11 @@ void Map::start() { // TODO add pause arg // Reset the flag. is_stopped = false; + // Do we need to pause first? + if (start_paused) { + pause(); + } + // Setup async notifications // Iron out the differences between libuv 0.10 and 0.11 @@ -159,8 +164,9 @@ void Map::stop(stop_callback cb, void *data) { async = false; } -void Map::pause() { +void Map::pause(bool wait_for_pause) { assert(uv_thread_self() == main_thread); + assert(async); Log::Info(Event::General, "Map::pause() start"); // TODO wait until paused before return @@ -182,6 +188,7 @@ void Map::pause() { void Map::resume() { assert(uv_thread_self() == main_thread); + assert(async); Log::Info(Event::General, "Map::resume() start"); Log::Info(Event::General, "Map::resume() locking");