Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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
7 changes: 4 additions & 3 deletions shell/platform/glfw/flutter_glfw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -739,9 +739,10 @@ void FlutterDesktopWindowSetPixelRatioOverride(
bool FlutterDesktopRunWindowEventLoopWithTimeout(
FlutterDesktopWindowControllerRef controller,
uint32_t timeout_milliseconds) {
auto wait_duration = timeout_milliseconds == 0
? std::chrono::milliseconds::max()
: std::chrono::milliseconds(timeout_milliseconds);
std::chrono::nanoseconds wait_duration =
timeout_milliseconds == 0
? std::chrono::nanoseconds::max()
: std::chrono::milliseconds(timeout_milliseconds);
controller->event_loop->WaitForEvents(wait_duration);

return !glfwWindowShouldClose(controller->window.get());
Expand Down
11 changes: 7 additions & 4 deletions shell/platform/glfw/glfw_event_loop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ void GLFWEventLoop::WaitForEvents(std::chrono::nanoseconds max_wait) {
// Make sure the seconds are not integral.
using Seconds = std::chrono::duration<double, std::ratio<1>>;

std::lock_guard<std::mutex> lock(task_queue_mutex_);
const auto next_wake = task_queue_.empty() ? TaskTimePoint::max()
: task_queue_.top().fire_time;
TaskTimePoint next_wake;
{
std::lock_guard<std::mutex> 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<Seconds>(
std::min(next_wake - now, max_wait));
Expand All @@ -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);
}
Expand Down