DefaultLogger issue #266

Open
opened 2025-12-29 15:27:53 +01:00 by adam · 11 comments
Owner

Originally created by @llKoull on GitHub (Apr 13, 2019).

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

Originally created by @llKoull on GitHub (Apr 13, 2019). 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](https://github.com/JohnEstropia/CoreStore/files/3075861/com.arcadiaseed.nootric_issue_crash_0d57e54adbfd4283817e1f88fa5ed81e_DNE_0_v2.txt)
adam added the question label 2025-12-29 15:27:53 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Apr 14, 2019):

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 commented on GitHub (Apr 14, 2019): 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.
Author
Owner

@llKoull commented on GitHub (Apr 15, 2019):

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()) {
... // 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 commented on GitHub (Apr 15, 2019): 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!
Author
Owner

@JohnEstropia commented on GitHub (Apr 15, 2019):

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

@JohnEstropia commented on GitHub (Apr 15, 2019): The most common issue around this is that your `transaction.fetchOne` is getting called before your `DataStack.addStorage(...)` processing completes.
Author
Owner

@llKoull commented on GitHub (Apr 15, 2019):

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 commented on GitHub (Apr 15, 2019): 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!
Author
Owner

@JohnEstropia commented on GitHub (Apr 15, 2019):

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 commented on GitHub (Apr 15, 2019): Can you show how you are initializing your `DataStack`? From your stack trace it looks like it's crashing during loading of xcdatamodeld file
Author
Owner

@llKoull commented on GitHub (Apr 15, 2019):

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 commented on GitHub (Apr 15, 2019): 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!
Author
Owner

@JohnEstropia commented on GitHub (Apr 16, 2019):

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

CoreStore.defaultStack = DataStack(/* ... */)
_ = dataStack.addStorage(
    // ...
)
@JohnEstropia commented on GitHub (Apr 16, 2019): Try to set the `CoreStore.defaultStack` to your `DataStack` as early as you can. ```swift CoreStore.defaultStack = DataStack(/* ... */) _ = dataStack.addStorage( // ... ) ```
Author
Owner

@llKoull commented on GitHub (Apr 16, 2019):

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 commented on GitHub (Apr 16, 2019): 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!
Author
Owner

@llKoull commented on GitHub (Apr 22, 2019):

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 commented on GitHub (Apr 22, 2019): 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! <img width="1015" alt="Captura de pantalla 2019-04-22 a las 9 05 02" src="https://user-images.githubusercontent.com/5525265/56488235-1b986400-64de-11e9-944d-5d1f9addc6bc.png">
Author
Owner

@llKoull commented on GitHub (Jul 18, 2019):

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 commented on GitHub (Jul 18, 2019): 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](https://user-images.githubusercontent.com/5525265/61468159-1e8bdf00-a97d-11e9-93e1-d32c1ac25b83.png) I'm using CoreStore 6.3.1 right now and those crashes are the most repeated in my app :S Thanks and best regards!
Author
Owner

@llKoull commented on GitHub (Aug 3, 2019):

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 commented on GitHub (Aug 3, 2019): Hello again! This issue is my biggest problem right now. Look the statistics just for the last version: <img width="1041" alt="Captura de pantalla 2019-08-03 a las 11 29 31" src="https://user-images.githubusercontent.com/5525265/62410147-2df86280-b5e2-11e9-9bd9-c434460ebd84.png"> Anyone has any ideas? Thanks and best regards!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore#266