Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions wBlockCoreService/FilterUpdateXPC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class FilterUpdateClient {

/// Calls the XPC service to run an update, returning true on success.
/// If the service is missing or fails to respond within the timeout, returns false.
public func updateFilters(timeout seconds: TimeInterval = 2.0) async -> Bool {
public func updateFilters(timeout seconds: TimeInterval = 180.0) async -> Bool {
let log = OSLog(subsystem: "wBlockCoreService", category: "FilterUpdateXPC")
guard seconds.isFinite, seconds >= 0 else {
os_log("Invalid XPC timeout: %.2fs", log: log, type: .error, seconds)
Expand Down Expand Up @@ -78,16 +78,24 @@ public final class FilterUpdateClient {
}
}

guard let proxy = connection.remoteObjectProxy as? FilterUpdateProtocol else {
os_log("Failed to obtain remoteObjectProxy for XPC service", log: log, type: .error)
let proxy = connection.remoteObjectProxyWithErrorHandler { error in
if markFinished() {
os_log("Failed to obtain remoteObjectProxy for XPC service: %{public}@", log: log, type: .error, error.localizedDescription)
connection.invalidate()
cont.resume(returning: false)
}
}

guard let filterProxy = proxy as? FilterUpdateProtocol else {
os_log("Failed to cast remoteObjectProxy to FilterUpdateProtocol", log: log, type: .error)
if markFinished() {
connection.invalidate()
cont.resume(returning: false)
}
return
}

proxy.updateFilters { success in
filterProxy.updateFilters { success in
if markFinished() {
connection.invalidate()
cont.resume(returning: success)
Comment thread
0xCUB3 marked this conversation as resolved.
Expand Down