Skip to content

Commit 7b17a86

Browse files
author
ComputelessComputer
committed
Keep capture work off the main thread
Move the expensive accessibility snapshot crawl off MainActor while keeping the frontmost-app lookup on the UI thread to reduce brief beachballs when reopening the app.
1 parent 81b7314 commit 7b17a86

2 files changed

Lines changed: 1 addition & 4 deletions

File tree

Sources/OpenbirdKit/Capture/AccessibilitySnapshotter.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public struct AccessibilitySnapshotter: Sendable {
2929

3030
public init() {}
3131

32-
@MainActor
3332
func snapshotFrontmostWindow(for application: FrontmostApplicationContext) -> WindowSnapshot? {
3433
if shouldUseMinimalSnapshot(for: application) {
3534
let snapshot = snapshotSanitizer.sanitize(minimalSnapshot(for: application))

Sources/OpenbirdKit/Capture/CollectorRuntime.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ public final class CollectorRuntime: NSObject, @unchecked Sendable {
169169
return
170170
}
171171

172-
guard var snapshot = await MainActor.run(body: {
173-
snapshotter.snapshotFrontmostWindow(for: frontmostApplication)
174-
}) else {
172+
guard var snapshot = snapshotter.snapshotFrontmostWindow(for: frontmostApplication) else {
175173
_ = try await persistCollectorStatus("idle", heartbeat: now)
176174
return
177175
}

0 commit comments

Comments
 (0)