Skip to content

Commit

Permalink
Start managing content blocking assets before tab is loaded into memory
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaresiak committed Jan 30, 2024
1 parent 8ed7f51 commit 3810d78
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

ContentBlocking.shared.onCriticalError = presentPreemptiveCrashAlert
// Explicitly prepare ContentBlockingUpdating instance before Tabs are created
_ = ContentBlockingUpdating.shared

// Can be removed after a couple of versions
cleanUpMacPromoExperiment2()
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/ContentBlockingUpdating.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension ContentBlockerRulesIdentifier.Difference {
}

public final class ContentBlockingUpdating {
fileprivate static let shared = ContentBlockingUpdating()
static let shared = ContentBlockingUpdating()

private typealias Update = ContentBlockerRulesManager.UpdateEvent
struct NewContent: UserContentControllerNewContent {
Expand All @@ -55,7 +55,7 @@ public final class ContentBlockingUpdating {

private(set) var userContentBlockingAssets: AnyPublisher<NewContent, Never>!

init(appSettings: AppSettings = AppDependencyProvider.shared.appSettings,
init(appSettings: AppSettings = AppUserDefaults(),
contentBlockerRulesManager: ContentBlockerRulesManagerProtocol = ContentBlocking.shared.contentBlockingManager,
privacyConfigurationManager: PrivacyConfigurationManaging = ContentBlocking.shared.privacyConfigurationManager) {

Expand Down
3 changes: 0 additions & 3 deletions DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -847,9 +847,6 @@ class MainViewController: UIViewController {
if tabManager.current(createIfNeeded: true) == nil {
fatalError("failed to create tab")
}

// Likely this hasn't happened yet so the publishers won't be loaded and will block the webview from loading
_ = ContentBlocking.shared.contentBlockingManager.scheduleCompilation()
}

guard let tab = currentTab else { fatalError("no tab") }
Expand Down

0 comments on commit 3810d78

Please sign in to comment.