[thanos] Warmed up compute probe after initial dialogs load.

This commit is contained in:
23rd
2026-04-15 12:38:22 +03:00
parent ae10e37fcd
commit 5eec2baabc
6 changed files with 71 additions and 1 deletions
+2
View File
@@ -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
@@ -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),
@@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <rhi/qrhi.h>
#ifdef Q_OS_UNIX
#include <QOffscreenSurface>
#include <QSurfaceFormat>
#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<QOffscreenSurface>(
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<QWidget*> parent)
: _parent(parent) {
}
@@ -35,6 +35,12 @@ public:
void raise();
[[nodiscard]] static bool Supported();
// Runs the (potentially slow, 10300ms) 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();
@@ -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<Main::Session*> 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
@@ -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<Main::Session*> session,
rpl::lifetime &lifetime);
} // namespace Ui