Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Fix #7366: Tab restoring white screen sometimes #7367

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion Sources/Brave/Frontend/Browser/TabManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ class TabManager: NSObject {

if let request = request {
tab.loadRequest(request)
tab.url = request.url
} else if !isPopup {
tab.loadRequest(PrivilegedRequest(url: TabManager.ntpInteralURL) as URLRequest)
tab.url = TabManager.ntpInteralURL
Expand Down Expand Up @@ -901,7 +902,11 @@ class TabManager: NSObject {
for savedTab in savedTabs {
let tabURL = savedTab.url
// Provide an empty request to prevent a new tab from loading the home screen
let tab = addTab(URLRequest(url: tabURL),
let request = InternalURL.isValid(url: tabURL) ?
PrivilegedRequest(url: tabURL) as URLRequest :
URLRequest(url: tabURL)

let tab = addTab(request,
flushToDisk: false,
zombie: true,
id: savedTab.tabId,
Expand Down
15 changes: 10 additions & 5 deletions Sources/Data/models/SessionTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ extension SessionTab {

public static func update(tabId: UUID, interactionState: Data, title: String, url: URL) {
DataController.perform { context in
guard let sessionTab = Self.from(tabId: tabId, in: context) else { return }
guard let sessionTab = Self.from(tabId: tabId, in: context) else {
Logger.module.error("Error: SessionTab.update missing managed object")
return
}
sessionTab.interactionState = interactionState
sessionTab.title = title
sessionTab.url = url
Expand All @@ -166,7 +169,7 @@ extension SessionTab {
DataController.perform { context in
for (index, tabId) in tabIds.enumerated() {
guard let tab = Self.from(tabId: tabId, in: context) else {
Logger.module.error("Error: SessionTab missing managed object")
Logger.module.error("Error: SessionTab.updateScreenshot missing managed object")
continue
}
tab.index = Int32(index)
Expand All @@ -176,12 +179,14 @@ extension SessionTab {

public static func updateAll(tabs: [(tabId: UUID, interactionState: Data, title: String, url: URL)]) {
DataController.performOnMainContext { context in
for (index, tab) in tabs.enumerated() {
guard let sessionTab = Self.from(tabId: tab.tabId, in: context) else { return }
for tab in tabs {
guard let sessionTab = Self.from(tabId: tab.tabId, in: context) else {
Logger.module.error("Error: SessionTab.updateAll missing managed object")
continue
}
sessionTab.interactionState = tab.interactionState
sessionTab.title = tab.title
sessionTab.url = tab.url
sessionTab.index = Int32(index)
kylehickinson marked this conversation as resolved.
Show resolved Hide resolved
}

do {
Expand Down