Attempt to fix stale tabs losing info

This commit is contained in:
2026-07-06 09:24:36 -07:00
parent 4371f051aa
commit 18b63cbd19
3 changed files with 29 additions and 27 deletions
+10 -20
View File
@@ -19,7 +19,6 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate
public var tabInfo: TabInfo {
get {
updateMetadata()
return _tabInfo
}
}
@@ -39,18 +38,14 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate
}
public var policyManager: ResourcePolicyManager
private var _tabInfo: TabInfo = TabInfo()
// Persisted snapshot of visible tab metadata; do not recompute on read.
var _tabInfo: TabInfo = TabInfo()
private var loadedWebView: WKWebView? = nil
public var title: String? { get { tabInfo.title } }
public var url: URL? {
get {
if let urlString = tabInfo.urlString {
return URL(string: urlString)
}
return nil
}
if let urlString = tabInfo.urlString { return URL(string: urlString) }
return nil
}
public var javaScriptEnabled: Bool = false {
@@ -110,6 +105,10 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate
super.init()
bridge.delegate = self
// Initialize snapshot metadata
_tabInfo.identifier = self.identifier
if let url { _tabInfo.urlString = url.absoluteString }
}
deinit {
@@ -117,6 +116,8 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate
}
func beginLoadingURL(_ url: URL) {
// Update snapshot immediately so UI keeps URL even if process jettisons.
_tabInfo.urlString = url.absoluteString
let request = URLRequest(url: url)
webView.load(request)
}
@@ -150,15 +151,4 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate
.assign(to: \.favicon, on: self)
}
}
private func updateMetadata() {
guard contentProcessTerminated == false else { return }
_tabInfo = TabInfo(
title: loadedWebView?.title,
urlString: loadedWebView?.url?.absoluteString ?? self.homeURL?.absoluteString,
faviconData: self.favicon?.pngData(),
identifier: self.identifier
)
}
}