-
Notifications
You must be signed in to change notification settings - Fork 717
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
Crash on com.apollographql.websocket on _inputStreamCallbackFunc #3390
Comments
Hi @aaronbarsky - you mentioned this being consistent; do you know the conditions or sequence of events that leads to the crash. Being able to have a reproduction case would be immensely helpful to resolving this. |
By consistent, I mean that the call stack is exactly the same in each case. It happens about 1/500 sessions. The challenge is that the start of the crash is
which makes it quite tough to write a unit test or minimally reproducible example. |
We're going to really struggle to create or verify a fix for this since, as you said, its difficult to reproduce it.
What codepaths are you referring to here? If there are some obvious areas where we are creating unsafe memory access, I'd suggest trying to fork the library, fix the |
I worked around the problem with an explicit call to closeConnection. Previously I had
Now I keep an explicit reference to the networkTransport so I can close it before deallocating the client
(Note that networkTransport is Fixing it in the library would require a lot of changes, that could be complex. The problem is that FoundationStream marks the delgate as Current situation
My theoretical fix would look something like
The tricky bit is that you can't make strong references to self in the deinit. So rather than the delegate being an instance of Apollo.FoundationStream, it would have to be a separate object with a weak reference back to FoundationStream. I'm too busy to make an attempt on this now. Perhaps if this code doesn't change much in Apollo 2.0, I can give it another look in the future. |
Thanks for the great debugging @aaronbarsky.
The current StarScream-based websocket implementation will be removed from Apollo iOS; it's old, unsupported and hindering progress. Ideally we build a default websocket implementation using iOS native websocket APIs but allow users to swap in whatever websocket library they choose to use. When that happens is still undecided though. We're trying to keep the scope of 2.0 breaking changes as small as possible and it really depends how much work is needed here to achieve that. |
I'm seeing a handful of crashes like this as well in my app |
@aaronbarsky Isn't setting the
If that's the case, could the crash be that On my end, the crashes seem to be happening because I call |
Summary
Crashlytics is reporting a very rare but consistent crash on the com.apollograph.websocket queue.
The app is a mix of 60% foreground and 40% background.
Version
1.9.2
Steps to reproduce the behavior
Unfortunately I only have crash logs
Logs
No response
Anything else?
My hunch is that it's the FoundationStream teardown sequence:
stream.delegate is an
unowned(unsafe)
var.There are several codepaths where cleanup is not called on com.apollographql.websocket. When this happens, delegate can be set to nil as the CFReadStream is attempting to invoke a callback on the deallocated delegate.
The text was updated successfully, but these errors were encountered: