Skip to content
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

Optimize input queue processing in SRProxyConnect. #455

Merged
merged 2 commits into from
Aug 23, 2016

Conversation

nlutsenko
Copy link
Contributor

Purely to tackle the theory described in #421 (comment)

@erikprice
Copy link
Contributor

This looks good, @nlutsenko. Thanks for submitting this.

We can't reproduce the bug that this fixes, but we've seen it in the field. We are still using a fork of SocketRocket, if you remember. I'll apply this commit to our fork and it will go out in our next App Store release, and we'll let you know if we see a drop in crash reports for this problem.

@richardjrossiii
Copy link
Contributor

richardjrossiii commented Aug 8, 2016

What does the stack trace look like when -dequeueInput is invoked? Are there still ivar references to the SRProxyConnect around that aren't strong at that time (that could then cause a crash in the method that invokes dequeueInput)?

Honestly, I think the proper solution here is to either

  • A: Hold a strong reference to self for the duration of deuqueInput (and potentially, the calling function).
  • B: Ensure that the ProxyConnect object is not deallocated in the completion handler.

Having this strange scenario where you potentially cannot use any of the variables in self after calling _proxyProcessHTTPResponseWithData seems dangerous, and likely to break again in the future.

@erikprice
Copy link
Contributor

erikprice commented Aug 8, 2016

@richardjrossiii said

What does the stack trace look like when -dequeueInput is invoked?

You can see the stack trace from two separate apps that have encountered this problem in #421.

Are there still ivar references to the SRProxyConnect around that aren't strong at that time (that could then cause a crash in the method that invokes dequeueInput)?

I'm not sure if there is an ivar reference to the SRProxyConnect within the SocketRocket project, but it does seem possible that the SRProxyConnect object is still set as the delegate of a NSStream object at that time, and this property is listed as having assign semantics in Apple's header file.

Does that help with your assessment?

@nlutsenko
Copy link
Contributor Author

Per our discussion - I ended up just moving the cleanup for proxy connect to the work queue, instead of creating an autoreleasing local scope variable. Biggest reason - it's disconnected and most of the calls are in a separate method.

@richardjrossiii
Copy link
Contributor

#shipit

@nlutsenko nlutsenko merged commit 00a8a66 into master Aug 23, 2016
@nlutsenko nlutsenko deleted the nlutsenko.proxy.crash branch August 23, 2016 00:42
@nlutsenko nlutsenko added this to the 0.6.0 milestone Oct 31, 2016
madlymad pushed a commit to madlymad/SocketRocket that referenced this pull request Jul 6, 2017
…y.crash

Optimize input queue processing in SRProxyConnect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants