Skip to content

armgit / cra

Public Imported from GitHub
0

The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.

Tab sleeping says why it passed a page over and counts pages apart from retries; a discarded page's load end is no visit (#214)

Victor135f7941c5cf
diff --git a/Packages/CraCore/Sources/CraCore/ItemTable.swift b/Packages/CraCore/Sources/CraCore/ItemTable.swift
index fb65fa1..fb65d6e 100644
--- a/Packages/CraCore/Sources/CraCore/ItemTable.swift
+++ b/Packages/CraCore/Sources/CraCore/ItemTable.swift
@@ -20,6 +20,7 @@ public final class ItemTable {
@ObservationIgnored private var signals: [UUID: ItemSignal] = [:]
/// Bumped on every change: what a walk over all items observes.
private var version = 0
+ @ObservationIgnored private var tabs = 0
public init() {}
@@ -29,12 +30,21 @@ public final class ItemTable {
return storage[id]
}
set {
- guard storage[id] != newValue else { return }
+ let old = storage[id]
+ guard old != newValue else { return }
storage[id] = newValue
+ tabs += (newValue?.isTab == true ? 1 : 0) - (old?.isTab == true ? 1 : 0)
notify(id)
}
}
+ /// How many items are tabs, kept as items change: the performance recorder reads it every
+ /// five seconds, and counting 2,600 items there cost 2–6 ms of the main thread (GitHub #214).
+ public var tabCount: Int {
+ _ = version
+ return tabs
+ }
+
public var all: [UUID: SidebarItem] {
_ = version
return storage
diff --git a/Packages/CraCore/Sources/CraCore/Perf/PerfMetric.swift b/Packages/CraCore/Sources/CraCore/Perf/PerfMetric.swift
index 991b37e..0f416d2 100644
--- a/Packages/CraCore/Sources/CraCore/Perf/PerfMetric.swift
+++ b/Packages/CraCore/Sources/CraCore/Perf/PerfMetric.swift
@@ -32,9 +32,19 @@ public enum PerfCounter: String, Codable, CaseIterable, Sendable {
/// Chromium's "Page Unresponsive" (about 15 s without handling input), and its recovery.
case rendererUnresponsive
case rendererResponsive
- /// Tab sleeping closed a page, or kept one awake; the key is why.
+ /// Tab sleeping closed a page; the key is why (the policy).
case tabSlept
+ /// A page that refused to sleep, once per page and reason (what cra.log says); the key is the
+ /// reason. `sleepRetry` counts the same page refusing again after the back-off (GitHub #214:
+ /// one page asked eight times read like eight pages).
case sleepRefusal
+ case sleepRetry
+ /// A candidate tab sleeping passed over without asking its page (loading, Picture in
+ /// Picture, DevTools…), once per page and reason; the key is TabSleepPolicy.Hold.
+ case sleepSkip
+ /// A data-folder JSON file written; the key is its name, so `jsonSave`'s count can be told
+ /// apart by file (GitHub #214).
+ case fileSaved
}
/// The kinds of process Cra runs, from the name macOS gives each one.
diff --git a/Packages/CraCore/Sources/CraCore/Perf/PerfState.swift b/Packages/CraCore/Sources/CraCore/Perf/PerfState.swift
index 5014b25..255998f 100644
--- a/Packages/CraCore/Sources/CraCore/Perf/PerfState.swift
+++ b/Packages/CraCore/Sources/CraCore/Perf/PerfState.swift
@@ -73,7 +73,7 @@ public struct PerfState: Sendable {
case .rendererUnresponsive: events.append(PerfEvent(at: at, kind: "renderer", detail: "unresponsive", site: site))
case .rendererResponsive: events.append(PerfEvent(at: at, kind: "renderer", detail: "responsive again", site: site))
case .loadError: events.append(PerfEvent(at: at, kind: "load", detail: "error \(key)", site: site))
- case .tabSlept, .sleepRefusal: break
+ case .tabSlept, .sleepRefusal, .sleepRetry, .sleepSkip, .fileSaved: break
}
}
diff --git a/Packages/CraCore/Sources/CraCore/TabSleepPolicy.swift b/Packages/CraCore/Sources/CraCore/TabSleepPolicy.swift
index aca481c..5eb2aa3 100644
--- a/Packages/CraCore/Sources/CraCore/TabSleepPolicy.swift
+++ b/Packages/CraCore/Sources/CraCore/TabSleepPolicy.swift
@@ -68,6 +68,60 @@ public struct TabSleepPolicy: Equatable, Sendable {
return Set((visible + hidden).prefix(count))
}
+ /// A candidate's page as BrowserManager sees it before asking it anything.
+ public struct PageState: Equatable, Sendable {
+ public var discarded = false
+ public var hiddenAt: Date?
+ public var audibleAt: Date?
+ public var visible = false
+ public var created = true
+ public var closed = false
+ public var loading = false
+ public var pictureInPicture = false
+ public var capturing = false
+ public var audible = false
+ public var devTools = false
+
+ public init(discarded: Bool = false, hiddenAt: Date?, audibleAt: Date? = nil, visible: Bool = false, created: Bool = true,
+ closed: Bool = false, loading: Bool = false, pictureInPicture: Bool = false, capturing: Bool = false,
+ audible: Bool = false, devTools: Bool = false) {
+ self.discarded = discarded
+ self.hiddenAt = hiddenAt
+ self.audibleAt = audibleAt
+ self.visible = visible
+ self.created = created
+ self.closed = closed
+ self.loading = loading
+ self.pictureInPicture = pictureInPicture
+ self.capturing = capturing
+ self.audible = audible
+ self.devTools = devTools
+ }
+ }
+
+ /// Why a page stays awake without being asked, the first that holds (GitHub #214: a sweep
+ /// that came 27 passes late could not say which). The raw values are `sleepSkip`'s keys in
+ /// perf.json and the words in cra.log.
+ public enum Hold: String, CaseIterable, Sendable {
+ case discarded, shown, sound, notCreated, closing, loading, pictureInPicture, capturing, audible, devTools
+ }
+
+ /// nil when the page may be asked to sleep: out of sight and silent since before `cutoff`, made,
+ /// not loading, and in no Picture in Picture, capture or DevTools.
+ public static func hold(_ p: PageState, before cutoff: Date) -> Hold? {
+ if p.discarded { return .discarded }
+ if p.visible || p.hiddenAt.map({ $0 < cutoff }) != true { return .shown }
+ if p.audibleAt.map({ $0 < cutoff }) == false { return .sound }
+ if !p.created { return .notCreated }
+ if p.closed { return .closing }
+ if p.loading { return .loading }
+ if p.pictureInPicture { return .pictureInPicture }
+ if p.capturing { return .capturing }
+ if p.audible { return .audible }
+ if p.devTools { return .devTools }
+ return nil
+ }
+
/// Chromium's freezing policy sees what Cra's page probes can't: a call with the camera and
/// microphone off (an open RTCPeerConnection), a USB, Bluetooth, HID or serial device, a
/// mirrored or captured tab. `reasons` are its CannotFreezeReasonToString names for the page
diff --git a/Packages/CraCore/Tests/CraCoreTests/ItemTableTests.swift b/Packages/CraCore/Tests/CraCoreTests/ItemTableTests.swift
index aa137cd..683acde 100644
--- a/Packages/CraCore/Tests/CraCoreTests/ItemTableTests.swift
+++ b/Packages/CraCore/Tests/CraCoreTests/ItemTableTests.swift
@@ -57,4 +57,25 @@ struct ItemTableTests {
#expect(fired.value)
#expect(ItemSignal().version == 0)
}
+
+ /// The recorder's tab count, kept as items change instead of counted every sample (#214).
+ @Test(.bug("https://github.com/VictorKildahl/cra/issues/214")) func tabCountFollowsWrites() {
+ let table = ItemTable()
+ let folder = SidebarItem.folder("F", parent: nil)
+ var tabs = (0..<3).map { SidebarItem.tab("https://example.com/\($0)", parent: folder.id) }
+ table[folder.id] = folder
+ for t in tabs { table[t.id] = t }
+ #expect(table.tabCount == 3)
+ tabs[0].title = "renamed"
+ table[tabs[0].id] = tabs[0]
+ table[tabs[1].id] = tabs[1]
+ #expect(table.tabCount == 3, "a tab written again is still one tab")
+ table[tabs[2].id] = nil
+ table[UUID()] = nil
+ #expect(table.tabCount == 2)
+ table[tabs[1].id] = SidebarItem(id: tabs[1].id, parentID: nil, title: "F2", children: [], isUnread: false,
+ createdAt: folder.createdAt, data: folder.data)
+ #expect(table.tabCount == 1, "a tab turned folder stops counting")
+ #expect(table.tabCount == table.values.filter(\.isTab).count)
+ }
}
diff --git a/Packages/CraCore/Tests/CraCoreTests/TabSleepPolicyTests.swift b/Packages/CraCore/Tests/CraCoreTests/TabSleepPolicyTests.swift
index 229cea2..2b03f1a 100644
--- a/Packages/CraCore/Tests/CraCoreTests/TabSleepPolicyTests.swift
+++ b/Packages/CraCore/Tests/CraCoreTests/TabSleepPolicyTests.swift
@@ -118,4 +118,31 @@ struct TabSleepPolicyTests {
@Test func pressureLevels() {
#expect([PerfSystemSample.Pressure.normal, .warning, .critical, .unknown].map(\.isShort) == [false, true, true, false])
}
+
+ /// Why a candidate stays awake without being asked, the first that holds (#214).
+ @Test(.bug("https://github.com/VictorKildahl/cra/issues/214")) func holds() {
+ let now = Date(timeIntervalSince1970: 10_000), cutoff = now.addingTimeInterval(-900)
+ let idle = TabSleepPolicy.PageState(hiddenAt: now.addingTimeInterval(-3600))
+ #expect(TabSleepPolicy.hold(idle, before: cutoff) == nil)
+ func with(_ change: (inout TabSleepPolicy.PageState) -> Void) -> TabSleepPolicy.Hold? {
+ var p = idle
+ change(&p)
+ return TabSleepPolicy.hold(p, before: cutoff)
+ }
+ #expect(with { $0.discarded = true } == .discarded)
+ #expect(with { $0.visible = true } == .shown)
+ #expect(with { $0.hiddenAt = nil } == .shown)
+ #expect(with { $0.hiddenAt = now.addingTimeInterval(-60) } == .shown)
+ #expect(with { $0.audibleAt = now.addingTimeInterval(-60) } == .sound)
+ #expect(with { $0.audibleAt = now.addingTimeInterval(-3600) } == nil)
+ #expect(with { $0.created = false } == .notCreated)
+ #expect(with { $0.closed = true } == .closing)
+ #expect(with { $0.loading = true } == .loading)
+ #expect(with { $0.pictureInPicture = true } == .pictureInPicture)
+ #expect(with { $0.capturing = true } == .capturing)
+ #expect(with { $0.audible = true } == .audible)
+ #expect(with { $0.devTools = true } == .devTools)
+ #expect(with { $0.loading = true; $0.devTools = true } == .loading, "the first that holds is the one said")
+ #expect(TabSleepPolicy.Hold.loading.rawValue == "loading", "the key in perf.json and the word in cra.log")
+ }
}
diff --git a/Sources/Cra/Perf/PerfCEF.swift b/Sources/Cra/Perf/PerfCEF.swift
index bfe9450..f7d33d2 100644
--- a/Sources/Cra/Perf/PerfCEF.swift
+++ b/Sources/Cra/Perf/PerfCEF.swift
@@ -66,7 +66,7 @@ enum PerfCEF {
private static func tabCounts(_ app: AppDelegate) -> PerfTabCounts {
let managers = app.mainWindows.compactMap(\.browsers)
- return PerfTabCounts(tabs: app.store.allTabs().count,
+ return PerfTabCounts(tabs: app.store.items.tabCount,
live: managers.reduce(0) { $0 + $1.runtimes.values.filter { !$0.discarded }.count },
visible: managers.reduce(0) { $0 + $1.visibleTabIDs.count },
slept: managers.reduce(0) { $0 + $1.sleptTabs.count },
diff --git a/Sources/Cra/Services/BrowserManager.swift b/Sources/Cra/Services/BrowserManager.swift
index 07d4ba3..40463f0 100644
--- a/Sources/Cra/Services/BrowserManager.swift
+++ b/Sources/Cra/Services/BrowserManager.swift
@@ -40,6 +40,9 @@ final class TabRuntime {
var sleepProbeAfter: Date?
/// Why the page last refused to sleep ("" when it didn't), so the log says it once.
var sleepRefusal: String?
+ /// Why tab sleeping last passed the page over without asking it (nil: it didn't), so the log
+ /// and the recorder say it once (#214).
+ var sleepHold: TabSleepPolicy.Hold?
/// Whether this page's DevTools are open, closing or asked for (DevToolsToggle).
var devTools = DevToolsToggle()
/// Loads of an extension's page Chromium blocked because the extension wasn't up yet
@@ -422,7 +425,13 @@ final class BrowserManager: NSObject, @preconcurrency CraBrowserDelegate {
let cutoff = now.addingTimeInterval(-policy.hiddenFor)
var asked = 0
for id in policy.candidates(sleepPages, visible: visibleTabIDs, protectedRecent: protectedRecentTabs, now: now) {
- guard let rt = runtimes[id], canSleep(rt, before: cutoff), rt.sleepProbeAfter.map({ $0 <= now }) ?? true else { continue }
+ guard let rt = runtimes[id] else { continue }
+ if let hold = sleepHold(rt, before: cutoff) {
+ passOver(rt, hold)
+ continue
+ }
+ rt.sleepHold = nil
+ guard rt.sleepProbeAfter.map({ $0 <= now }) ?? true else { continue }
if let limit = policy.limit, asked >= limit { break }
asked += 1
let b = rt.browser
@@ -478,6 +487,7 @@ final class BrowserManager: NSObject, @preconcurrency CraBrowserDelegate {
}
guard discarded else { return self.unload(id) }
rt.discarded = true
+ rt.sleepRefusal = nil
if rt.freezeVoted { self.setFreezingVote(rt, false) }
self.delegate?.browserManagerDidUpdate(id)
}
@@ -508,14 +518,25 @@ final class BrowserManager: NSObject, @preconcurrency CraBrowserDelegate {
runtimes[id] === rt && rt.navigationRevision == revision && rt.browser.currentURL == url && canSleep(rt, before: cutoff)
}
- /// Asked again after the back-off; the log names the site once per reason (never an incognito one).
+ /// Asked again after the back-off; the log names the site once per reason (never an incognito
+ /// one), and the recorder counts the page once per reason and its later refusals as retries (#214).
private func keepAwake(_ rt: TabRuntime, _ url: String, _ refusal: String) {
rt.sleepProbeAfter = clock.now.addingTimeInterval(Self.refusalBackoff)
+ guard rt.sleepRefusal != refusal else { return Perf.count(.sleepRetry, refusal) }
Perf.count(.sleepRefusal, refusal)
- if rt.sleepRefusal != refusal, !rt.browser.isIncognito { CraLog.note("tab sleep keeps \(CraLog.host(url)) awake: \(refusal)") }
+ if !rt.browser.isIncognito { CraLog.note("tab sleep keeps \(CraLog.host(url)) awake: \(refusal)") }
rt.sleepRefusal = refusal
}
+ /// A candidate held awake before its page is asked (loading, DevTools…): said once per reason,
+ /// so a sweep that comes late can be explained from cra.log and the recorder (#214).
+ private func passOver(_ rt: TabRuntime, _ hold: TabSleepPolicy.Hold) {
+ guard rt.sleepHold != hold else { return }
+ rt.sleepHold = hold
+ Perf.count(.sleepSkip, hold.rawValue)
+ if !rt.browser.isIncognito { CraLog.note("tab sleep passes over \(CraLog.host(rt.browser.currentURL)): \(hold.rawValue)") }
+ }
+
static let refusalBackoff: TimeInterval = 10 * 60
/// Arc's WebContentLifecycleOptimization freezes a page out of sight for `timeToFreezeTab`
@@ -562,11 +583,15 @@ final class BrowserManager: NSObject, @preconcurrency CraBrowserDelegate {
TabSleepPolicy.recentlyShown(sleepPages, visible: visibleTabIDs, count: protectedRecentTabs)
}
- private func canSleep(_ rt: TabRuntime, before cutoff: Date) -> Bool {
+ private func canSleep(_ rt: TabRuntime, before cutoff: Date) -> Bool { sleepHold(rt, before: cutoff) == nil }
+
+ private func sleepHold(_ rt: TabRuntime, before cutoff: Date) -> TabSleepPolicy.Hold? {
let b = rt.browser
- return !rt.discarded && rt.hiddenAt.map { $0 < cutoff } == true && rt.audibleAt.map { $0 < cutoff } != false
- && !visibleTabIDs.contains(rt.tabID) && b.isCreated && !b.isClosed && !b.isLoading && !b.isInPictureInPicture
- && !b.isCapturingMedia && !b.isAudible && !b.hasDevTools
+ return TabSleepPolicy.hold(.init(discarded: rt.discarded, hiddenAt: rt.hiddenAt, audibleAt: rt.audibleAt,
+ visible: visibleTabIDs.contains(rt.tabID), created: b.isCreated, closed: b.isClosed,
+ loading: b.isLoading, pictureInPicture: b.isInPictureInPicture,
+ capturing: b.isCapturingMedia, audible: b.isAudible, devTools: b.hasDevTools),
+ before: cutoff)
}
/// In Cra's isolated world: "" when the page has nothing to lose, else why it must stay:
@@ -1065,7 +1090,8 @@ final class BrowserManager: NSObject, @preconcurrency CraBrowserDelegate {
}
func browser(_ browser: CraBrowser, didFinishLoadingURL url: String, title: String, statusCode: Int) {
- guard let id = tabID(of: browser) else { return }
+ // CEF ends the load of the page a discard just closed: nothing loaded, and nothing was visited (#214).
+ guard let id = tabID(of: browser), runtimes[id]?.discarded != true else { return }
log(id, "loaded \(site(url, id, browser)) (HTTP \(statusCode))")
if statusCode != 0 { runtimes[id]?.extensionPageRetries = 0 }
guard !browser.isIncognito else { return }
diff --git a/Sources/Cra/Services/Persistence.swift b/Sources/Cra/Services/Persistence.swift
index 12cfdd8..e310453 100644
--- a/Sources/Cra/Services/Persistence.swift
+++ b/Sources/Cra/Services/Persistence.swift
@@ -109,7 +109,10 @@ final class JSONStore<T: Codable> {
try? fm.removeItem(at: bak)
try? fm.copyItem(at: url, to: bak)
}
- do { try data.write(to: url, options: .atomic) } catch {
+ do {
+ try data.write(to: url, options: .atomic)
+ Perf.count(.fileSaved, url.lastPathComponent)
+ } catch {
CraLog.fault("\(url.lastPathComponent) not saved: \(error.localizedDescription)")
}
}
diff --git a/Tests/BrowserManagerLifecycleTests.swift b/Tests/BrowserManagerLifecycleTests.swift
index 5ca3da9..cb6402e 100644
--- a/Tests/BrowserManagerLifecycleTests.swift
+++ b/Tests/BrowserManagerLifecycleTests.swift
@@ -102,6 +102,8 @@ enum BrowserManagerLifecycleTests {
await sleepClockCase()
await pressureSweepCase()
await discardCase()
+ await discardedPageLoadCase()
+ await sleepCountsCase()
shortTimerCase()
recentlyAudibleCase()
await audiblePageStaysAwakeCase()
@@ -553,6 +555,79 @@ enum BrowserManagerLifecycleTests {
manager.closeAll()
}
+ // promise: #214
+ /// CEF reports a load end for the page a discard just ended (#214). That page isn't there: the
+ /// log says nothing, history gets no visit and no Web Store install starts. Loaded again on
+ /// waking, it counts.
+ @MainActor
+ private static func discardedPageLoadCase() async {
+ let store = SidebarStore()
+ let manager = BrowserManager(store: store, favicons: FaviconCache(), container: NSView())
+ manager.protectedRecentTabs = 0
+ let url = "https://example.test/discarded-load"
+ let id = store.createTab(url: url).id
+ let rt = manager.ensureRuntime(for: id)!
+ rt.hiddenAt = Date.distantPast
+ manager.sleepIdleTabs(TabSleepPolicy(hiddenFor: 60))
+ rt.browser.reply(to: isolatedProbe, with: idleReply)
+ await drainMainQueue()
+ rt.browser.reply(to: "Runtime.evaluate", with: idleReply)
+ await drainMainQueue()
+ await finishSleep(rt.browser)
+ let installs = ExtensionStore.shared.webStoreProfiles.count
+ expect(rt.discarded, "the page is discarded")
+ manager.browser(rt.browser, didFinishLoadingURL: url, title: "Discarded", statusCode: 200)
+ expect(store.visits.isEmpty && ExtensionStore.shared.webStoreProfiles.count == installs,
+ "a discarded page's load end is no visit and starts no Web Store install")
+ manager.show(id, focus: false)
+ manager.browser(rt.browser, didFinishLoadingURL: url, title: "Woken", statusCode: 200)
+ expect(store.visits == [url] && ExtensionStore.shared.webStoreProfiles.count == installs + 1,
+ "the page loaded again on waking is a visit")
+ manager.closeAll()
+ }
+
+ // promise: #214
+ /// What the recorder says about tab sleeping (#214): a candidate passed over counts once per
+ /// reason (the first that holds, TabSleepPolicy.hold), and a page refusing again after the
+ /// back-off counts as a retry of the same page, not as another page.
+ @MainActor
+ private static func sleepCountsCase() async {
+ var facts: [(PerfCounter, String)] = []
+ Perf.attach { fact in if case .count(let c, let key, _, _) = fact { facts.append((c, key)) } }
+ defer { Perf.attach(nil) }
+ facts = [] // what earlier cases left in the recorder's start-up buffer
+ func counted(_ c: PerfCounter) -> [String] { facts.filter { $0.0 == c }.map(\.1) }
+ let store = SidebarStore()
+ let manager = BrowserManager(store: store, favicons: FaviconCache(), container: NSView())
+ manager.protectedRecentTabs = 0
+
+ let loadingID = store.createTab(url: "https://example.test/loading").id
+ let loading = manager.ensureRuntime(for: loadingID)!
+ loading.hiddenAt = Date.distantPast
+ loading.browser.setLoading(true)
+ for _ in 0..<3 { manager.sleepIdleTabs(TabSleepPolicy(hiddenFor: 60)) }
+ expect(counted(.sleepSkip) == ["loading"] && !loading.browser.replies.contains { $0.method == isolatedProbe },
+ "a loading page passed over three times counts once, as loading")
+ loading.browser.setLoading(false)
+ loading.browser.hasDevTools = true
+ manager.sleepIdleTabs(TabSleepPolicy(hiddenFor: 60))
+ expect(counted(.sleepSkip) == ["loading", "devTools"], "a new reason counts again")
+ loading.browser.hasDevTools = false
+ manager.sleepIdleTabs(TabSleepPolicy(hiddenFor: 60))
+ expect(loading.browser.replies.contains { $0.method == isolatedProbe }, "with nothing holding it the page is asked")
+ loading.browser.reply(to: isolatedProbe, with: #"{"result":{"type":"string","value":"typed"}}"#)
+ await drainMainQueue()
+ for _ in 0..<2 {
+ loading.sleepProbeAfter = Date.distantPast
+ manager.sleepIdleTabs(TabSleepPolicy(hiddenFor: 60))
+ loading.browser.reply(to: isolatedProbe, with: #"{"result":{"type":"string","value":"typed"}}"#)
+ await drainMainQueue()
+ }
+ expect(counted(.sleepRefusal) == ["typed"] && counted(.sleepRetry) == ["typed", "typed"],
+ "one page refusing three times is one refusal and two retries")
+ manager.closeAll()
+ }
+
// promise: #153
/// "Force tabs out of memory after:" below Arc's 4 hours closes the 10 tabs used last too;
/// 4 hours and more keep them (#153).
diff --git a/Tests/BrowserManagerSupport/AppServices.swift b/Tests/BrowserManagerSupport/AppServices.swift
index 0b05060..2991c9f 100644
--- a/Tests/BrowserManagerSupport/AppServices.swift
+++ b/Tests/BrowserManagerSupport/AppServices.swift
@@ -38,7 +38,9 @@ enum TestRoot { case today }
}
func setThemeColor(_ id: UUID, _ hex: String) { items[id]?.tab?.themeColor = hex }
func setFaviconKey(_ id: UUID, _ key: String) { items[id]?.tab?.faviconKey = key }
- func recordVisit(url: String, title: String) {}
+ /// The URLs a finished load counted as visits, in order.
+ var visits: [String] = []
+ func recordVisit(url: String, title: String) { visits.append(url) }
func clearHistory(_ range: BrowsingDataClear.Range) {}
func selectTab(_ id: UUID, window: UUID?) {}
func markUnread(_ id: UUID, _ unread: Bool) {}
diff --git a/Tests/promises.lock b/Tests/promises.lock
index 19a3469..44b92da 100644
--- a/Tests/promises.lock
+++ b/Tests/promises.lock
@@ -331,6 +331,10 @@
#211 Packages/CraCore/Tests/CraCoreTests/FaviconKeyTests.swift::tabsOnOneHostKeepTheirOwnIcons 21d360f30e94
#212 Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swift::turkishQZoomKeys 840de09abff1
#213 Packages/CraCore/Tests/CraCoreTests/FolderPeekTests.swift::aClickOpensAClosedFolderEvenWithItsOpenTabInSight 70f9e64eb96b
+#214 Packages/CraCore/Tests/CraCoreTests/ItemTableTests.swift::tabCountFollowsWrites 549f222462af
+#214 Packages/CraCore/Tests/CraCoreTests/TabSleepPolicyTests.swift::holds d2bd0269d879
+#214 Tests/BrowserManagerLifecycleTests.swift::discardedPageLoadCase 4c91d8a1d9df
+#214 Tests/BrowserManagerLifecycleTests.swift::sleepCountsCase ea4c379bd476
#215 Tests/StoreTests.swift::arcLiveFolderImportsLive a5c462b3a9c7
#218 Tests/Scenarios/extension-popup-download.scenario ffb6285b0eee
#219 Packages/CraCore/Tests/CraCoreTests/TabTearOffTests.swift::aWindowLargerThanTheScreenShrinksToFit bb6acd6907ac
diff --git a/docs/performance.md b/docs/performance.md
index c4fef47..c531468 100644
--- a/docs/performance.md
+++ b/docs/performance.md
@@ -71,7 +71,10 @@ whether Cra was active. Per process kind (browser, renderer, GPU, utility, other
Chromium's `--type=` argument): CPU, memory footprint, disk reads and writes, wakeups (in the
file only), and processes started and ended. The Mac: CPU, memory pressure, thermal state, Low
Power Mode, free disk, and Cra's average CPU while nobody used the Mac (`idle`: 5-second samples
-with no keyboard or mouse input for a minute). Tabs by state, sleep refusals by reason, and
+with no keyboard or mouse input for a minute). Tabs by state; tab sleeping's pages closed
+(`tabSlept`), pages refusing (`sleepRefusal`, once per page and reason, then `sleepRetry` for
+each ask after the back-off) and candidates passed over without being asked (`sleepSkip`:
+loading, DevTools, Picture in Picture…, once per page and reason; cra.log names the site); and
timings for tab switch (without the page created for a tab that had none, which is page
create), page create, page load, waking a slept tab and framing an extension's popup. In the visible page,
read with the long tasks every 5 s and never in background tabs: long tasks, Chromium's long
@@ -79,7 +82,8 @@ animation frames (`longFrames`, `longestFrameMs`: a passive observer, it asks fo
the frames its videos played and dropped (`getVideoPlaybackQuality`). Renderer crashes, hangs
and failed loads with their codes. Start-up phases (store loaded, Chromium started, windows shown, then the first page shown,
committed and loaded), JSON load and save times (saves run on the
-persistence queue, so `jsonSave` is never a main-thread stall), the profile's and caches' size
+persistence queue, so `jsonSave` is never a main-thread stall; `fileSaved` counts the writes by
+file name), the profile's and caches' size
(at export only). The session: a random id, the launch number, the previous session and whether
it quit. The totals in `tabs` are since launch; `history.json`, in the export too, has stalls
and long tasks per 5 minutes.