Improve startup time (#822)
Profiles were loaded after reading receipt, which took at least a second on iOS. Potential regression from #821
This commit is contained in:
parent
a1b7679fb0
commit
abe4c779b8
|
@ -99,20 +99,24 @@ extension ExtendedTunnel {
|
|||
}
|
||||
|
||||
public func prepare(purge: Bool) async throws {
|
||||
pp_log(.app, .notice, "Prepare tunnel and purge stale data (\(purge))...")
|
||||
try await tunnel.prepare(purge: purge)
|
||||
}
|
||||
|
||||
public func install(_ profile: Profile) async throws {
|
||||
pp_log(.app, .notice, "Install profile \(profile.id)...")
|
||||
let newProfile = try processedProfile(profile)
|
||||
try await tunnel.install(newProfile, connect: false, title: processedTitle)
|
||||
}
|
||||
|
||||
public func connect(with profile: Profile) async throws {
|
||||
pp_log(.app, .notice, "Connect to profile \(profile.id)...")
|
||||
let newProfile = try processedProfile(profile)
|
||||
try await tunnel.install(newProfile, connect: true, title: processedTitle)
|
||||
}
|
||||
|
||||
public func disconnect() async throws {
|
||||
pp_log(.app, .notice, "Disconnect...")
|
||||
try await tunnel.disconnect()
|
||||
}
|
||||
|
||||
|
|
|
@ -67,15 +67,20 @@ public final class AppContext: ObservableObject {
|
|||
return
|
||||
}
|
||||
isActivating = true
|
||||
Task {
|
||||
do {
|
||||
pp_log(.app, .notice, "Application became active")
|
||||
await iapManager.reloadReceipt()
|
||||
pp_log(.app, .notice, "Prepare tunnel and purge stale data...")
|
||||
try await tunnel.prepare(purge: true)
|
||||
Task {
|
||||
await withTaskGroup(of: Void.self) { group in
|
||||
group.addTask {
|
||||
do {
|
||||
try await self.tunnel.prepare(purge: true)
|
||||
} catch {
|
||||
pp_log(.app, .fault, "Unable to prepare tunnel: \(error)")
|
||||
}
|
||||
}
|
||||
group.addTask {
|
||||
await self.iapManager.reloadReceipt()
|
||||
}
|
||||
}
|
||||
isActivating = false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue