fix(workbench): keep timing ticker active in background pages (#1985)
Co-authored-by: root <root@lyon.remote>
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user