我在iOS上啓動了我的Cordova應用程序,從一個重要的位置更改開始,有時以這種方式啓動時,它在打開數據庫時崩潰。我不確定是什麼情況導致這種情況 - 我自己無法再現,我剛剛收到關於Crashlytics的報告;它看起來像隻影響一些設備。在後臺模式下打開FMDB時崩潰
這裏是我的代碼:
class Database {
static let DB_DIR:URL = {
// Library/LocalDatabase doesn't get backed up to iTunes/iCloud, and it matches our sqlite plugin's default (for Javascript access)
let fileMgr = FileManager.default
let libUrl:URL = try! fileMgr.url(for: .libraryDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
return libUrl.appendingPathComponent("LocalDatabase")
}()
static func getPath(_ dbName:String!) -> String {
return DB_DIR.appendingPathComponent(dbName).path
}
static func createDb(_ dbName:String!) -> FMDatabase {
return FMDatabase(path: getPath(dbName))
}
// only for front- and back-end dbs (TODO - close these when app exits, or open/close for each transaction?)
static func getOpenedDb(_ dbName:String) -> FMDatabase {
let db:FMDatabase = createDb(dbName)
if !db.open() {
fatalError("Unable to open \(dbName)")
}
return db
}
static let BACKEND_DB:FMDatabase = Database.getOpenedDb("mainIosDb")
static let FRONTEND_DB:FMDatabase = Database.getOpenedDb("JsDb")
}
...這是一個崩潰日誌:
Crashed: com.rsginc.rmove.TripStorage.singleton
0 libswiftCore.dylib 0x1008c8a18 _TFs16_assertionFailedFTVs12StaticStringSSS_Su5flagsVs6UInt32_Os5Never + 164
1 rMove 0x10022dc88 type metadata accessor for Database (Utilities.swift)
2 rMove 0x10022d320 globalinit_33_2CFFAAA7EF6073F07DB88164E80B793B_func11 (Utilities.swift:177)
3 libdispatch.dylib 0x188c6e1bc _dispatch_client_callout + 16
4 libdispatch.dylib 0x188c6efb0 dispatch_once_f + 56
5 rMove 0x10022d35c Database.BACKEND_DB.unsafeMutableAddressor (Utilities.swift)
6 rMove 0x100213864 TripStorage.init() -> TripStorage (TripStorage.swift:13)
7 rMove 0x100213508 static TripStorage.(getInstance() -> TripStorage).(closure #1) (TripStorage.swift:87)
8 libdispatch.dylib 0x188c6e1bc _dispatch_client_callout + 16
9 libdispatch.dylib 0x188c7b7f0 _dispatch_barrier_sync_f_invoke + 84
10 rMove 0x100213418 static TripStorage.getInstance() -> TripStorage (TripStorage.swift)
11 rMove 0x10020384c specialized CordovaInterface.start(Double, Double, Int, Double, Double, String, Bool, Int, Int, Double, Int, Int, Int, Int) ->() (CordovaInterface.swift)
12 rMove 0x1001fea74 CordovaInterface.configureFromDefaults() ->() (CordovaInterface.swift)
13 rMove 0x1002014fc partial apply (CordovaInterface.swift)
14 rMove 0x10020b1e0 specialized TerminationRecovery.applicationLaunched(notification : NSNotification) ->() (TerminationRecovery.swift)
15 rMove 0x10020a020 @objc TerminationRecovery.applicationLaunched(notification : NSNotification) ->() (TerminationRecovery.swift)
16 CoreFoundation 0x189d7eb10 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
17 CoreFoundation 0x189d7e214 _CFXRegistrationPost + 400
18 CoreFoundation 0x189d7df90 ___CFXNotificationPost_block_invoke + 60
19 CoreFoundation 0x189dedb8c -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1504
20 CoreFoundation 0x189cbfe64 _CFXNotificationPost + 376
21 Foundation 0x18a7f4e0c -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
22 UIKit 0x18ff1cd38 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4196
23 UIKit 0x18ff22808 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1656
24 UIKit 0x18ff37104 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke.3139 + 48
25 UIKit 0x18ff1f7ec -[UIApplication workspaceDidEndTransaction:] + 168
26 FrontBoardServices 0x18b9bb92c __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36
27 FrontBoardServices 0x18b9bb798 -[FBSSerialQueue _performNext] + 176
28 FrontBoardServices 0x18b9bbb40 -[FBSSerialQueue _performNextFromRunLoopSource] + 56
29 CoreFoundation 0x189d92b5c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
30 CoreFoundation 0x189d924a4 __CFRunLoopDoSources0 + 524
31 CoreFoundation 0x189d900a4 __CFRunLoopRun + 804
32 CoreFoundation 0x189cbe2b8 CFRunLoopRunSpecific + 444
33 UIKit 0x18fd057b0 -[UIApplication _run] + 608
34 UIKit 0x18fd00534 UIApplicationMain + 208
35 rMove 0x100103b00 main (main.m:32)
36 libdispatch.dylib 0x188ca15b8 (Missing)
此行的堆棧跟蹤:
2 rMove 0x10022d320 globalinit_33_2CFFAAA7EF6073F07DB88164E80B793B_func11 (Utilities.swift:177)
相當於本行代碼:
static let BACKEND_DB:FMDatabase = Database.getOpenedDb("mainIosDb")
我的猜測和希望的是,有在堆棧跟蹤一些偉大的信息直接在此問題的原因分,我只是不知道如何解釋它。
通過「大信息」我希望這意味着某人做某事: 我使用FMDB _TFs16_assertionFailedFTVs12StaticStringSSS_Su5flagsVs6UInt32_Os5Never – Crag