From 22757c99ad264555a1dec30acb72126408c0c4ac Mon Sep 17 00:00:00 2001 From: Guillaume Meunier Date: Sun, 3 Aug 2025 10:39:24 +0200 Subject: [PATCH] Don't load too many textures in the same frame --- client/scenes/lobby_gui.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/scenes/lobby_gui.cpp b/client/scenes/lobby_gui.cpp index 50a0b2c1..37fbb783 100644 --- a/client/scenes/lobby_gui.cpp +++ b/client/scenes/lobby_gui.cpp @@ -36,6 +36,7 @@ #include "version.h" #include #include +#include #include #include #include @@ -422,6 +423,7 @@ void scenes::lobby::gui_connected() ImGui::Indent((usable_window_width - icon_line_width) / 2); + auto t0 = std::chrono::steady_clock::now(); for (const auto [index, app]: utils::enumerate(apps->applications)) { ImTextureID texture = [&]() -> ImTextureID { @@ -432,7 +434,10 @@ void scenes::lobby::gui_connected() auto it = app_icons.find(app.id); if (it == app_icons.end()) { - // TODO load textures in background + // Don't load too many textures at the same time to keep the GUI responsive + if (std::chrono::steady_clock::now() - t0 > 10ms) + return default_icon; + it = app_icons.emplace(app.id, imgui_ctx->load_texture(app.image)).first; } return it->second;