Open alexeystrakh opened 1 year ago
In order for this to happen, something needs to be returning a positive, non-zero, value from numberOfRowsInSection
(tableViewDataSourceNotSet
returns 0 in this function) then whatever data source is returning that non-zero value is being removed so that tableViewDataSourceNotSet
's cellForRowAt
gets called.
Apple made some internal changes to how table views work (i.e., added a bug to table views) recently, which is fixed in the latest version of RxCocoa... Your error doesn't seem to be related to that issue, but it is a good idea for you to update to the latest versions of RxSwift and RxCocoa.
Note that your code sample is not self-contained. Also note that this issue is also being discussed here (https://stackoverflow.com/questions/75952981/rxcocoa-rxswift-crash-when-accessing-tableviewdatasourcenotset-tableview-cellf)
@alexeystrakh Any solutions for this? I am facing the same crashes in my firebase dashboard
Can one of you create self-contained code sample?
I can work on the self-contained code sample but see no value in it, because the code follows the guidelines and works in 99.99% cases. Basically when you run it, you wont see any crashes and most likely won't be able to reproduce. I believe the issue is in either UIKit or RxCocoa as the stack trace points there as should be handled respectively.
Meanwhile, I will create a sample project to reflect the code structure and the rx bindings.
Since this has never come up before in the past 8 years, either you are doing something wrong, or Apple has indeed changed something inside UIKit (this wouldn't be the first time they've done that) or there is a specific issue within Firebase.
So questions:
Can you provide analytics that can answer the first question? Can you remove Firebase from the equation to see if that fixes the problem?
Here we go, the self-contained solution: https://github.com/alexeystrakh/rxswift-tablecrash
What version(s) of iOS are experiencing these crashes?
iOS 15 and iOS 16 (foreground only)
Are these sorts of crashes happening even when Firebase is not involved?
Without Firebase it will be hard to say, because they are only reported by Firebase, I cannot reproduce them locally.
For me, the Firebase crash analysis is attached below for the iOS versions
@danielt1263 where you able to confirm an issue or find some workaround for this crash?
I was not.
Short description of the issue:
I'm using RxCocoa and RxSwift to render a UITableView against an array provided by a BehaviorRelay. The code to bind the data is below. In most cases it works just fine but in some rare cases which I cannot reproduce the app crashes with the following stacktrace, reported by a few Firebase uses:
The crash is hard to reproduce (I wasn't able to) but it's affects multiple users. The
bindData
method is called once atviewDidLoad
, and I callloadData
on every page appearance (willAppear, return back from another page or app activation deactivation) but it's not clear why it crashes and how to reproduce/fix it.The crash is coming from
TableViewDataSourceNotSet
which seems to be set by the RxCocoa/RxSwift framework and crashes when cell for an item is requested. I'm not setting that custom dataSource explicitly anywhere. Any ideas how I can prevent this from happening?Expected outcome:
App renders the table and no crashes are reported by users in Firebase
What actually happens:
App renders the table but a few users report crashes
TableViewDataSourceNotSet
Self contained code example that reproduces the issue:
RxSwift/RxCocoa/RxBlocking/RxTest version/commit
v5.1.1
Platform/Environment
How easy is to reproduce? (chances of successful reproduce after running the self contained code)
Xcode version:
:warning: Fields below are optional for general issues or in case those questions aren't related to your issue, but filling them out will increase the chances of getting your issue resolved. :warning:
Installation method:
I have multiple versions of Xcode installed: (so we can know if this is a potential cause of your issue)
Level of RxSwift knowledge: (this is so we can understand your level of knowledge and formulate the response in an appropriate manner)