New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash due to non thread safe destinations property #340
Comments
Thanks for posting this and taking your time to investigate the issue! Can you please also share how you set up the logger? |
I'm encountering the same issue.
This is the setup code. |
Ah I think we found the issue! SwiftyBeaver is spawning using its own thread for logging operations to not slow down an app and that seems to create race conditions during the setup. Please try not to put SwiftyBeaver into an own thread and initialize it on the main thread. |
This is the change I did : Move the setup out of the |
In our case the setup is performed in the main thread, as soon as the app start. We (myself and @dlbuckley) believe the issue is related to the @skreutzberger can you please reopen this issue? |
We've been running into the same issue on our project. Just put up a fix for it here: #504 |
Overview
We have been seeing a crash when logging from within an NSOperation from a few of our users. I've been trying to track it down for the past few hours and have managed to track it down to the
destinations
property not being thread safe.Details
We have a number of services that start when the app starts and one of those is to do with sending network requests that have failed or have been cached previously. If the user starts the app without a network connection the request fails very quickly and so the operation fails which in turn triggers an issue to be logged. This is fine but the SwiftyBeaver service is being started at the same time and is having it's destinations added. The crash seems to come down to the destinations being modified while they are also being accessed.
As you can see from the crash log, the issue is appearing in
SwiftyBeaver.swift
at line 149 in version 1.7 (app name replaced with XXXXX for privacy reasons).Note
While it's not typically expected to start logging until the logger has started, it is also not expected to provoke a crash. This is one has come to light as it's actually a network request going through our own networking code in our own logger destination that triggers the log. Its a bit of a "chicken and the egg" situation.
The text was updated successfully, but these errors were encountered: