Fix crash for web socket in some race conditions (#22439)
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: https://github.com/facebook/react-native/pull/22439

Differential Revision: D13564247

Pulled By: cpojer

fbshipit-source-id: 675c1b2805aa45c54d7708d796f5843ef7ea34e2

janicduplessis/react-native,hammerandchisel/react-native,janicduplessis/react-native,arthuralee/react-native,javache/react-native,myntra/react-native,exponent/react-native,facebook/react-native,facebook/react-native,myntra/react-native,javache/react-native,myntra/react-native,exponentjs/react-native,hoangpham95/react-native,exponentjs/react-native,facebook/react-native,exponentjs/react-native,exponentjs/react-native,arthuralee/react-native,arthuralee/react-native,exponentjs/react-native,javache/react-native,arthuralee/react-native,hoangpham95/react-native,janicduplessis/react-native,facebook/react-native,pandiaraj44/react-native,hoangpham95/react-native,exponent/react-native,javache/react-native,exponentjs/react-native,pandiaraj44/react-native,pandiaraj44/react-native,janicduplessis/react-native,hammerandchisel/react-native,javache/react-native,hammerandchisel/react-native,exponent/react-native,janicduplessis/react-native,exponent/react-native,janicduplessis/react-native,hammerandchisel/react-native,exponent/react-native,hammerandchisel/react-native,facebook/react-native,pandiaraj44/react-native,pandiaraj44/react-native,facebook/react-native,myntra/react-native,hoangpham95/react-native,exponent/react-native,myntra/react-native,javache/react-native,myntra/react-native,facebook/react-native,exponentjs/react-native,myntra/react-native,hoangpham95/react-native,janicduplessis/react-native,exponentjs/react-native,hammerandchisel/react-native,arthuralee/react-native,pandiaraj44/react-native,hammerandchisel/react-native,janicduplessis/react-native,hoangpham95/react-native,javache/react-native,exponent/react-native,pandiaraj44/react-native,hoangpham95/react-native,hammerandchisel/react-native,exponent/react-native,javache/react-native,facebook/react-native,hoangpham95/react-native,javache/react-native,myntra/react-native,myntra/react-native,pandiaraj44/react-native,facebook/react-native