From 5eec2baabc2a469ff414ad9c51a9a0c50ad0803b Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 15 Apr 2026 12:38:22 +0300 Subject: [PATCH] [thanos] Warmed up compute probe after initial dialogs load. --- Telegram/CMakeLists.txt | 2 ++ .../dialogs/dialogs_inner_widget.cpp | 3 ++ .../SourceFiles/ui/effects/thanos_effect.cpp | 9 +++++- .../SourceFiles/ui/effects/thanos_effect.h | 6 ++++ .../ui/effects/thanos_effect_session.cpp | 32 +++++++++++++++++++ .../ui/effects/thanos_effect_session.h | 20 ++++++++++++ 6 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 Telegram/SourceFiles/ui/effects/thanos_effect_session.cpp create mode 100644 Telegram/SourceFiles/ui/effects/thanos_effect_session.h diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 827b7c8eec..bf52a8d690 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1833,6 +1833,8 @@ PRIVATE ui/effects/thanos_effect_controller.h ui/effects/thanos_effect_renderer.cpp ui/effects/thanos_effect_renderer.h + ui/effects/thanos_effect_session.cpp + ui/effects/thanos_effect_session.h ui/effects/send_action_animations.cpp ui/effects/send_action_animations.h ui/image/image.cpp diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 9b09929b39..049ee3a313 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -74,6 +74,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/chat/chats_filter_tag.h" #include "ui/effects/ripple_animation.h" #include "ui/effects/loading_element.h" +#include "ui/effects/thanos_effect_session.h" #include "ui/widgets/multi_select.h" #include "ui/widgets/menu/menu_add_action_callback_factory.h" #include "ui/unread_badge.h" @@ -375,6 +376,8 @@ InnerWidget::InnerWidget( refresh(); }, lifetime()); + Ui::ScheduleThanosEffectWarmUp(&session(), lifetime()); + rpl::merge( session().settings().archiveCollapsedChanges() | rpl::map_to(false), session().data().chatsFilters().changed() | rpl::map_to(true), diff --git a/Telegram/SourceFiles/ui/effects/thanos_effect.cpp b/Telegram/SourceFiles/ui/effects/thanos_effect.cpp index 0ca839c007..6a1c2bf2f4 100644 --- a/Telegram/SourceFiles/ui/effects/thanos_effect.cpp +++ b/Telegram/SourceFiles/ui/effects/thanos_effect.cpp @@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #ifdef Q_OS_UNIX #include +#include #endif #endif @@ -57,7 +58,7 @@ namespace { // here fails (no GL context, software fallback without compute, // driver bug), treat compute as unsupported and refuse the effect // rather than show an uninitialized swap-chain. - auto format = QRhiGles2InitParams::adjustedFormat(); + auto format = QSurfaceFormat::defaultFormat(); auto offscreen = std::unique_ptr( QRhiGles2InitParams::newFallbackSurface(format)); if (!offscreen) { @@ -101,6 +102,12 @@ bool ThanosEffect::Supported() { #endif } +void ThanosEffect::WarmUp() { +#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) + (void)RhiComputeSupportedCached(); +#endif +} + ThanosEffect::ThanosEffect(not_null parent) : _parent(parent) { } diff --git a/Telegram/SourceFiles/ui/effects/thanos_effect.h b/Telegram/SourceFiles/ui/effects/thanos_effect.h index 37685077f3..be9c887c95 100644 --- a/Telegram/SourceFiles/ui/effects/thanos_effect.h +++ b/Telegram/SourceFiles/ui/effects/thanos_effect.h @@ -35,6 +35,12 @@ public: void raise(); [[nodiscard]] static bool Supported(); + // Runs the (potentially slow, 10–300ms) QRhi capability probe + // synchronously on the main thread and caches the result. Safe to + // call multiple times. If not called, `Supported()` will lazily + // probe on first use — prefer warming it up during idle time so the + // first message deletion doesn't hitch. + static void WarmUp(); private: void ensureSurface(); diff --git a/Telegram/SourceFiles/ui/effects/thanos_effect_session.cpp b/Telegram/SourceFiles/ui/effects/thanos_effect_session.cpp new file mode 100644 index 0000000000..258a8b4131 --- /dev/null +++ b/Telegram/SourceFiles/ui/effects/thanos_effect_session.cpp @@ -0,0 +1,32 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#include "ui/effects/thanos_effect_session.h" + +#include "ui/effects/thanos_effect.h" +#include "data/data_folder.h" +#include "data/data_session.h" +#include "main/main_session.h" + +namespace Ui { + +void ScheduleThanosEffectWarmUp( + not_null session, + rpl::lifetime &lifetime) { + if (session->data().chatsListLoaded(nullptr)) { + ThanosEffect::WarmUp(); + return; + } + session->data().chatsListLoadedEvents( + ) | rpl::filter([](Data::Folder *folder) { + return !folder; + }) | rpl::take(1) | rpl::on_next([] { + ThanosEffect::WarmUp(); + }, lifetime); +} + +} // namespace Ui diff --git a/Telegram/SourceFiles/ui/effects/thanos_effect_session.h b/Telegram/SourceFiles/ui/effects/thanos_effect_session.h new file mode 100644 index 0000000000..0ca99043ea --- /dev/null +++ b/Telegram/SourceFiles/ui/effects/thanos_effect_session.h @@ -0,0 +1,20 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#pragma once + +namespace Main { +class Session; +} // namespace Main + +namespace Ui { + +void ScheduleThanosEffectWarmUp( + not_null session, + rpl::lifetime &lifetime); + +} // namespace Ui