Tighten browser devtools close timing
This commit is contained in:
parent
8397b32067
commit
48426bf1ec
2 changed files with 10 additions and 3 deletions
|
|
@ -4221,11 +4221,18 @@ extension BrowserPanel {
|
|||
func noteDeveloperToolsHostAttached() {
|
||||
cancelPendingDeveloperToolsVisibilityLossCheck()
|
||||
developerToolsLastAttachedHostAt = Date()
|
||||
developerToolsLastKnownVisibleAt = isDeveloperToolsVisible() ? Date() : nil
|
||||
if isDeveloperToolsVisible() {
|
||||
developerToolsLastKnownVisibleAt = Date()
|
||||
}
|
||||
}
|
||||
|
||||
func scheduleDeveloperToolsVisibilityLossCheck() {
|
||||
developerToolsVisibilityLossCheckWorkItem?.cancel()
|
||||
let attachedAge = developerToolsLastAttachedHostAt.map { Date().timeIntervalSince($0) } ?? 0
|
||||
let delay = max(
|
||||
developerToolsTransitionSettleDelay,
|
||||
developerToolsAttachedManualCloseDetectionDelay - attachedAge
|
||||
)
|
||||
let workItem = DispatchWorkItem { [weak self] in
|
||||
guard let self else { return }
|
||||
self.developerToolsVisibilityLossCheckWorkItem = nil
|
||||
|
|
@ -4233,7 +4240,7 @@ extension BrowserPanel {
|
|||
}
|
||||
developerToolsVisibilityLossCheckWorkItem = workItem
|
||||
DispatchQueue.main.asyncAfter(
|
||||
deadline: .now() + developerToolsTransitionSettleDelay,
|
||||
deadline: .now() + max(0, delay),
|
||||
execute: workItem
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -542,7 +542,7 @@ struct BrowserPanelView: View {
|
|||
// `isVisibleInUI` never flips to false. Check for an attached-inspector
|
||||
// X-close when focus leaves as well so the persisted intent stays in sync.
|
||||
DispatchQueue.main.async {
|
||||
_ = panel.consumeAttachedDeveloperToolsManualCloseIfNeeded()
|
||||
panel.scheduleDeveloperToolsVisibilityLossCheck()
|
||||
}
|
||||
}
|
||||
syncWebViewResponderPolicyWithViewState(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue