-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash for web socket in some race conditions (#22439)
Summary: Fixes #21086. Fixes #6117. This PR fixes a crash caused by a race condition when `webSocket` deallocated and `NSStream` delegate callback, because `NSStream`'s delegate callback be called on `RCTSR_networkRunLoop`. This PR mainly changes: * Remove unnecessary `nil` operation in `dealloc` method. * Add a new method `_scheduleCleanUp` to schedule `webSocket` cleanup also on `RCTSR_networkRunLoop`. * In `stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode` delegate method, add a `wself` to make safe further. Pull Request resolved: #22439 Differential Revision: D13564247 Pulled By: cpojer fbshipit-source-id: 675c1b2805aa45c54d7708d796f5843ef7ea34e2
- Loading branch information
1 parent
2c3f807
commit dd209bb
Showing
1 changed file
with
133 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dd209bb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @zhongwuzw , I am here again. I follow your thread on Github issues and see the crash related to
RCTSRWebSocket.m
still continue until now. It looks like you fixed it completely. Currently, I have a project which is not apply your fixed.Can I copy the code from this link RCTSRWebSocket.m and past it to my
RCTSRWebSocket.m
for fixing this issue?dd209bb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@truongluong1314520 Yes, you can just copy it!
dd209bb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @zhongwuzw,
As an FYI, I have patched this file in my own React project (0.57.7) and rebuilt from Xcode, and it did not fix the problem. I still see my iPhone crashing on
com.squareup.SocketRocket.NetworkThread (XX): signal SIGABRT
after some inactivity (and Xcode's debugger definitely breakpoints to the new version of the file when the crash occurs).dd209bb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@silvainSayduck Sorry if it not solve your problem, can you upgrade the version of react native? If it still has, please open an issue that we can try to fix it.
dd209bb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your answer :)
Unfortunalely, I use a package that specifically requires 0.57.7, so until they update it to support the latest version of RN, I do not dare do it myself... But I will let you know as soon as it happens!