From 88114ac6eb50e7dabad2a0f42f8d128774bb7457 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Wed, 30 Jun 2021 16:27:14 -0700 Subject: [PATCH] apply newer fluter runloop in run_loop.cpp for windows performance fix --- pubspec.lock | 40 ++++++++++++------------------------- windows/runner/run_loop.cpp | 11 ++++++++-- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index ec4202b9..58f991e0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,7 +42,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.3.1" + version: "1.2.0" clock: dependency: transitive description: @@ -70,7 +70,7 @@ packages: name: dbus url: "https://pub.dartlang.org" source: hosted - version: "0.5.1" + version: "0.5.2" desktop_notifications: dependency: "direct main" description: @@ -91,14 +91,14 @@ packages: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.2" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.1" + version: "6.1.2" flutter: dependency: "direct main" description: flutter @@ -125,7 +125,7 @@ packages: name: glob url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "2.0.1" http: dependency: transitive description: @@ -189,20 +189,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" - node_interop: - dependency: transitive - description: - name: node_interop - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - node_io: - dependency: transitive - description: - name: node_io - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" package_config: dependency: transitive description: @@ -216,7 +202,7 @@ packages: name: package_info_plus url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.3" package_info_plus_linux: dependency: transitive description: @@ -244,14 +230,14 @@ packages: name: package_info_plus_web url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" package_info_plus_windows: dependency: transitive description: name: package_info_plus_windows url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" path: dependency: transitive description: @@ -265,7 +251,7 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" path_provider_linux: dependency: transitive description: @@ -300,14 +286,14 @@ packages: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.11.0" + version: "1.11.1" petitparser: dependency: transitive description: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "4.1.0" + version: "4.2.0" platform: dependency: transitive description: @@ -382,7 +368,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.1" + version: "0.4.0" typed_data: dependency: transitive description: @@ -403,7 +389,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.2.4" xdg_directories: dependency: transitive description: diff --git a/windows/runner/run_loop.cpp b/windows/runner/run_loop.cpp index 2d6636ab..818b6ae2 100644 --- a/windows/runner/run_loop.cpp +++ b/windows/runner/run_loop.cpp @@ -9,7 +9,14 @@ RunLoop::RunLoop() {} RunLoop::~RunLoop() {} void RunLoop::Run() { - bool keep_running = true; + // Fix/workaround for Windows high CPU usage + // https://github.com/flutter/flutter/issues/78517#issuecomment-814843107 + MSG msg; + while (GetMessage(&msg, nullptr, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + /*bool keep_running = true; TimePoint next_flutter_event_time = TimePoint::clock::now(); while (keep_running) { std::chrono::nanoseconds wait_duration = @@ -40,7 +47,7 @@ void RunLoop::Run() { next_flutter_event_time = std::min(next_flutter_event_time, ProcessFlutterMessages()); } - } + }*/ } void RunLoop::RegisterFlutterInstance(