-
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
Observing elements on main thread after calling dispose on main thread #1778
Comments
Hi @stephan7 ,
This is not a self contained case. Self contained case means that I can copy the code, run it, and it will demonstrate the issue. If you can post self contained code sample, I can take a look. |
Hi @kzaher , Thanks for taking a look. You are right, some glue code is missing, sry. Here a complete example:
Run it on a device or on a simulator. In the console of Xcode you should see something like this:
I can also provide a complete Xcode project if that is helpful. |
Hi @stephan7 , yes, you are correct, this is a bug. |
Hi, Very cool and thanks for the fast fix. I can confirm that the bug is now fixed. (For testing I simply changed the Podfile to the corresponding commit:
) |
First of all many thanks for your incredible work regarding RxSwift.
Short description of the issue:
Setup scenario:
-> sometimes emissions on main thread happens after dispose is called on main thread
Expected outcome:
Intuitively, I would expect that if I call dispose on the same thread where I also observe that after disposing no further elements are emitted then.
I looked through the issues section and found this:
see here
#38
What actually happens:
Sometimes emissions on main thread happens after dispose is called on main thread.
Self contained code example that reproduces the issue:
A self-contained test case of another user can be found on Stackoverflow: https://stackoverflow.com/questions/51856962/dispose-cancel-observable-subscribeon-and-observeon-different-schedulers
Just change the line
if !strongSelf.isCancelled {
there toif strongSelf.isCancelled {
(without negation).Check missing?:
Searching through the code I found that in the class ObserveOnSerialDispatchQueueSink there is cachedScheduleLambda. One could add a test there for !self.cancel.isDisposed. That would prevent above mentioned emissions after a dispose happened.
But I have to admit that I don't understand RxSwift's internal processes enough to judge whether this could be a proper fix.
Or maybe there are even good reasons for it and the behavior is so intentional.
RxSwift/RxCocoa/RxBlocking/RxTest version/commit
4.2.0
Platform/Environment
How easy is to reproduce? (chances of successful reproduce after running the self contained code)
Xcode version:
Installation method:
I have multiple versions of Xcode installed:
(so we can know if this is a potential cause of your issue)
The text was updated successfully, but these errors were encountered: