-
Notifications
You must be signed in to change notification settings - Fork 88
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
Force closing the app or updating to a newer version, causes the Segment.Analytics.init(configuration:) to call fatalError() #333
Comments
I noticed the same issue on my project 😞 . |
If you have a crash report or stack trace, could you post it please @GavrilikArt @leontedev ? |
Hey, here it is: Crashed: com.apple.main-thread I removed most if it, because only those lines are relevant. |
I'd actually like to see the whole thing if you wouldn't mind. It'd show me what was happening overall. The contents or a description of the closure that's located in appDidFinishLaunching would be useful too since I'm guessing it's async or something. |
Ok. Crashed: com.apple.main-thread |
Thanks @GavrilikArt. Given that your application is coming from a CLEAN start, it seems that something else might be starting the analytics instance other than your |
In my case that is true: the closure which calls the Segment configuration and init in |
It's highly likely your closure is getting called twice somehow. As I mentioned previously, you can put a breakpoint on Analytics.init and see who the callers are and when they're occurring. As the log shows it's a completely fresh run, so there wouldn't be another analytics instance in place w/ a matching write key unless your code is making one. |
You are right! Thanks @bsneed! 🙏 |
@leontedev great, glad that worked out! Yeah, I hear what you're saying and believe me, it wasn't my first choice. We found customers creating two instances of analytics with the same write key, which in turn basically corrupted the storage system (two separate instances writing to all the same files and trying to send the same files to segment). We didn't feel that some DEBUG only thing was sufficient to get their attention to this anti-pattern. Some places have analytics disabled while in DEBUG, some places point all that stuff to the appropriate places in their CI, etc. all of which result in someone never seeing the fatalError call get hit. |
I see! Thanks for explaining! 🙏 |
Describe the bug
Ever since the changes made in 1.5.3 - the new Analytics
init(configuration:)
causes the app to crash if:It appears that in these 2 cases, the Analytics.deinit is not called and causes an issue on the next app's launch, when the Analytics object is initialised with a
writeKey
which is still "active".To Reproduce
Steps to reproduce the behavior:
analytics-swift
version higher than 1.5.2The text was updated successfully, but these errors were encountered: