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

Fix #3169: Database race condition crash at startup. #3170

Merged
merged 1 commit into from
Jan 6, 2021
Merged
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
19 changes: 9 additions & 10 deletions Client/Application/Delegates/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIViewControllerRestorati

// Set the Firefox UA for browsing.
setUserAgent()

// An attempt to fix #2185.
// There's an unknown crash related to database creation, which happens when tabs are being restored.
// Our DataControllers uses a mix of static and lazy properties, there is a chance that some
// concurrency problems are occuring.
// This forces the database to initialize the most important lazy properties before doing any other
// database related code.
// Please note that this is called after bookmark and keychain restoration processes.
DataController.shared.lazyInitialization()

// Start the keyboard helper to monitor and cache keyboard state.
KeyboardHelper.defaultHelper.startObserving()

DynamicFontHelper.defaultHelper.startObserving()

MenuHelper.defaultHelper.setItems()
Expand All @@ -112,21 +120,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIViewControllerRestorati
let logDate = Date()
// Create a new sync log file on cold app launch. Note that this doesn't roll old logs.
Logger.syncLogger.newLogWithDate(logDate)

Logger.browserLogger.newLogWithDate(logDate)

let profile = getProfile(application)
let profilePrefix = profile.prefs.getBranchPrefix()
Migration.launchMigrations(keyPrefix: profilePrefix)

// An attempt to fix #2185.
// There's an unknown crash related to database creation, which happens when tabs are being restored.
// Our DataControllers uses a mix of static and lazy properties, there is a chance that some
// concurrency problems are occuring.
// This forces the database to initialize most important lazy properties before doing any other
// database related code.
// Please note that this is called after bookmark and keychain restoration processes.
DataController.shared.lazyInitialization()
setUpWebServer(profile)

var imageStore: DiskImageStore?
Expand Down