Merge feature/renderer-autodetect-hardening into pre-release
cc # Conflicts: # crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po # crates/qbz-ui/translations/en/LC_MESSAGES/qbz-ui.po # crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po # crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po # crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po # crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po # crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po # crates/qbz/src/main.rs
This commit is contained in:
11 files changed
+416
-45
No files matched your search
@@ -4461,3 +4461,6 @@ msgstr "Protokolle teilen"
|
|||||||
# Guest local-only mode disclaimer line (login screen, #553)
|
# Guest local-only mode disclaimer line (login screen, #553)
|
||||||
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
||||||
msgstr "QBZ kann ohne Qobuz™-Konto als Offline-Player genutzt werden (kein Zugriff auf die Qobuz™-Bibliothek)."
|
msgstr "QBZ kann ohne Qobuz™-Konto als Offline-Player genutzt werden (kein Zugriff auf die Qobuz™-Bibliothek)."
|
||||||
|
# Renderer degradation ladder toast (generic: GL or software rung)
|
||||||
|
msgid "Renderer switched automatically — the previous renderer failed to start"
|
||||||
|
msgstr "Renderer automatisch gewechselt — der vorherige konnte nicht starten"
|
||||||
@@ -230,3 +230,6 @@ msgstr "Share logs"
|
|||||||
# Guest local-only mode disclaimer line (login screen, #553)
|
# Guest local-only mode disclaimer line (login screen, #553)
|
||||||
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
||||||
msgstr "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
msgstr "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
||||||
|
# Renderer degradation ladder toast (generic: GL or software rung)
|
||||||
|
msgid "Renderer switched automatically — the previous renderer failed to start"
|
||||||
|
msgstr "Renderer switched automatically — the previous renderer failed to start"
|
||||||
@@ -4491,3 +4491,6 @@ msgstr "Compartir registros"
|
|||||||
# Guest local-only mode disclaimer line (login screen, #553)
|
# Guest local-only mode disclaimer line (login screen, #553)
|
||||||
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
||||||
msgstr "QBZ puede usarse como reproductor sin conexión sin una cuenta de Qobuz™ (sin acceso a la biblioteca de Qobuz™)."
|
msgstr "QBZ puede usarse como reproductor sin conexión sin una cuenta de Qobuz™ (sin acceso a la biblioteca de Qobuz™)."
|
||||||
|
# Renderer degradation ladder toast (generic: GL or software rung)
|
||||||
|
msgid "Renderer switched automatically — the previous renderer failed to start"
|
||||||
|
msgstr "El renderizador cambió automáticamente — el anterior no pudo iniciar"
|
||||||
@@ -4461,3 +4461,6 @@ msgstr "Partager les journaux"
|
|||||||
# Guest local-only mode disclaimer line (login screen, #553)
|
# Guest local-only mode disclaimer line (login screen, #553)
|
||||||
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
||||||
msgstr "QBZ peut être utilisé comme lecteur hors ligne sans compte Qobuz™ (pas d'accès à la bibliothèque Qobuz™)."
|
msgstr "QBZ peut être utilisé comme lecteur hors ligne sans compte Qobuz™ (pas d'accès à la bibliothèque Qobuz™)."
|
||||||
|
# Renderer degradation ladder toast (generic: GL or software rung)
|
||||||
|
msgid "Renderer switched automatically — the previous renderer failed to start"
|
||||||
|
msgstr "Moteur de rendu changé automatiquement — le précédent n'a pas pu démarrer"
|
||||||
@@ -4450,3 +4450,6 @@ msgstr "ログを共有"
|
|||||||
# Guest local-only mode disclaimer line (login screen, #553)
|
# Guest local-only mode disclaimer line (login screen, #553)
|
||||||
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
||||||
msgstr "QBZはQobuz™アカウントなしでオフラインプレーヤーとして使用できます(Qobuz™ライブラリにはアクセスできません)。"
|
msgstr "QBZはQobuz™アカウントなしでオフラインプレーヤーとして使用できます(Qobuz™ライブラリにはアクセスできません)。"
|
||||||
|
# Renderer degradation ladder toast (generic: GL or software rung)
|
||||||
|
msgid "Renderer switched automatically — the previous renderer failed to start"
|
||||||
|
msgstr "レンダラーを自動的に切り替えました — 前のレンダラーは起動できませんでした"
|
||||||
@@ -4461,3 +4461,6 @@ msgstr "Compartilhar registros"
|
|||||||
# Guest local-only mode disclaimer line (login screen, #553)
|
# Guest local-only mode disclaimer line (login screen, #553)
|
||||||
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
||||||
msgstr "O QBZ pode ser usado como reprodutor offline sem conta Qobuz™ (sem acesso à biblioteca Qobuz™)."
|
msgstr "O QBZ pode ser usado como reprodutor offline sem conta Qobuz™ (sem acesso à biblioteca Qobuz™)."
|
||||||
|
# Renderer degradation ladder toast (generic: GL or software rung)
|
||||||
|
msgid "Renderer switched automatically — the previous renderer failed to start"
|
||||||
|
msgstr "Renderizador alterado automaticamente — o anterior não pôde iniciar"
|
||||||
@@ -4474,3 +4474,6 @@ msgstr "Поделиться журналами"
|
|||||||
# Guest local-only mode disclaimer line (login screen, #553)
|
# Guest local-only mode disclaimer line (login screen, #553)
|
||||||
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
msgid "QBZ can be used as an offline player without a Qobuz™ account (no access to the Qobuz™ library)."
|
||||||
msgstr "QBZ можно использовать как офлайн-плеер без учётной записи Qobuz™ (без доступа к библиотеке Qobuz™)."
|
msgstr "QBZ можно использовать как офлайн-плеер без учётной записи Qobuz™ (без доступа к библиотеке Qobuz™)."
|
||||||
|
# Renderer degradation ladder toast (generic: GL or software rung)
|
||||||
|
msgid "Renderer switched automatically — the previous renderer failed to start"
|
||||||
|
msgstr "Рендерер переключён автоматически — предыдущий не смог запуститься"
|
||||||
@@ -499,6 +499,20 @@ pub async fn build_full_report(runtime: &Runtime) -> String {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
md_line(&mut out, "GPU Adapters", &renderer_adapters);
|
md_line(&mut out, "GPU Adapters", &renderer_adapters);
|
||||||
|
md_line(
|
||||||
|
&mut out,
|
||||||
|
"UI Loop Latency",
|
||||||
|
&format!(
|
||||||
|
"{} ms (worst {} ms{})",
|
||||||
|
crate::ui_watchdog::last_latency_ms(),
|
||||||
|
crate::ui_watchdog::worst_latency_ms(),
|
||||||
|
if crate::ui_watchdog::flagged() {
|
||||||
|
", sustained degradation flagged"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
md_line(&mut out, "GDK Scale", &opt(&d.gfx_gdk_scale));
|
md_line(&mut out, "GDK Scale", &opt(&d.gfx_gdk_scale));
|
||||||
md_line(&mut out, "GDK DPI Scale", &opt(&d.gfx_gdk_dpi_scale));
|
md_line(&mut out, "GDK DPI Scale", &opt(&d.gfx_gdk_dpi_scale));
|
||||||
@@ -867,9 +881,25 @@ fn build_graphics_rows(d: &qbz_app::diagnostics::RuntimeDiagnostics) -> Vec<Diag
|
|||||||
2
|
2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Event-loop responsiveness probe (#555): dispatch latency of a
|
||||||
|
// cross-thread closure — renderer-independent, so a bad number here with
|
||||||
|
// a healthy GPU points ABOVE the renderer. status 2 = sustained
|
||||||
|
// degradation was flagged this session.
|
||||||
|
let ui_latency = {
|
||||||
|
let last = crate::ui_watchdog::last_latency_ms();
|
||||||
|
let worst = crate::ui_watchdog::worst_latency_ms();
|
||||||
|
if last == 0 && worst == 0 {
|
||||||
|
"not sampled yet".to_string()
|
||||||
|
} else {
|
||||||
|
format!("{last} ms (worst {worst} ms)")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let ui_latency_status = if crate::ui_watchdog::flagged() { 2 } else { 0 };
|
||||||
|
|
||||||
vec![
|
vec![
|
||||||
row("Renderer (Slint)", &renderer_saved, &renderer_runtime, 0),
|
row("Renderer (Slint)", &renderer_saved, &renderer_runtime, 0),
|
||||||
row("GPU Adapters", "—", &renderer_adapters, 0),
|
row("GPU Adapters", "—", &renderer_adapters, 0),
|
||||||
|
row("UI Loop Latency", "—", &ui_latency, ui_latency_status),
|
||||||
row(
|
row(
|
||||||
"Hardware Acceleration",
|
"Hardware Acceleration",
|
||||||
hw_saved,
|
hw_saved,
|
||||||
|
|||||||
+249
-45
@@ -132,6 +132,7 @@ mod tray;
|
|||||||
mod tray_settings;
|
mod tray_settings;
|
||||||
mod ui_prefs;
|
mod ui_prefs;
|
||||||
mod viewport;
|
mod viewport;
|
||||||
|
mod ui_watchdog;
|
||||||
mod whats_new;
|
mod whats_new;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -1004,11 +1005,21 @@ fn install_browser_mouse_nav(window: &AppWindow) {
|
|||||||
}
|
}
|
||||||
return EventResult::Propagate;
|
return EventResult::Propagate;
|
||||||
}
|
}
|
||||||
|
// A deliberate close is also liveness (a crash never emits one) —
|
||||||
|
// without this, a launch-then-close-from-the-taskbar inside the
|
||||||
|
// fallback window would falsely degrade the renderer next start.
|
||||||
|
WindowEvent::CloseRequested => {
|
||||||
|
disarm_renderer_sentinel_on_liveness("close request");
|
||||||
|
return EventResult::Propagate;
|
||||||
|
}
|
||||||
WindowEvent::MouseInput {
|
WindowEvent::MouseInput {
|
||||||
state: ElementState::Pressed,
|
state: ElementState::Pressed,
|
||||||
button,
|
button,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
|
// A real click = the app reached a usable state; the startup
|
||||||
|
// renderer sentinel can stand down (see its doc).
|
||||||
|
disarm_renderer_sentinel_on_liveness("mouse input");
|
||||||
let Some(window) = weak.upgrade() else {
|
let Some(window) = weak.upgrade() else {
|
||||||
return EventResult::Propagate;
|
return EventResult::Propagate;
|
||||||
};
|
};
|
||||||
@@ -1047,6 +1058,8 @@ fn install_browser_mouse_nav(window: &AppWindow) {
|
|||||||
WindowEvent::KeyboardInput { event: key_event, .. }
|
WindowEvent::KeyboardInput { event: key_event, .. }
|
||||||
if key_event.state == ElementState::Pressed =>
|
if key_event.state == ElementState::Pressed =>
|
||||||
{
|
{
|
||||||
|
// Key press = usable app; stand the startup sentinel down.
|
||||||
|
disarm_renderer_sentinel_on_liveness("key input");
|
||||||
let Some(window) = weak.upgrade() else {
|
let Some(window) = weak.upgrade() else {
|
||||||
return EventResult::Propagate;
|
return EventResult::Propagate;
|
||||||
};
|
};
|
||||||
@@ -5548,8 +5561,62 @@ fn renderer_sentinel_armed() -> bool {
|
|||||||
renderer_sentinel_path().map(|p| p.exists()).unwrap_or(false)
|
renderer_sentinel_path().map(|p| p.exists()).unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Disarm the sentinel on proof of LIVENESS: the first real user input (or
|
||||||
|
/// a close request — a crash never emits one), with a 30s timer as the
|
||||||
|
/// no-touch fallback. Once-guarded so the hot input path costs one relaxed
|
||||||
|
/// swap after the first call.
|
||||||
|
fn disarm_renderer_sentinel_on_liveness(signal: &str) {
|
||||||
|
static DISARMED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
|
||||||
|
if !DISARMED.swap(true, std::sync::atomic::Ordering::Relaxed) {
|
||||||
|
log::info!("[renderer] startup sentinel disarmed ({signal})");
|
||||||
|
clear_renderer_sentinel();
|
||||||
|
// The surviving rung must OUTLIVE the process: when this session ran
|
||||||
|
// on the ALTERNATE wgpu adapter, version-stamp that success so the
|
||||||
|
// next start arms the alt rung directly — otherwise the rung-2 win
|
||||||
|
// dies with the process and the machine crash-cycles every other
|
||||||
|
// launch (rung 1 default adapter, crash, rung 2, work, repeat).
|
||||||
|
if WGPU_ALT_ADAPTER.load(std::sync::atomic::Ordering::Relaxed) {
|
||||||
|
let mut prefs = crate::ui_prefs::load();
|
||||||
|
if prefs.renderer_wgpu_alt != env!("CARGO_PKG_VERSION") {
|
||||||
|
prefs.renderer_wgpu_alt = env!("CARGO_PKG_VERSION").to_string();
|
||||||
|
crate::ui_prefs::save(&prefs);
|
||||||
|
log::info!(
|
||||||
|
"[renderer] alternate wgpu adapter survived — persisted for this build"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Arm the sentinel for a freshly auto-detected tier. Wgpu goes straight to
|
||||||
|
/// the ALT-adapter rung when this build already proved the default adapter
|
||||||
|
/// dead (`renderer_wgpu_alt` stamped at disarm time on an alt-rung run).
|
||||||
|
/// Software is the unarmored floor. macOS stays out of the ladder.
|
||||||
|
fn arm_auto_tier(tier: RendererTier, prefs: &crate::ui_prefs::UiPrefs) {
|
||||||
|
if cfg!(target_os = "macos") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
match tier {
|
||||||
|
RendererTier::Wgpu => {
|
||||||
|
if prefs.renderer_wgpu_alt == env!("CARGO_PKG_VERSION") {
|
||||||
|
log::info!(
|
||||||
|
"[renderer] default wgpu adapter is known-bad on this build -> \
|
||||||
|
alternate adapter directly"
|
||||||
|
);
|
||||||
|
WGPU_ALT_ADAPTER.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||||
|
arm_renderer_sentinel("auto-wgpu-alt");
|
||||||
|
} else {
|
||||||
|
arm_renderer_sentinel("auto-wgpu");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RendererTier::FemtovgGl => arm_renderer_sentinel("auto-gl"),
|
||||||
|
RendererTier::Software => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// What the armed sentinel was protecting ("wgpu"/"gl"/"software" for a
|
/// What the armed sentinel was protecting ("wgpu"/"gl"/"software" for a
|
||||||
/// Settings override, "auto-wgpu" for the auto-detected wgpu tier).
|
/// Settings override, "auto-wgpu"/"auto-wgpu-alt"/"auto-gl" for the auto
|
||||||
|
/// ladder rungs).
|
||||||
fn renderer_sentinel_value() -> Option<String> {
|
fn renderer_sentinel_value() -> Option<String> {
|
||||||
std::fs::read_to_string(renderer_sentinel_path()?).ok()
|
std::fs::read_to_string(renderer_sentinel_path()?).ok()
|
||||||
}
|
}
|
||||||
@@ -5564,6 +5631,12 @@ struct GpuTopology {
|
|||||||
}
|
}
|
||||||
static GPU_TOPOLOGY: std::sync::OnceLock<GpuTopology> = std::sync::OnceLock::new();
|
static GPU_TOPOLOGY: std::sync::OnceLock<GpuTopology> = std::sync::OnceLock::new();
|
||||||
|
|
||||||
|
/// Ladder rung 2 (see `renderer_tier_from_prefs`): retry wgpu with the
|
||||||
|
/// OPPOSITE PowerPreference after the default adapter failed a start —
|
||||||
|
/// the #542 family is an adapter mixup, not a wgpu failure.
|
||||||
|
static WGPU_ALT_ADAPTER: std::sync::atomic::AtomicBool =
|
||||||
|
std::sync::atomic::AtomicBool::new(false);
|
||||||
|
|
||||||
/// Minimal adapter probe for the paths that skip `detect_hardware_gpu`
|
/// Minimal adapter probe for the paths that skip `detect_hardware_gpu`
|
||||||
/// (QBZ_RENDERER / Settings forcing the wgpu tier).
|
/// (QBZ_RENDERER / Settings forcing the wgpu tier).
|
||||||
fn probe_gpu_topology() -> GpuTopology {
|
fn probe_gpu_topology() -> GpuTopology {
|
||||||
@@ -5719,6 +5792,20 @@ fn select_slint_backend() -> Result<bool, slint::PlatformError> {
|
|||||||
let mut wgpu_settings = slint::wgpu_28::WGPUSettings::default();
|
let mut wgpu_settings = slint::wgpu_28::WGPUSettings::default();
|
||||||
wgpu_settings.power_preference = slint::wgpu_28::wgpu::PowerPreference::from_env()
|
wgpu_settings.power_preference = slint::wgpu_28::wgpu::PowerPreference::from_env()
|
||||||
.unwrap_or_else(default_wgpu_power_preference);
|
.unwrap_or_else(default_wgpu_power_preference);
|
||||||
|
// Alternate-adapter rung: the previous start died on the adapter
|
||||||
|
// this preference picks, so flip it (even over WGPU_POWER_PREF —
|
||||||
|
// anyone setting that env is debugging and reads the log line).
|
||||||
|
if WGPU_ALT_ADAPTER.load(std::sync::atomic::Ordering::Relaxed) {
|
||||||
|
use slint::wgpu_28::wgpu::PowerPreference;
|
||||||
|
wgpu_settings.power_preference = match wgpu_settings.power_preference {
|
||||||
|
PowerPreference::HighPerformance => PowerPreference::LowPower,
|
||||||
|
_ => PowerPreference::HighPerformance,
|
||||||
|
};
|
||||||
|
log::warn!(
|
||||||
|
"[renderer] alternate-adapter rung: flipped power preference to {:?}",
|
||||||
|
wgpu_settings.power_preference
|
||||||
|
);
|
||||||
|
}
|
||||||
log::info!(
|
log::info!(
|
||||||
"[renderer] selecting wgpu (GPU) renderer (power_preference={:?})",
|
"[renderer] selecting wgpu (GPU) renderer (power_preference={:?})",
|
||||||
wgpu_settings.power_preference
|
wgpu_settings.power_preference
|
||||||
@@ -5793,56 +5880,144 @@ fn requested_renderer_tier() -> (RendererTier, String) {
|
|||||||
|
|
||||||
/// Resolve the persisted Settings>Appearance renderer key ("auto" | "wgpu" |
|
/// Resolve the persisted Settings>Appearance renderer key ("auto" | "wgpu" |
|
||||||
/// "gl" | "software"). A non-auto override is wrapped in the startup sentinel:
|
/// "gl" | "software"). A non-auto override is wrapped in the startup sentinel:
|
||||||
/// armed here (before the risky backend/window init), disarmed shortly after
|
/// armed here (before the risky backend/window init), disarmed on the first
|
||||||
/// the main window is up. If we find it still armed from the PREVIOUS run,
|
/// real user input (or a fallback timer). If we find it still armed from the
|
||||||
/// that run never reached first paint with this override — revert to "auto"
|
/// PREVIOUS run, that run never reached a usable state with this override —
|
||||||
/// and auto-detect, so users can't lock themselves out with a bad choice.
|
/// revert to "auto" and auto-detect, so users can't lock themselves out.
|
||||||
|
///
|
||||||
|
/// AUTO runs a degradation LADDER instead of a single fallback: each failed
|
||||||
|
/// start moves one rung down, and the first rung that survives wins.
|
||||||
|
///
|
||||||
|
/// wgpu (default adapter) -> wgpu (opposite PowerPreference) -> GL -> software
|
||||||
|
///
|
||||||
|
/// The alternate-adapter rung exists because the #542 family is an ADAPTER
|
||||||
|
/// mixup, not a wgpu failure: on hybrid machines (mux laptops, desktops with
|
||||||
|
/// the monitor on the discrete card) the heuristically-preferred adapter may
|
||||||
|
/// be unable to present while the other one works perfectly — surrendering
|
||||||
|
/// the whole GPU tier over that would be wrong. macOS stays out of the
|
||||||
|
/// ladder by design (no GL tier there; it degrades back to wgpu).
|
||||||
fn renderer_tier_from_prefs() -> (RendererTier, String) {
|
fn renderer_tier_from_prefs() -> (RendererTier, String) {
|
||||||
let mut prefs = crate::ui_prefs::load();
|
let mut prefs = crate::ui_prefs::load();
|
||||||
let key = prefs.renderer.clone();
|
let mut key = prefs.renderer.clone();
|
||||||
|
// A persisted AUTO-degradation is version-keyed: a new build re-probes
|
||||||
|
// "auto" once (vendored renderer fixes / driver updates are likely since
|
||||||
|
// the rung was recorded); the ladder re-degrades within one start if the
|
||||||
|
// stack is still broken. User-chosen overrides carry no version marker
|
||||||
|
// and are never re-probed.
|
||||||
|
if key != "auto"
|
||||||
|
&& !prefs.renderer_auto_degraded.is_empty()
|
||||||
|
&& prefs.renderer_auto_degraded != env!("CARGO_PKG_VERSION")
|
||||||
|
{
|
||||||
|
log::info!(
|
||||||
|
"[renderer] '{key}' was auto-degraded by version {} — re-probing auto once on {}",
|
||||||
|
prefs.renderer_auto_degraded,
|
||||||
|
env!("CARGO_PKG_VERSION")
|
||||||
|
);
|
||||||
|
prefs.renderer = "auto".to_string();
|
||||||
|
prefs.renderer_auto_degraded.clear();
|
||||||
|
crate::ui_prefs::save(&prefs);
|
||||||
|
key = "auto".to_string();
|
||||||
|
}
|
||||||
if key == "auto" {
|
if key == "auto" {
|
||||||
// The sentinel also guards the AUTO-DETECTED wgpu tier (#542): if the
|
|
||||||
// previous auto start picked wgpu and died before first paint,
|
|
||||||
// re-detecting would pick wgpu again — an unrecoverable crash loop.
|
|
||||||
// Degrade the persisted setting to "gl" (the user can switch back in
|
|
||||||
// Settings) and explain with a toast. macOS has no GL tier (it
|
|
||||||
// degrades back to wgpu), so the guard is Linux-shaped by design.
|
|
||||||
if renderer_sentinel_armed() {
|
if renderer_sentinel_armed() {
|
||||||
let attempted = renderer_sentinel_value();
|
let attempted = renderer_sentinel_value();
|
||||||
clear_renderer_sentinel();
|
clear_renderer_sentinel();
|
||||||
if attempted.as_deref() == Some("auto-wgpu") && !cfg!(target_os = "macos") {
|
if !cfg!(target_os = "macos") {
|
||||||
log::warn!(
|
match attempted.as_deref() {
|
||||||
"[renderer] previous start with the auto-detected wgpu renderer never \
|
// Rung 2: the default-preference adapter died before the
|
||||||
reached first paint -> persisting the GL (compatibility) renderer"
|
// app became usable. Retry wgpu on the OPPOSITE
|
||||||
);
|
// PowerPreference before surrendering the GPU tier.
|
||||||
prefs.renderer = "gl".to_string();
|
Some("auto-wgpu") => {
|
||||||
crate::ui_prefs::save(&prefs);
|
log::warn!(
|
||||||
RENDERER_DEGRADED.store(true, std::sync::atomic::Ordering::Relaxed);
|
"[renderer] auto wgpu (default adapter) never reached a usable \
|
||||||
return (
|
state -> retrying wgpu on the alternate adapter"
|
||||||
RendererTier::FemtovgGl,
|
);
|
||||||
"Settings (gl — auto-detected wgpu failed to start)".to_string(),
|
WGPU_ALT_ADAPTER.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||||
);
|
arm_renderer_sentinel("auto-wgpu-alt");
|
||||||
|
return (
|
||||||
|
RendererTier::Wgpu,
|
||||||
|
"auto-detect (alternate wgpu adapter after a failed start)"
|
||||||
|
.to_string(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Rung 3: both wgpu adapters failed -> persist GL
|
||||||
|
// (compatibility), version-stamped for the re-probe.
|
||||||
|
Some("auto-wgpu-alt") => {
|
||||||
|
log::warn!(
|
||||||
|
"[renderer] both wgpu adapters failed to start -> persisting \
|
||||||
|
the GL (compatibility) renderer"
|
||||||
|
);
|
||||||
|
prefs.renderer = "gl".to_string();
|
||||||
|
prefs.renderer_auto_degraded = env!("CARGO_PKG_VERSION").to_string();
|
||||||
|
crate::ui_prefs::save(&prefs);
|
||||||
|
RENDERER_DEGRADED.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||||
|
arm_renderer_sentinel("auto-gl");
|
||||||
|
return (
|
||||||
|
RendererTier::FemtovgGl,
|
||||||
|
"Settings (gl — both wgpu adapters failed to start)".to_string(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Rung 4: even GL died (broken EGL stacks exist) ->
|
||||||
|
// software, the floor that cannot fail.
|
||||||
|
Some("auto-gl") => {
|
||||||
|
log::warn!(
|
||||||
|
"[renderer] the GL renderer also failed to start -> persisting \
|
||||||
|
the software renderer"
|
||||||
|
);
|
||||||
|
prefs.renderer = "software".to_string();
|
||||||
|
prefs.renderer_auto_degraded = env!("CARGO_PKG_VERSION").to_string();
|
||||||
|
crate::ui_prefs::save(&prefs);
|
||||||
|
RENDERER_DEGRADED.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||||
|
return (
|
||||||
|
RendererTier::Software,
|
||||||
|
"Settings (software — wgpu and GL failed to start)".to_string(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let tier = detect_hardware_gpu();
|
let tier = detect_hardware_gpu();
|
||||||
if tier == RendererTier::Wgpu && !cfg!(target_os = "macos") {
|
// Every fallible auto rung is sentinel-armed (GL stacks can be as
|
||||||
arm_renderer_sentinel("auto-wgpu");
|
// broken as wgpu ones); a known-bad default adapter goes straight
|
||||||
}
|
// to the alt rung.
|
||||||
|
arm_auto_tier(tier, &prefs);
|
||||||
return (tier, "auto-detect".to_string());
|
return (tier, "auto-detect".to_string());
|
||||||
}
|
}
|
||||||
if renderer_sentinel_armed() {
|
if renderer_sentinel_armed() {
|
||||||
|
let attempted = renderer_sentinel_value();
|
||||||
|
clear_renderer_sentinel();
|
||||||
|
// Ladder continuation (rung 4 via the persisted-"gl" route): rung 3
|
||||||
|
// wrote prefs.renderer="gl" and armed "auto-gl", so its failure
|
||||||
|
// surfaces HERE, not in the auto branch. A USER-picked gl arms the
|
||||||
|
// literal "gl", never "auto-gl" — no ambiguity.
|
||||||
|
if attempted.as_deref() == Some("auto-gl") && !cfg!(target_os = "macos") {
|
||||||
|
log::warn!(
|
||||||
|
"[renderer] the ladder-persisted GL renderer also failed to start -> \
|
||||||
|
persisting the software renderer"
|
||||||
|
);
|
||||||
|
prefs.renderer = "software".to_string();
|
||||||
|
prefs.renderer_auto_degraded = env!("CARGO_PKG_VERSION").to_string();
|
||||||
|
crate::ui_prefs::save(&prefs);
|
||||||
|
RENDERER_DEGRADED.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||||
|
return (
|
||||||
|
RendererTier::Software,
|
||||||
|
"Settings (software — wgpu and GL failed to start)".to_string(),
|
||||||
|
);
|
||||||
|
}
|
||||||
log::warn!(
|
log::warn!(
|
||||||
"[renderer] previous start with renderer='{key}' never reached first paint \
|
"[renderer] previous start with renderer='{key}' never reached a usable state \
|
||||||
-> reverting the setting to auto"
|
-> reverting the setting to auto"
|
||||||
);
|
);
|
||||||
clear_renderer_sentinel();
|
|
||||||
prefs.renderer = "auto".to_string();
|
prefs.renderer = "auto".to_string();
|
||||||
|
prefs.renderer_auto_degraded.clear();
|
||||||
crate::ui_prefs::save(&prefs);
|
crate::ui_prefs::save(&prefs);
|
||||||
RENDERER_REVERTED.store(true, std::sync::atomic::Ordering::Relaxed);
|
RENDERER_REVERTED.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||||
return (
|
let tier = detect_hardware_gpu();
|
||||||
detect_hardware_gpu(),
|
// Arm the re-detected tier too — if IT also fails, the next start
|
||||||
format!("auto-detect (reverted: '{key}' failed to start)"),
|
// continues down the ladder instead of looping.
|
||||||
);
|
arm_auto_tier(tier, &prefs);
|
||||||
|
return (tier, format!("auto-detect (reverted: '{key}' failed to start)"));
|
||||||
}
|
}
|
||||||
let tier = match key.as_str() {
|
let tier = match key.as_str() {
|
||||||
"wgpu" => RendererTier::Wgpu,
|
"wgpu" => RendererTier::Wgpu,
|
||||||
@@ -5853,8 +6028,14 @@ fn renderer_tier_from_prefs() -> (RendererTier, String) {
|
|||||||
return (detect_hardware_gpu(), "auto-detect".to_string());
|
return (detect_hardware_gpu(), "auto-detect".to_string());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
log::info!("[renderer] Settings renderer override '{key}' (sentinel armed)");
|
// Software cannot fail to start — arming it would only invite false
|
||||||
arm_renderer_sentinel(&key);
|
// reverts from no-input quick sessions.
|
||||||
|
if tier != RendererTier::Software {
|
||||||
|
log::info!("[renderer] Settings renderer override '{key}' (sentinel armed)");
|
||||||
|
arm_renderer_sentinel(&key);
|
||||||
|
} else {
|
||||||
|
log::info!("[renderer] Settings renderer override 'software'");
|
||||||
|
}
|
||||||
(tier, format!("Settings ({key})"))
|
(tier, format!("Settings ({key})"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6105,22 +6286,34 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let window = AppWindow::new()?;
|
let window = AppWindow::new()?;
|
||||||
// Renderer auto-revert sentinel: disarm it once the window has been alive
|
// Renderer auto-revert sentinel: disarmed on the FIRST real user input
|
||||||
// for a few seconds (renderer/driver init crashes happen at or shortly
|
// (or window close request) via the winit event filter — proof the app
|
||||||
// after realization; surviving this long counts as a working renderer).
|
// reached a usable state — with a 30s fallback for no-touch sessions.
|
||||||
// Single-shot timer — the binding must outlive this scope's run loop.
|
// The old fixed 5s disarm lost the race against late startup crashes
|
||||||
// Piggybacked: persist the REAL compositor DPR as `last_dpr` (the surface
|
// (#558: the swapchain error lands seconds after first paint, the timer
|
||||||
// is mapped by now, so winit reports the true value — unlike right after
|
// had already disarmed, and the crash looped forever).
|
||||||
|
let _renderer_sentinel_timer = slint::Timer::default();
|
||||||
|
_renderer_sentinel_timer.start(
|
||||||
|
slint::TimerMode::SingleShot,
|
||||||
|
std::time::Duration::from_secs(30),
|
||||||
|
|| {
|
||||||
|
disarm_renderer_sentinel_on_liveness("30s fallback");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
// Event-loop responsiveness watchdog (#555): background probe thread,
|
||||||
|
// read by the Diagnostics panel. Detection only — never switches tiers.
|
||||||
|
ui_watchdog::spawn();
|
||||||
|
// Persist the REAL compositor DPR as `last_dpr` once the surface is
|
||||||
|
// mapped (winit reports the true value there — unlike right after
|
||||||
// creation on Wayland). Read from the WINIT window, not the Slint one:
|
// creation on Wayland). Read from the WINIT window, not the Slint one:
|
||||||
// SLINT_SCALE_FACTOR overrides Slint's factor but winit still sees the
|
// SLINT_SCALE_FACTOR overrides Slint's factor but winit still sees the
|
||||||
// compositor's. The next scaled launch bakes this into the env value.
|
// compositor's. The next scaled launch bakes this into the env value.
|
||||||
let _renderer_sentinel_timer = slint::Timer::default();
|
let _dpr_probe_timer = slint::Timer::default();
|
||||||
let sentinel_weak = window.as_weak();
|
let sentinel_weak = window.as_weak();
|
||||||
_renderer_sentinel_timer.start(
|
_dpr_probe_timer.start(
|
||||||
slint::TimerMode::SingleShot,
|
slint::TimerMode::SingleShot,
|
||||||
std::time::Duration::from_secs(5),
|
std::time::Duration::from_secs(5),
|
||||||
move || {
|
move || {
|
||||||
clear_renderer_sentinel();
|
|
||||||
if let Some(w) = sentinel_weak.upgrade() {
|
if let Some(w) = sentinel_weak.upgrade() {
|
||||||
w.window().with_winit_window(|win| {
|
w.window().with_winit_window(|win| {
|
||||||
let real_dpr = win.scale_factor() as f32;
|
let real_dpr = win.scale_factor() as f32;
|
||||||
@@ -6180,10 +6373,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// Same idea for the auto-detect path (#542): wgpu crashed pre-paint last
|
// Same idea for the auto-detect path (#542): wgpu crashed pre-paint last
|
||||||
// time, this start persisted the GL fallback instead.
|
// time, this start persisted the GL fallback instead.
|
||||||
if RENDERER_DEGRADED.load(std::sync::atomic::Ordering::Relaxed) {
|
if RENDERER_DEGRADED.load(std::sync::atomic::Ordering::Relaxed) {
|
||||||
|
// Generic on purpose: the ladder can land on GL or software.
|
||||||
crate::toast::warning(
|
crate::toast::warning(
|
||||||
&window,
|
&window,
|
||||||
qbz_i18n::t(
|
qbz_i18n::t(
|
||||||
"Renderer switched to GPU (compatibility) — the GPU renderer failed to start",
|
"Renderer switched automatically — the previous renderer failed to start",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -8766,6 +8960,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// sentinel there).
|
// sentinel there).
|
||||||
let mut prefs = crate::ui_prefs::load();
|
let mut prefs = crate::ui_prefs::load();
|
||||||
prefs.renderer = crate::ui_prefs::renderer_for_index(index).to_string();
|
prefs.renderer = crate::ui_prefs::renderer_for_index(index).to_string();
|
||||||
|
// A manual pick is the USER's choice — drop the auto-degrade
|
||||||
|
// and alt-adapter markers so the ladder starts clean if they
|
||||||
|
// ever return to "auto".
|
||||||
|
prefs.renderer_auto_degraded.clear();
|
||||||
|
prefs.renderer_wgpu_alt.clear();
|
||||||
crate::ui_prefs::save(&prefs);
|
crate::ui_prefs::save(&prefs);
|
||||||
crate::toast::info_weak(
|
crate::toast::info_weak(
|
||||||
&theme_weak,
|
&theme_weak,
|
||||||
@@ -19381,6 +19580,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// tray Quit), so hide-to-tray works.
|
// tray Quit), so hide-to-tray works.
|
||||||
window.show()?;
|
window.show()?;
|
||||||
slint::run_event_loop_until_quit()?;
|
slint::run_event_loop_until_quit()?;
|
||||||
|
// Reaching here = a CLEAN exit (tray Quit calls quit_event_loop directly,
|
||||||
|
// with no window input event) — without this, launch-then-quit-from-tray
|
||||||
|
// inside the 30s fallback would leave the sentinel armed and falsely
|
||||||
|
// walk the renderer ladder on the next start.
|
||||||
|
disarm_renderer_sentinel_on_liveness("clean exit");
|
||||||
// Single choke point for ALL quit paths (custom-titlebar close, WM close,
|
// Single choke point for ALL quit paths (custom-titlebar close, WM close,
|
||||||
// tray Quit): release anything QBZ parked on the audio graph before the
|
// tray Quit): release anything QBZ parked on the audio graph before the
|
||||||
// process exits. Quitting mid-playback never runs the audio thread's Stop
|
// process exits. Quitting mid-playback never runs the audio thread's Stop
|
||||||
|
|||||||
@@ -520,6 +520,22 @@ pub struct UiPrefs {
|
|||||||
/// window comes up, the next start reverts this to "auto".
|
/// window comes up, the next start reverts this to "auto".
|
||||||
#[serde(default = "default_renderer")]
|
#[serde(default = "default_renderer")]
|
||||||
pub renderer: String,
|
pub renderer: String,
|
||||||
|
/// App version that AUTO-degraded `renderer` (the ladder persisted "gl"
|
||||||
|
/// or "software" after failed starts). Empty = `renderer` is the user's
|
||||||
|
/// own choice. A NEW build re-probes "auto" once (vendored renderer
|
||||||
|
/// fixes / driver updates are likely) — the ladder re-degrades within
|
||||||
|
/// one start if the stack is still broken. Cleared when the user picks
|
||||||
|
/// a renderer manually in Settings.
|
||||||
|
#[serde(default)]
|
||||||
|
pub renderer_auto_degraded: String,
|
||||||
|
/// App version whose ALT-adapter wgpu rung SURVIVED a session (stamped
|
||||||
|
/// at sentinel-disarm time). While it matches the running build, fresh
|
||||||
|
/// auto-detects arm the alternate adapter directly — without this the
|
||||||
|
/// rung-2 success dies with the process and a #542-family machine would
|
||||||
|
/// crash every other launch forever. Version-keyed like
|
||||||
|
/// `renderer_auto_degraded`; cleared on a manual renderer pick.
|
||||||
|
#[serde(default)]
|
||||||
|
pub renderer_wgpu_alt: String,
|
||||||
/// Interface-size preset: `"default"` | `"small"` | `"large"` | `"xl"`.
|
/// Interface-size preset: `"default"` | `"small"` | `"large"` | `"xl"`.
|
||||||
/// Read at the very top of main() (before ANY thread exists) to set
|
/// Read at the very top of main() (before ANY thread exists) to set
|
||||||
/// SLINT_SCALE_FACTOR, so changes apply on restart.
|
/// SLINT_SCALE_FACTOR, so changes apply on restart.
|
||||||
@@ -704,6 +720,8 @@ impl Default for UiPrefs {
|
|||||||
window_x: default_window_pos(),
|
window_x: default_window_pos(),
|
||||||
window_y: default_window_pos(),
|
window_y: default_window_pos(),
|
||||||
renderer: default_renderer(),
|
renderer: default_renderer(),
|
||||||
|
renderer_auto_degraded: String::new(),
|
||||||
|
renderer_wgpu_alt: String::new(),
|
||||||
ui_scale: default_ui_scale(),
|
ui_scale: default_ui_scale(),
|
||||||
last_dpr: default_last_dpr(),
|
last_dpr: default_last_dpr(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
//! UI event-loop responsiveness watchdog (#555 diagnosis aid).
|
||||||
|
//!
|
||||||
|
//! The #555 class of lag is RENDERER-INDEPENDENT (software == GL == wgpu in
|
||||||
|
//! both field reports), which means the bottleneck sits above the renderer:
|
||||||
|
//! the event loop itself stops turning promptly. This watchdog measures
|
||||||
|
//! exactly that — the round-trip latency of a cross-thread
|
||||||
|
//! `invoke_from_event_loop` closure — every couple of seconds, from a plain
|
||||||
|
//! background thread. It never switches anything: it records, logs ONCE when
|
||||||
|
//! degradation is sustained, and feeds the Developer > Diagnostics panel so
|
||||||
|
//! field reports carry a number instead of "feels like 3fps".
|
||||||
|
//!
|
||||||
|
//! Design guards against false positives: sampling starts after a startup
|
||||||
|
//! grace (cache rebuilds, first paints), a flag needs many CONSECUTIVE bad
|
||||||
|
//! samples (a suspend/resume or one heavy IO burst resets the streak), and
|
||||||
|
//! the timeout cap keeps a wedged loop from blocking the watchdog thread.
|
||||||
|
|
||||||
|
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
|
||||||
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
|
/// Latency of the most recent probe, in milliseconds.
|
||||||
|
static LAST_MS: AtomicU64 = AtomicU64::new(0);
|
||||||
|
/// Worst latency seen this session, in milliseconds.
|
||||||
|
static WORST_MS: AtomicU64 = AtomicU64::new(0);
|
||||||
|
/// Set once when SUSTAINED_BAD consecutive probes exceeded BAD_MS.
|
||||||
|
static FLAGGED: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
|
/// Don't sample during the startup storm.
|
||||||
|
const STARTUP_GRACE: Duration = Duration::from_secs(30);
|
||||||
|
/// Probe cadence.
|
||||||
|
const INTERVAL: Duration = Duration::from_secs(2);
|
||||||
|
/// A probe slower than this counts against the streak. ~250ms dispatch
|
||||||
|
/// latency means the loop turns at <4Hz — far past "janky", into "broken".
|
||||||
|
const BAD_MS: u64 = 250;
|
||||||
|
/// Consecutive bad probes (~20s of sustained degradation) before flagging.
|
||||||
|
const SUSTAINED_BAD: u32 = 10;
|
||||||
|
/// Cap so a fully wedged loop can't block the watchdog thread forever.
|
||||||
|
const PROBE_TIMEOUT: Duration = Duration::from_secs(10);
|
||||||
|
|
||||||
|
/// Spawn the watchdog thread. Call once, after the Slint event loop exists.
|
||||||
|
pub fn spawn() {
|
||||||
|
let _ = std::thread::Builder::new()
|
||||||
|
.name("qbz-ui-watchdog".into())
|
||||||
|
.spawn(|| {
|
||||||
|
std::thread::sleep(STARTUP_GRACE);
|
||||||
|
let mut streak = 0u32;
|
||||||
|
loop {
|
||||||
|
std::thread::sleep(INTERVAL);
|
||||||
|
let (tx, rx) = std::sync::mpsc::channel::<()>();
|
||||||
|
let sent = Instant::now();
|
||||||
|
if slint::invoke_from_event_loop(move || {
|
||||||
|
let _ = tx.send(());
|
||||||
|
})
|
||||||
|
.is_err()
|
||||||
|
{
|
||||||
|
// Event loop is gone — the app is shutting down.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Clamped to the probe cap: `Instant` counts suspend time on
|
||||||
|
// modern Linux (CLOCK_BOOTTIME), so a sleep mid-probe would
|
||||||
|
// otherwise record a multi-hour "worst" forever.
|
||||||
|
let ms = match rx.recv_timeout(PROBE_TIMEOUT) {
|
||||||
|
Ok(()) => (sent.elapsed().as_millis() as u64)
|
||||||
|
.min(PROBE_TIMEOUT.as_millis() as u64),
|
||||||
|
Err(_) => PROBE_TIMEOUT.as_millis() as u64,
|
||||||
|
};
|
||||||
|
LAST_MS.store(ms, Ordering::Relaxed);
|
||||||
|
WORST_MS.fetch_max(ms, Ordering::Relaxed);
|
||||||
|
if ms > BAD_MS {
|
||||||
|
streak += 1;
|
||||||
|
} else {
|
||||||
|
streak = 0;
|
||||||
|
}
|
||||||
|
if streak == SUSTAINED_BAD && !FLAGGED.swap(true, Ordering::Relaxed) {
|
||||||
|
log::warn!(
|
||||||
|
"[ui-watchdog] UI event loop sustained >{BAD_MS}ms dispatch latency \
|
||||||
|
for ~{}s (last probe {ms}ms) — the interface is running degraded. \
|
||||||
|
This is ABOVE the renderer (all tiers affected); see issue #555.",
|
||||||
|
(SUSTAINED_BAD as u64 * INTERVAL.as_secs())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Latest probe latency in ms (0 = no probe yet).
|
||||||
|
pub fn last_latency_ms() -> u64 {
|
||||||
|
LAST_MS.load(Ordering::Relaxed)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Worst probe latency this session, in ms.
|
||||||
|
pub fn worst_latency_ms() -> u64 {
|
||||||
|
WORST_MS.load(Ordering::Relaxed)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// True once sustained degradation was flagged this session.
|
||||||
|
pub fn flagged() -> bool {
|
||||||
|
FLAGGED.load(Ordering::Relaxed)
|
||||||
|
}
|
||||||
Reference in new issue
Block a user