From d653cb1b8bccde7df52f08f2b60d576f5ee99efa Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sat, 5 Feb 2022 12:38:06 +0300 Subject: [PATCH] Restrict max events per frame in UI event loop --- libs/app/source/ui_scene.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/app/source/ui_scene.cpp b/libs/app/source/ui_scene.cpp index 7366d8d1..1315299c 100644 --- a/libs/app/source/ui_scene.cpp +++ b/libs/app/source/ui_scene.cpp @@ -1,5 +1,7 @@ #include +#include + namespace psemek::app { @@ -88,8 +90,11 @@ namespace psemek::app void ui_scene::update() { + static constexpr std::size_t max_events_per_frame = 64; + controller_.update(update_clock_.restart().count()); - controller_.loop()->pump(); + if (controller_.loop()->pump(max_events_per_frame) == max_events_per_frame) + log::warning() << "UI event loop had more than " << max_events_per_frame << " events, delaying others"; } void ui_scene::present()