fix(workbench): keep timing ticker active in background pages (#1985)

Co-authored-by: root <root@lyon.remote>
This commit is contained in:
Lyon
2026-06-23 20:38:39 +08:00
committed by GitHub
parent e3a8c20fda
commit 839b85d17c
@@ -35,7 +35,10 @@ function refreshNow(): void {
}
function reconcileTimer(): void {
const shouldRun = isBrowser() && isDocumentVisible() && hasActiveSubscriber();
// Passive observer pages may be backgrounded while still being the source of
// web-probe samples. Keep the render ticker alive for active subscribers so
// elapsed/recent labels advance monotonically instead of jumping on resume.
const shouldRun = isBrowser() && hasActiveSubscriber();
if (shouldRun && timer === null) {
refreshNow();
timer = window.setInterval(refreshNow, TICK_INTERVAL_MS);
@@ -74,7 +77,3 @@ function handleVisibilityChange(): void {
function isBrowser(): boolean {
return typeof window !== "undefined";
}
function isDocumentVisible(): boolean {
return typeof document === "undefined" || document.visibilityState !== "hidden";
}