Closed esreli closed 2 years ago
@esreli can you provide a simple, example project that consistently reproduces this issue? I've managed to reproduce a few times, somewhat randomly, but more often than not, the issue is not reproducible.
Hi @jaredmixpanel, thanks for looking into this issue. After this sprint I'll try to set aside some time to publish a consistent repro case.
Hi @jaredmixpanel. I've reproduced the bug and pushed the code to this repository: esreli/mixpanel-bug.
Here's another interesting thing that I've learned along the way. If I were to initialize Mixpanel in the highest level View
instead of initializing Mixpanel within the App
then the problem seems to resolve itself.
Thanks in advance for looking into this for me!
@esreli thanks for the example project. I still find the behavior very random. I've attached a long, boring, low resolution (sorry!) screen recording below, so you can see my results are very inconsistent. At the moment, I'm inclined to think this is a SwiftUI/Xcode kind of thing and that Mixpanel just so happens to be the code that is in your init(), but that some other code may cause similar issues.
@jaredmixpanel very interesting. I've updated the dependency to the latest commit on main as of today and it appears that the issue was possibly connected to the deadlock issue and is now resolved.
I can't be entirely confident here because the bug/repro case is so unreliable but, for now, I believe the issue has been fixed. Thanks @gabriellanata!
Closing.
Hi @jaredmixpanel @esreli I've still the issue, my whole app turns blue when I init Mixpanel
Environment
Xcode Version 13.2.1 (13C100) Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30) SPM Resolved Dependency:
Issue
I'm building a SwiftUI iOS app with a min deployment of iOS 14+. Because of this I'm using the SwiftUI types introduced in iOS 14 like
App
,Scene
, etc. As such, I'm not notified that the app has launched through the app or scene delegate as is the case forUIKit
apps. With this "pure" SwiftUI approach, all initializations are typically done within theApp
's init function.With the initialization of Mixpanel, all of a sudden the project's Global accent color (contained by an Asset Catalog) is reverted to the default system blue.
I believe this is an issue with the initialization API because when I comment out the line...
...the app global accent color works as expected.
What I've tried to remedy the issue
.xcasset
item from the default"AccentColor"
to a non-standard name.Current Workaround
I've created a lazily built reference to
Mixpanel.mainInstance()
in which I initialize the token. This allows the Mixpanel initialize token code to be ran on the first time the app fires off the first track event.This isn't ideal because any tracking associated with initializing Mixpanel is deferred until the first actively tracked event leaving a gap between launch and the first event in unknown territory.
Do you have any idea what's going on here? Thanks!