-
Notifications
You must be signed in to change notification settings - Fork 114
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
Crash: Simultaneous accesses, but modification requires exclusive access #257
Comments
Updated to 3.17.0 (it's not on CocoaPods so switched it to SPM), still the same problem. |
Same problem here :( If i remove the subject.send(completion: .finished) from the Property.deinit the crash goes away. |
Ignore my previous reaction. Was my own fault. |
My assumption is that these are valid problems caused by the way ReactiveKit is used, caused by reasons like @TeunVR had. For example mutating a property that trigged the event from the observer or binding of that property is not a valid usage and is expected to throw a simultaneous accesses error. |
Yeah turns out merely referencing the property inside an observer is enough to crash once it's disposed. Fixed, thanks for clarifiying. |
Not sure where my problem could come from. My VC is something like this: class ReportsContainerViewController: UIViewController {
private let viewModel = ReportsViewModel()
private func setupBindings() {
viewModel.statusSignal.bind(to: self) { vc, status in
// Do things
}
}
} Now, the crash happens when the user logs out: that results in the root window's |
Okay, I found the problem. This is my ViewModel: class ReportsViewModel {
enum Status {
case loading
case loaded(data: ReportData)
case error(error: ReportsViewModelError)
}
public var period = Property<ReportPeriod>(ReportPeriod(rawValue: 0))
public var statusSignal: Signal<Status, Never> {
return period.removeDuplicates().flatMapLatest(getData)
}
private let urlCache: URLCache
private let sessionManager: SessionManager
init() {
urlCache = URLCache(memoryCapacity: 20 * 1024 * 1024, diskCapacity: 200 * 1024 * 1024, diskPath: nil)
let configuration = URLSessionConfiguration.default
configuration.requestCachePolicy = .returnCacheDataElseLoad
configuration.urlCache = urlCache
configuration.timeoutIntervalForRequest = 15
sessionManager = Alamofire.SessionManager(configuration: configuration)
}
private func getData(period: ReportPeriod) -> Signal<Status, Never> {
// ...
}
} If I change the class ReportsViewModel {
enum Status {
case loading
case loaded(data: ReportData)
case error(error: ReportsViewModelError)
}
public var period = Property<ReportPeriod>(ReportPeriod(rawValue: 0))
public var statusSignal: Signal<Status, Never>!
private let urlCache: URLCache
private let sessionManager: SessionManager
init() {
urlCache = URLCache(memoryCapacity: 20 * 1024 * 1024, diskCapacity: 200 * 1024 * 1024, diskPath: nil)
let configuration = URLSessionConfiguration.default
configuration.requestCachePolicy = .returnCacheDataElseLoad
configuration.urlCache = urlCache
configuration.timeoutIntervalForRequest = 15
sessionManager = Alamofire.SessionManager(configuration: configuration)
statusSignal = period.removeDuplicates().flatMapLatest(getData)
}
private func getData(period: ReportPeriod) -> Signal<Status, Never> {
// ...
}
} The reason why I did it like the first way first, was because I was getting |
ReactiveKit 3.16.3 (via Cocoapods).
Xcode 11.3.1
iOS 13.3
The text was updated successfully, but these errors were encountered: