From 853f82402016ecd38d99de862ba152865265a126 Mon Sep 17 00:00:00 2001 From: Ivo van Dongen Date: Mon, 20 Nov 2017 15:22:34 +0200 Subject: [PATCH 1/7] [android] Enable map rendering when app is paused --- .../src/main/java/com/mapbox/mapboxsdk/maps/MapView.java | 9 +++++++++ .../com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java | 8 ++++++++ .../renderer/glsurfaceview/GLSurfaceViewMapRenderer.java | 4 ++-- .../renderer/textureview/TextureViewMapRenderer.java | 4 ++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index de917979aef..2d2dc03022f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -365,6 +365,10 @@ public void onStart() { if (mapboxMap != null) { mapboxMap.onStart(); } + + if (mapRenderer != null) { + mapRenderer.onStart(); + } } /** @@ -396,6 +400,11 @@ public void onStop() { // map was destroyed before it was started mapboxMap.onStop(); } + + if (mapRenderer != null) { + mapRenderer.onStop(); + } + ConnectivityReceiver.instance(getContext()).deactivate(); FileSource.getInstance(getContext()).deactivate(); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java index 961438ed146..2baff473e94 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java @@ -33,6 +33,10 @@ public MapRenderer(Context context) { nativeInitialize(this, fileSource, pixelRatio, programCacheDir); } + public void onStart() { + // Implement if needed + } + public void onPause() { // Implement if needed } @@ -41,6 +45,10 @@ public void onResume() { // Implement if needed } + public void onStop() { + // Implement if needed + } + public void onDestroy() { // Implement if needed } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java index ba2e118faaa..d98e4d06a32 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java @@ -31,12 +31,12 @@ public GLSurfaceViewMapRenderer(Context context, GLSurfaceView glSurfaceView) { } @Override - public void onPause() { + public void onStop() { glSurfaceView.onPause(); } @Override - public void onResume() { + public void onStart() { glSurfaceView.onResume(); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java index 8cd724a8287..397904b1f58 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java @@ -74,7 +74,7 @@ public void queueEvent(Runnable runnable) { * {@inheritDoc} */ @Override - public void onPause() { + public void onStop() { renderThread.onPause(); } @@ -82,7 +82,7 @@ public void onPause() { * {@inheritDoc} */ @Override - public void onResume() { + public void onStart() { renderThread.onResume(); } From e57127746ce022dbf2ca67eeaffd1bf9cb26eab6 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Wed, 22 Nov 2017 17:08:23 +0100 Subject: [PATCH 2/7] [android] - activate filesource to list offline regions (#10531) --- .../java/com/mapbox/mapboxsdk/offline/OfflineManager.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java index 130284e88d2..6a2bf6b07b0 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java @@ -149,8 +149,8 @@ private Handler getHandler() { * * @param callback the callback to be invoked */ - public void listOfflineRegions(@NonNull - final ListOfflineRegionsCallback callback) { + public void listOfflineRegions(@NonNull final ListOfflineRegionsCallback callback) { + fileSource.activate(); listOfflineRegions(fileSource, new ListOfflineRegionsCallback() { @Override @@ -158,6 +158,7 @@ public void onList(final OfflineRegion[] offlineRegions) { getHandler().post(new Runnable() { @Override public void run() { + fileSource.deactivate(); callback.onList(offlineRegions); } }); @@ -168,6 +169,7 @@ public void onError(final String error) { getHandler().post(new Runnable() { @Override public void run() { + fileSource.deactivate(); callback.onError(error); } }); @@ -241,6 +243,7 @@ private boolean isValidOfflineRegionDefinition(OfflineRegionDefinition definitio /** * Changing or bypassing this limit without permission from Mapbox is prohibited * by the Mapbox Terms of Service. + * * @param limit the new tile count limit. */ public native void setOfflineMapboxTileCountLimit(long limit); From ab1b0738bc97db9add8e07a3c6bd57555c94911e Mon Sep 17 00:00:00 2001 From: Tobrun Date: Wed, 22 Nov 2017 18:46:31 +0100 Subject: [PATCH 3/7] [android] - harden MarkerView integration by checking for null bitmap (#10532) --- .../src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java index 2ee17c227d2..8749656e354 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java @@ -36,7 +36,7 @@ public String getId() { * @return The bitmap being used for the icon. */ public Bitmap getBitmap() { - if (mBitmap.getConfig() != Bitmap.Config.ARGB_8888) { + if (mBitmap != null && mBitmap.getConfig() != Bitmap.Config.ARGB_8888) { mBitmap = mBitmap.copy(Bitmap.Config.ARGB_8888, false); } return mBitmap; From 05f0ba44b946e6911fe4893eb468909621788559 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Wed, 29 Nov 2017 12:26:52 +0100 Subject: [PATCH 4/7] [android] - use concurrent lists for camera change listeners (#10542) --- .../maps/CameraChangeDispatcher.java | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java index cf780dcc3f3..f046744c31a 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java @@ -2,8 +2,7 @@ import android.support.annotation.NonNull; -import java.util.ArrayList; -import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraIdleListener; import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveCanceledListener; @@ -15,10 +14,10 @@ class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, M private boolean idle = true; - private final List onCameraMoveStartedListenerList = new ArrayList<>(); - private final List onCameraMoveCanceledListenerList = new ArrayList<>(); - private final List onCameraMoveListenerList = new ArrayList<>(); - private final List onCameraIdleListenerList = new ArrayList<>(); + private final CopyOnWriteArrayList onCameraMoveStarted = new CopyOnWriteArrayList<>(); + private final CopyOnWriteArrayList onCameraMoveCanceled = new CopyOnWriteArrayList<>(); + private final CopyOnWriteArrayList onCameraMove = new CopyOnWriteArrayList<>(); + private final CopyOnWriteArrayList onCameraIdle = new CopyOnWriteArrayList<>(); private OnCameraMoveStartedListener onCameraMoveStartedListener; private OnCameraMoveCanceledListener onCameraMoveCanceledListener; @@ -58,8 +57,8 @@ public void onCameraMoveStarted(int reason) { } // new API - if (!onCameraMoveStartedListenerList.isEmpty()) { - for (OnCameraMoveStartedListener cameraMoveStartedListener : onCameraMoveStartedListenerList) { + if (!onCameraMoveStarted.isEmpty()) { + for (OnCameraMoveStartedListener cameraMoveStartedListener : onCameraMoveStarted) { cameraMoveStartedListener.onCameraMoveStarted(reason); } } @@ -73,8 +72,8 @@ public void onCameraMove() { } // new API - if (!onCameraMoveListenerList.isEmpty() && !idle) { - for (OnCameraMoveListener cameraMoveListener : onCameraMoveListenerList) { + if (!onCameraMove.isEmpty() && !idle) { + for (OnCameraMoveListener cameraMoveListener : onCameraMove) { cameraMoveListener.onCameraMove(); } } @@ -88,8 +87,8 @@ public void onCameraMoveCanceled() { } // new API - if (!onCameraMoveCanceledListenerList.isEmpty() && !idle) { - for (OnCameraMoveCanceledListener cameraMoveCanceledListener : onCameraMoveCanceledListenerList) { + if (!onCameraMoveCanceled.isEmpty() && !idle) { + for (OnCameraMoveCanceledListener cameraMoveCanceledListener : onCameraMoveCanceled) { cameraMoveCanceledListener.onCameraMoveCanceled(); } } @@ -105,8 +104,8 @@ public void onCameraIdle() { } // new API - if (!onCameraIdleListenerList.isEmpty()) { - for (OnCameraIdleListener cameraIdleListener : onCameraIdleListenerList) { + if (!onCameraIdle.isEmpty()) { + for (OnCameraIdleListener cameraIdleListener : onCameraIdle) { cameraIdleListener.onCameraIdle(); } } @@ -114,42 +113,42 @@ public void onCameraIdle() { } void addOnCameraIdleListener(@NonNull OnCameraIdleListener listener) { - onCameraIdleListenerList.add(listener); + onCameraIdle.add(listener); } void removeOnCameraIdleListener(@NonNull OnCameraIdleListener listener) { - if (onCameraIdleListenerList.contains(listener)) { - onCameraIdleListenerList.remove(listener); + if (onCameraIdle.contains(listener)) { + onCameraIdle.remove(listener); } } void addOnCameraMoveCancelListener(OnCameraMoveCanceledListener listener) { - onCameraMoveCanceledListenerList.add(listener); + onCameraMoveCanceled.add(listener); } void removeOnCameraMoveCancelListener(OnCameraMoveCanceledListener listener) { - if (onCameraMoveCanceledListenerList.contains(listener)) { - onCameraMoveCanceledListenerList.remove(listener); + if (onCameraMoveCanceled.contains(listener)) { + onCameraMoveCanceled.remove(listener); } } void addOnCameraMoveStartedListener(OnCameraMoveStartedListener listener) { - onCameraMoveStartedListenerList.add(listener); + onCameraMoveStarted.add(listener); } void removeOnCameraMoveStartedListener(OnCameraMoveStartedListener listener) { - if (onCameraMoveStartedListenerList.contains(listener)) { - onCameraMoveStartedListenerList.remove(listener); + if (onCameraMoveStarted.contains(listener)) { + onCameraMoveStarted.remove(listener); } } void addOnCameraMoveListener(OnCameraMoveListener listener) { - onCameraMoveListenerList.add(listener); + onCameraMove.add(listener); } void removeOnCameraMoveListener(OnCameraMoveListener listener) { - if (onCameraMoveListenerList.contains(listener)) { - onCameraMoveListenerList.remove(listener); + if (onCameraMove.contains(listener)) { + onCameraMove.remove(listener); } } } From fbd451ad3af920723b6db75884e37b947a665af5 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 30 Nov 2017 11:45:40 +0100 Subject: [PATCH 5/7] [android] - handle destroying activity programmatically as part of theme switching (#10589) --- .../src/main/java/com/mapbox/mapboxsdk/maps/MapView.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 2d2dc03022f..1f8faf0231a 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -416,8 +416,12 @@ public void onStop() { public void onDestroy() { destroyed = true; mapCallback.clearOnMapReadyCallbacks(); - nativeMapView.destroy(); - nativeMapView = null; + + if (nativeMapView != null) { + // null when destroying an activity programmatically mapbox-navigation-android/issues/503 + nativeMapView.destroy(); + nativeMapView = null; + } if (mapRenderer != null) { mapRenderer.onDestroy(); From 4e6a3ae14399aff7d2933ed0089a4f2bdf44dceb Mon Sep 17 00:00:00 2001 From: Tobrun Date: Wed, 6 Dec 2017 11:51:33 +0100 Subject: [PATCH 6/7] [android] - add FileSource activation/deactivation to MapSnapshotter, handle multiple deactivate scenario in FileSource (#10556) --- .../mapbox/mapboxsdk/storage/FileSource.java | 24 ++------------ platform/android/src/file_source.cpp | 19 ++++++++--- platform/android/src/file_source.hpp | 1 + .../src/snapshotter/map_snapshotter.cpp | 33 +++++++++++++++---- .../src/snapshotter/map_snapshotter.hpp | 5 +++ 5 files changed, 49 insertions(+), 33 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java index 41dc449b50a..f0cb8d973a6 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java @@ -6,10 +6,8 @@ import android.content.res.AssetManager; import android.os.Environment; import android.support.annotation.NonNull; - import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.constants.MapboxConstants; - import timber.log.Timber; /** @@ -119,28 +117,14 @@ public static boolean isExternalStorageReadable() { } private long nativePtr; - private long activeCounter; - private boolean wasPaused; private FileSource(String cachePath, AssetManager assetManager) { initialize(Mapbox.getAccessToken(), cachePath, assetManager); } - public void activate() { - activeCounter++; - if (activeCounter == 1 && wasPaused) { - wasPaused = false; - resume(); - } - } + public native void activate(); - public void deactivate() { - activeCounter--; - if (activeCounter == 0) { - wasPaused = true; - pause(); - } - } + public native void deactivate(); public native void setAccessToken(@NonNull String accessToken); @@ -148,10 +132,6 @@ public void deactivate() { public native void setApiBaseUrl(String baseUrl); - private native void resume(); - - private native void pause(); - /** * Sets a callback for transforming URLs requested from the internet *

diff --git a/platform/android/src/file_source.cpp b/platform/android/src/file_source.cpp index a576661a4f7..6a9d7badb07 100644 --- a/platform/android/src/file_source.cpp +++ b/platform/android/src/file_source.cpp @@ -63,11 +63,22 @@ void FileSource::setResourceTransform(jni::JNIEnv& env, jni::Objectresume(); + if (!activationCounter) { + activationCounter = optional(1) ; + return; + } + + activationCounter.value()++; + if (activationCounter == 1) { + fileSource->resume(); + } } void FileSource::pause(jni::JNIEnv&) { - fileSource->pause(); + activationCounter.value()--; + if (activationCounter == 0) { + fileSource->pause(); + } } jni::Class FileSource::javaClass; @@ -100,8 +111,8 @@ void FileSource::registerNative(jni::JNIEnv& env) { METHOD(&FileSource::setAccessToken, "setAccessToken"), METHOD(&FileSource::setAPIBaseUrl, "setApiBaseUrl"), METHOD(&FileSource::setResourceTransform, "setResourceTransform"), - METHOD(&FileSource::resume, "resume"), - METHOD(&FileSource::pause, "pause") + METHOD(&FileSource::resume, "activate"), + METHOD(&FileSource::pause, "deactivate") ); } diff --git a/platform/android/src/file_source.hpp b/platform/android/src/file_source.hpp index 2933aedf861..194f7846221 100644 --- a/platform/android/src/file_source.hpp +++ b/platform/android/src/file_source.hpp @@ -54,6 +54,7 @@ class FileSource { static void registerNative(jni::JNIEnv&); private: + optional activationCounter; std::unique_ptr> resourceTransform; std::unique_ptr fileSource; }; diff --git a/platform/android/src/snapshotter/map_snapshotter.cpp b/platform/android/src/snapshotter/map_snapshotter.cpp index 637eb5c1fdc..71f8b4f4c02 100644 --- a/platform/android/src/snapshotter/map_snapshotter.cpp +++ b/platform/android/src/snapshotter/map_snapshotter.cpp @@ -15,7 +15,7 @@ namespace android { MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env, jni::Object _obj, - jni::Object jFileSource, + jni::Object _jFileSource, jni::jfloat _pixelRatio, jni::jint width, jni::jint height, @@ -34,16 +34,16 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env, return; } - auto& fileSource = mbgl::android::FileSource::getDefaultFileSource(_env, jFileSource); + jFileSource = FileSource::getNativePeer(_env, _jFileSource); + auto& fileSource = mbgl::android::FileSource::getDefaultFileSource(_env, _jFileSource); auto size = mbgl::Size { static_cast(width), static_cast(height) }; auto cameraOptions = position ? CameraPosition::getCameraOptions(_env, position) : CameraOptions(); optional bounds; if (region) { bounds = LatLngBounds::getLatLngBounds(_env, region); } - + showLogo = _showLogo; - // Create the core snapshotter snapshotter = std::make_unique(fileSource, *threadPool, @@ -58,8 +58,9 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env, MapSnapshotter::~MapSnapshotter() = default; -void MapSnapshotter::start(JNIEnv&) { +void MapSnapshotter::start(JNIEnv& env) { MBGL_VERIFY_THREAD(tid); + activateFilesource(env); snapshotCallback = std::make_unique>( *Scheduler::GetCurrent(), @@ -79,17 +80,19 @@ void MapSnapshotter::start(JNIEnv&) { static auto onSnapshotReady = javaClass.GetMethod)>(*_env, "onSnapshotReady"); javaPeer->Call(*_env, onSnapshotReady, mapSnapshot); } + + deactivateFilesource(*_env); }); snapshotter->snapshot(snapshotCallback->self()); } -void MapSnapshotter::cancel(JNIEnv&) { +void MapSnapshotter::cancel(JNIEnv& env) { MBGL_VERIFY_THREAD(tid); snapshotCallback.reset(); + deactivateFilesource(env); } - void MapSnapshotter::setStyleUrl(JNIEnv& env, jni::String styleURL) { snapshotter->setStyleURL(jni::Make(env, styleURL)); } @@ -108,6 +111,22 @@ void MapSnapshotter::setRegion(JNIEnv& env, jni::Object region) { snapshotter->setRegion(LatLngBounds::getLatLngBounds(env, region)); } +// Private methods // + +void MapSnapshotter::activateFilesource(JNIEnv& env) { + if (!activatedFilesource) { + activatedFilesource = true; + jFileSource->resume(env); + } +} + +void MapSnapshotter::deactivateFilesource(JNIEnv& env) { + if (activatedFilesource) { + activatedFilesource = false; + jFileSource->pause(env); + } +} + // Static methods // jni::Class MapSnapshotter::javaClass; diff --git a/platform/android/src/snapshotter/map_snapshotter.hpp b/platform/android/src/snapshotter/map_snapshotter.hpp index 8cd85060bff..4cdf4bcf2b6 100644 --- a/platform/android/src/snapshotter/map_snapshotter.hpp +++ b/platform/android/src/snapshotter/map_snapshotter.hpp @@ -65,6 +65,11 @@ class MapSnapshotter { std::shared_ptr threadPool; std::unique_ptr> snapshotCallback; std::unique_ptr snapshotter; + + FileSource *jFileSource; + void activateFilesource(JNIEnv&); + void deactivateFilesource(JNIEnv&); + bool activatedFilesource = false; }; } // namespace android From c3311730d991cbc0037f6283ac79600e7bfcb0ef Mon Sep 17 00:00:00 2001 From: Chris Loer Date: Wed, 22 Nov 2017 13:18:22 -0800 Subject: [PATCH 7/7] [core, ios, qt, android] Close race condition in RunLoop (issue #9620) Because a message we queue from the foreground may cause the background to complete, exit, and tear down the AsyncTask, we have to block queue processing until we've finished our call to AsyncTask::send(). Broadening the scope of a mutex is scary, but I audited the code of our four implementations of AsyncTask and I don't see any way this could cause a deadlock. --- platform/android/src/run_loop.cpp | 6 ++++-- platform/darwin/src/run_loop.cpp | 6 ++++-- platform/default/run_loop.cpp | 6 ++++-- platform/qt/src/run_loop.cpp | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/platform/android/src/run_loop.cpp b/platform/android/src/run_loop.cpp index dff7d1d9845..1d284a9e720 100644 --- a/platform/android/src/run_loop.cpp +++ b/platform/android/src/run_loop.cpp @@ -217,8 +217,10 @@ LOOP_HANDLE RunLoop::getLoopHandle() { } void RunLoop::push(std::shared_ptr task) { - withMutex([&] { queue.push(std::move(task)); }); - impl->wake(); + withMutex([&] { + queue.push(std::move(task)); + impl->wake(); + }); } void RunLoop::run() { diff --git a/platform/darwin/src/run_loop.cpp b/platform/darwin/src/run_loop.cpp index 2ba8f8415bb..d60a88cf52b 100644 --- a/platform/darwin/src/run_loop.cpp +++ b/platform/darwin/src/run_loop.cpp @@ -30,8 +30,10 @@ RunLoop::~RunLoop() { } void RunLoop::push(std::shared_ptr task) { - withMutex([&] { queue.push(std::move(task)); }); - impl->async->send(); + withMutex([&] { + queue.push(std::move(task)); + impl->async->send(); + }); } void RunLoop::run() { diff --git a/platform/default/run_loop.cpp b/platform/default/run_loop.cpp index 6375dba78ec..5bccd21d56c 100644 --- a/platform/default/run_loop.cpp +++ b/platform/default/run_loop.cpp @@ -130,8 +130,10 @@ LOOP_HANDLE RunLoop::getLoopHandle() { } void RunLoop::push(std::shared_ptr task) { - withMutex([&] { queue.push(std::move(task)); }); - impl->async->send(); + withMutex([&] { + queue.push(std::move(task)); + impl->async->send(); + }); } void RunLoop::run() { diff --git a/platform/qt/src/run_loop.cpp b/platform/qt/src/run_loop.cpp index 71ea19032a3..af0c50ebb94 100644 --- a/platform/qt/src/run_loop.cpp +++ b/platform/qt/src/run_loop.cpp @@ -53,8 +53,10 @@ LOOP_HANDLE RunLoop::getLoopHandle() { } void RunLoop::push(std::shared_ptr task) { - withMutex([&] { queue.push(task); }); - impl->async->send(); + withMutex([&] { + queue.push(std::move(task)); + impl->async->send(); + }); } void RunLoop::run() {