mixpanel / mixpanel-swift

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

Websocket may block main queue on disconnection timeout #382

Closed Michael-Kr closed 4 years ago

Michael-Kr commented 4 years ago

I've accidentally noticed that you use the same Websocket.swift by Dalton Cherry as I do. I've identified an edge case issue when disconnect(forceTimeout:) called with a non-nil timeout value. The timeout action is triggered on the callbackQueue which is main queue by default and because the disconnectStream inside is called with error = nil the writeQueue.waitUntilAllOperationsAreFinished() will be called on main thread and will block the UI. I see you currently don't apply the timeout so the callbackQueue to be the main queue is probably not very painful, but still decided to let you know :) There are several easy ways to overcome the potential issue:

zihejia commented 4 years ago

hi @Michael-Kr , thanks for letting us know. Currently we don't have plan to update that piece of code from the 3rd party if it's working fine cause that problematic code path won't be executed under our use case. But definitely we will keep that in mind. Thanks!