diff --git a/shell/platform/glfw/flutter_glfw.cc b/shell/platform/glfw/flutter_glfw.cc index a5c847f846a17..e069cac3a170d 100644 --- a/shell/platform/glfw/flutter_glfw.cc +++ b/shell/platform/glfw/flutter_glfw.cc @@ -740,7 +740,7 @@ bool FlutterDesktopRunWindowEventLoopWithTimeout( FlutterDesktopWindowControllerRef controller, uint32_t timeout_milliseconds) { auto wait_duration = timeout_milliseconds == 0 - ? std::chrono::milliseconds::max() + ? std::chrono::nanoseconds::max() : std::chrono::milliseconds(timeout_milliseconds); controller->event_loop->WaitForEvents(wait_duration); diff --git a/shell/platform/glfw/glfw_event_loop.cc b/shell/platform/glfw/glfw_event_loop.cc index a92bab50b5a26..f1fc08c77ce03 100644 --- a/shell/platform/glfw/glfw_event_loop.cc +++ b/shell/platform/glfw/glfw_event_loop.cc @@ -63,9 +63,12 @@ void GLFWEventLoop::WaitForEvents(std::chrono::nanoseconds max_wait) { // Make sure the seconds are not integral. using Seconds = std::chrono::duration>; - std::lock_guard lock(task_queue_mutex_); - const auto next_wake = task_queue_.empty() ? TaskTimePoint::max() - : task_queue_.top().fire_time; + TaskTimePoint next_wake; + { + std::lock_guard lock(task_queue_mutex_); + next_wake = task_queue_.empty() ? TaskTimePoint::max() + : task_queue_.top().fire_time; + } const auto duration_to_wait = std::chrono::duration_cast( std::min(next_wake - now, max_wait)); @@ -84,7 +87,7 @@ void GLFWEventLoop::WaitForEvents(std::chrono::nanoseconds max_wait) { GLFWEventLoop::TaskTimePoint GLFWEventLoop::TimePointFromFlutterTime( uint64_t flutter_target_time_nanos) { const auto now = TaskTimePoint::clock::now(); - const auto flutter_duration = + const int64_t flutter_duration = flutter_target_time_nanos - FlutterEngineGetCurrentTime(); return now + std::chrono::nanoseconds(flutter_duration); }