Description
Bug report
Hey, we are getting crash when entering background or returning from background (not fully sure because it is hard to reproduce it locally, but see Testflight crash logs and getting this info from our testers). I think it might be a problem that sockets are not running when app is in background and you can have race condition? when reconnecting.
Versions
Please fill in the versions you're currently using:
apollo-ios
SDK version: 0.51.0- Xcode version: 13.3.1
- Swift version: 5.6
- Package manager: Pods
Steps to reproduce
Hard to reproduce but is happening when app is backgrounded.
Further details
Seems you are using Starscream for Websockets and this was similar issue: daltoniam/Starscream#500
Feel that you should not reconnect from DispatchQueue.main.asyncAfter
but instead use processing queue inside WebSocketTransport processingQueue.asyncAfter
.
In addition to that feels that you have guys retain cycle inside WebsocketTransport:243
and some places too:
processingQueue.async {
if let str = str {
self.write(str)
}
self.queue.removeAll()
self.subscriptions.removeAll()
}
in that case self is holding strong reference to processingQueue
and processingQueue
strong to self