CoreStore icon indicating copy to clipboard operation
CoreStore copied to clipboard

DefaultLogger issue

Open llKoull opened this issue 5 years ago • 11 comments

Hi!

I've been using this amazing library since 2 years ago but I'm experiencing many crashes in a class named DefaultLogger since March.

I don't really know where the problem is, but fabric says that the line 126 of DefaultLogger.swift crashes. I can't even reproduce the error in any of my devices, but the users are complaining about it and Fabric tells that there are many crashes of the same kind.

I attach one of the crash logs that fabrics generates. Can you help me?

Thanks and best regards!

com.arcadiaseed.nootric_issue_crash_0d57e54adbfd4283817e1f88fa5ed81e_DNE_0_v2.txt

llKoull avatar Apr 13 '19 06:04 llKoull

The logger will get called if there are any errors or any assertion failures, so it will be the last line in your stack trace. You will need to look at the stack trace right before the logger calls as that is where the real issue will be.

JohnEstropia avatar Apr 14 '19 00:04 JohnEstropia

Hi @JohnEstropia ,

Thanks for your answer, I was inspecting the stack trace and I found that the crash is generated in a method that persists the information of the user called in the "applicationWillResignActive" method of the AppDelegate.

Do you know if there is any problem if I call this method just before the app resign active?

CoreStore.perform( asynchronous: { (transaction) -> Void in do { if let user = try transaction.fetchOne(From<User>()) { ... // SAVE INFORMATION }catch{ print("Error: User couldn't be stored...") } }, completion: { _ in })

Maybe there's some internal timeout or maybe it should be called on the main thread.

Thanks and best regards!

llKoull avatar Apr 15 '19 07:04 llKoull

The most common issue around this is that your transaction.fetchOne is getting called before your DataStack.addStorage(...) processing completes.

JohnEstropia avatar Apr 15 '19 07:04 JohnEstropia

Thanks for your (really) fast answer @JohnEstropia !

I checked it but I Initialize Core Store in the "application: didFinishLaunchingWithOptions" and the I use it during all the session. Just before the app resigns active I persist the information. I don't know what's happening 😆

Best regards!

llKoull avatar Apr 15 '19 07:04 llKoull

Can you show how you are initializing your DataStack? From your stack trace it looks like it's crashing during loading of xcdatamodeld file

JohnEstropia avatar Apr 15 '19 09:04 JohnEstropia

Hey @JohnEstropia !

Yeah, sure 😉

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { self.initializeCoreStore(success: {() -> Void in .... }, failure: {(error) -> Void in })

    return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}

fileprivate func initializeCoreStore(success: @escaping () -> Void, failure: @escaping (Error) -> Void) { if let dbFileUrl = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first?.appendingPathComponent("{path}") { let dataStack = DataStack(xcodeModelName: "{model_name}", bundle: .main, migrationChain: nil) _ = dataStack.addStorage( SQLiteStore(fileURL: dbFileUrl, configuration: "Default", localStorageOptions: .recreateStoreOnModelMismatch), completion: { (result) -> Void in switch result { case .success(_): RegisterFlowScreenHelper.shared.loadInitialInformation(completion: { () -> Void in ObjectiveHelper.shared.loadInitialInformation(completion: { () -> Void in UserManagerHelper.shared.loadInitialInformation(completion: { () -> Void in success() }) }) }) case .failure(let error): print("Failed adding sqlite store with error: (error)") failure(error) } }) CoreStore.defaultStack = dataStack } }

Thanks and best regards!

llKoull avatar Apr 15 '19 09:04 llKoull

Try to set the CoreStore.defaultStack to your DataStack as early as you can.

CoreStore.defaultStack = DataStack(/* ... */)
_ = dataStack.addStorage(
    // ...
)

JohnEstropia avatar Apr 16 '19 09:04 JohnEstropia

Ok @JohnEstropia I did the cande and I'm uploading a new version to the Store.

I hope it works! hehehe

I'll tell you something as soon as I see the Crashlytitcs stats ;)

Thanks and best regards!

llKoull avatar Apr 16 '19 09:04 llKoull

Hi @JohnEstropia !

I released a new version of the app with the change that you proposed me but the issue is still there 😟 I don't know why but 2 of the most common issues of my app are related to CoreStore.

Maybe I am doing something wrong but I don't know where is the problem and I can't reproduce the error on my devices.

Thanks and best regards!

Captura de pantalla 2019-04-22 a las 9 05 02

llKoull avatar Apr 22 '19 07:04 llKoull

Hello @JohnEstropia !

It's been a long time since my last message and i've been investigating those issues that i'm still experiencing.

One weird thing that i saw is that if i look the full session information of the crash in fabric, theres a crash_info_entry_1 with the path of the CoreStore sources in my local computer. Is it normal? I've never saw this before.

Captura de pantalla 2019-07-18 a las 16 57 00

I'm using CoreStore 6.3.1 right now and those crashes are the most repeated in my app :S

Thanks and best regards!

llKoull avatar Jul 18 '19 14:07 llKoull

Hello again!

This issue is my biggest problem right now. Look the statistics just for the last version:

Captura de pantalla 2019-08-03 a las 11 29 31

Anyone has any ideas?

Thanks and best regards!

llKoull avatar Aug 03 '19 09:08 llKoull