-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
take(1)
+ share(replay: 1)
+ zip
= deadlock
#2653
Comments
I'm glad you posted this @isaac-weisberg I've been wanting to explain what's going on since your "lmao" post on another issue that shows effectively the same behavior (and for the same reason.) RxSwift is not, and has never been, asynchronous by default. If you don't introduce asynchronous behavior, then it will be completely synchronous. Your You can solve this by introducing asynchronous behavior on your You can also solve this by moving the Frankly, I don't run into these sorts of problems because I don't wrap synchronous work in Observable contexts like you did in your |
Yeah... I mean, what other answer could I have expected here. This library has some... you know... |
It's what makes the library so easily testable. No need for async tests and test expectations. But yea, if you are inconsistent when introducing async behavior you will run into problems. In production code. There is no need for something like your |
Like your previous post - you show nothing but disrespect for the time and work of people whose help you asked for. Daniel has spent a massive amount of time and kindness to explain the limitations. If this library doesn't suit your needs, feel free to stop using it. We'll hopefully still be able to afford our daily life after losing a customer 🥲 (of this entirely open-source, volunteer-based framework) If you are using it and need help, the way you're doing it in your last two posts isn't a way of getting it. Good luck, and I'm locking this thread, too. |
Hey, guys. I have uncovered that there is a situation where you can easily cause RxSwift do deadlock.
I have prepared a repo with 100% reproduction rate of this feature.
It is caused by the fact that:
take(1)
emits.completed
zip
starts unsubscribing fromsource
when it sees.completed
share(replay: 1)
synchronizes the unsubscribing under it's own lockshare(replay: 1)
replays the stored element under this very same lock.completed
event becausetake(1)
zip
, which will try to unsubscribe from sourceshare(replay: 1)
In this deadlock situation, there are always 2 threads that get stuck:
zip
, and tries to lock onshare(replay: 1)
to unsubshare(replay: 1)
to replay an event, and tries to lock onzip
If one thing happens earlier than the other in a concurrent environment, then they will deadlock.
Here's a link to my repository that reproes this issue, just build, Cmd+R, it's raw Xcodeproj with SPM:
https://github.com/isaac-weisberg/RxSwiftDeadlock
Separate thanks I would like to say to @firecore and specifically this issue: #2525 - one of the problems described in this issue is definitely related!
The text was updated successfully, but these errors were encountered: