diff --git a/src/core/drive/visit.js b/src/core/drive/visit.js index ec7565979..97aef6300 100644 --- a/src/core/drive/visit.js +++ b/src/core/drive/visit.js @@ -1,7 +1,7 @@ import { FetchMethod, FetchRequest } from "../../http/fetch_request" import { getAnchor } from "../url" import { PageSnapshot } from "./page_snapshot" -import { getHistoryMethodForAction, uuid, nextRepaint } from "../../util" +import { getHistoryMethodForAction, uuid } from "../../util" import { StreamMessage } from "../streams/stream_message" import { ViewTransitioner } from "./view_transitioner" @@ -419,7 +419,10 @@ export class Visit { async render(callback) { this.cancelRender() - this.frame = await nextRepaint() + await new Promise((resolve) => { + this.frame = + document.visibilityState === "hidden" ? setTimeout(() => resolve(), 0) : requestAnimationFrame(() => resolve()) + }) await callback() delete this.frame } diff --git a/src/tests/fixtures/cache_observer.html b/src/tests/fixtures/cache_observer.html index 5ad72b190..ad1b391f7 100644 --- a/src/tests/fixtures/cache_observer.html +++ b/src/tests/fixtures/cache_observer.html @@ -12,5 +12,7 @@