mirror of
https://github.com/StikDebug/StikDebug.git
synced 2026-10-15 20:10:30 +00:00
Fix JIT race on cold URL-scheme launch
This commit is contained in:
parent
03b7c109ac
commit
c1189928d4
2 changed files with 24 additions and 2 deletions
|
|
@ -45,6 +45,7 @@ struct StikDebugApp: App {
|
|||
private func downloadMissingDeveloperDiskImageFiles() async {
|
||||
do {
|
||||
try await DeveloperDiskImageService.shared.downloadMissingFiles()
|
||||
MountingProgress.shared.pubMount()
|
||||
} catch {
|
||||
await MainActor.run {
|
||||
showAlert(
|
||||
|
|
|
|||
|
|
@ -308,8 +308,18 @@ struct HomeView: View {
|
|||
let keepAliveLease = DebugKeepAliveLease()
|
||||
defer { keepAliveLease.invalidate() }
|
||||
|
||||
if triggeredByURLScheme {
|
||||
sleep(1)
|
||||
if triggeredByURLScheme, !waitForJITPrerequisites() {
|
||||
DispatchQueue.main.async {
|
||||
withAnimation {
|
||||
debugFeedback = nil
|
||||
}
|
||||
showAlert(
|
||||
title: "Failed to Enable JIT".localized,
|
||||
message: "The device connection or Developer Disk Image wasn't ready in time. Open StikDebug directly, wait for it to finish connecting, then try again.".localized,
|
||||
showOk: true
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
let finishProcessing: (Bool, String?) -> Void = { success, detail in
|
||||
|
|
@ -384,6 +394,17 @@ struct HomeView: View {
|
|||
}
|
||||
}
|
||||
|
||||
private func waitForJITPrerequisites(timeout: TimeInterval = 20) -> Bool {
|
||||
let deadline = Date().addingTimeInterval(timeout)
|
||||
while Date() < deadline {
|
||||
if TunnelManager.shared.isConnected && MountingProgress.shared.coolisMounted {
|
||||
return true
|
||||
}
|
||||
usleep(250_000)
|
||||
}
|
||||
return TunnelManager.shared.isConnected && MountingProgress.shared.coolisMounted
|
||||
}
|
||||
|
||||
private func base64URLToBase64(_ base64url: String) -> String {
|
||||
var base64 = base64url.replacingOccurrences(of: "-", with: "+").replacingOccurrences(of: "_", with: "/")
|
||||
let pad = 4 - (base64.count % 4)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue