perf(ui): render frames on demand instead of continuously
While theme effects were on (the default) the main loop drew every frame it could. Where vsync is off (offscreen, some drivers, remote sessions) an idle wallet spun at ~3,000 fps, 88% of a core; with vsync it still drew every refresh. Frames are now paced by what needs them: - full rate while there is input, a held key, a window appearing or settling, a smooth scroll or the UI sweep; - ambient (30 fps focused, 10 fps unfocused) for theme effects, the acrylic backdrop, avatar animations and notifications; - progress (10 fps focused, 4 fps unfocused) for UI that changes without input. The updater and bootstrap downloads, console commands, lite-wallet operations, seed migration, the loading overlay and the lock-screen countdowns ask for it with material::RequestProgressFrame(); - otherwise idle, as before: wait for events, with a housekeeping wake every 2 s (5 s unfocused). A software frame cap (0.9x the display refresh) bounds the loop where vsync is off, and hidden, occluded or minimized windows get no ambient frames. Reduce Motion freezes the theme-effect clock (ThemeEffects::setMotionFrozen), so it needs no ambient frames either. The displayed-balance roll goes through one clamped StepDisplayLerp (balance_lerp.h). An idle-length frame pushed dt*speed past 1, so the roll overshot, and under Reduce Motion's speed of 999 it diverged to inf/NaN. The classic layout had its own copy of the old code. Idle CPU, Lite build, offscreen (no vsync): 88% -> 5% of a core with effects on, and 91% -> 3% with effects saved off (with the previous commit). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+11
@@ -844,6 +844,14 @@ void App::update()
|
||||
lite_wallet_->beginOpenExisting();
|
||||
}
|
||||
|
||||
// The controller's open/lifecycle/sync/send/console work runs on its own threads and the UI
|
||||
// shows progress for it: keep frames coming while any of it is in flight.
|
||||
if (lite_wallet_->openInProgress() || lite_wallet_->lifecycleRequestInProgress() ||
|
||||
lite_wallet_->scanInProgress() || lite_wallet_->broadcastInProgress() ||
|
||||
lite_wallet_->consoleCommandInProgress()) {
|
||||
ui::material::RequestProgressFrame();
|
||||
}
|
||||
|
||||
// Lite has no RPC daemon (tryConnect() is a no-op in lite builds), so derive the app's
|
||||
// "online" state — which gates the wallet UI via isConnected() — from the lite wallet.
|
||||
// A wallet is open only after a successful backend init against the lite server, so this
|
||||
@@ -4239,6 +4247,8 @@ void App::renderSeedMigrationDialog()
|
||||
const bool busy = seed_migration_in_flight_
|
||||
|| seed_migration_step_ == SeedMigrationStep::Sweeping
|
||||
|| seed_migration_step_ == SeedMigrationStep::Adopting;
|
||||
// The op runs off the UI thread; keep frames coming for its progress while it does.
|
||||
if (busy || seed_migration_step_ == SeedMigrationStep::Working) ui::material::RequestProgressFrame();
|
||||
|
||||
ui::material::OverlayDialogSpec migOv;
|
||||
migOv.title = TR("mig_title"); migOv.p_open = &show_seed_migration_;
|
||||
@@ -6773,6 +6783,7 @@ void App::renderLoadingOverlay(float contentH)
|
||||
// The wallet-recovery dialog owns the screen while a salvage is pending — suppress the loading
|
||||
// spinner underneath it so "still loading" and "make a decision" are never the same screen.
|
||||
if (show_wallet_recovered_dialog_) return;
|
||||
RequestProgressFrame(); // the spinner and status text keep moving while the node loads
|
||||
|
||||
auto loadElem = [](const char* key, float fb) {
|
||||
float v = ui::schema::UI().drawElement("screens.loading", key).size;
|
||||
|
||||
Reference in New Issue
Block a user