mixpanel / mixpanel-swift

Official iOS (Swift) Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
434 stars 234 forks source link

Deadlock during initialization on Mac SwiftUI #524

Closed gabriellanata closed 2 years ago

gabriellanata commented 2 years ago

PR https://github.com/mixpanel/mixpanel-swift/pull/519 introduced a bug where the Mixpanel initialization code deadlocks on Mac M1 when using SwiftUI (possibly more, that's just the computer I was testing on).

Specifically this code change that wraps the instance initialization in a dispatch queue and a semaphore. I've verified that by reverting that to the previous implementation the deadlock goes away.

Here is a sample SwiftUI project that reproduces the deadlock, you can try interacting with the window in any way (like resizing) and it will beachball forever. MixpanelDeadlock.zip

gabriellanata commented 2 years ago

I've submitted a PR with a suggested fix here: https://github.com/mixpanel/mixpanel-swift/pull/523

gabriellanata commented 2 years ago

cc @zihejia

jaredmixpanel commented 2 years ago

@gabriellanata this should be fixed in v3.1.6, let us know if any issues persist. thanks again!