-
Notifications
You must be signed in to change notification settings - Fork 39
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
Reentrancy anomaly detected when using KingfisherManager #20
Comments
I think the issue isn't in the method, it's outside of it. Can you show the method that invoked getImage? |
Hi @freak4pc , thanks for answering me back. The code above, belongs to the ImageInteractor class, which handles the image requests. if let imagePath = $0.categoryLink?.image {
iconImage = imageInteractor.getImage(with: imagePath)
}
return IncidentViewModelItem(incidentId: $0.id,
iconImage: iconImage,
title: $0.name,
stages: []) And then, I'm setting up a tableview cell with the object internal var disposeBag = DisposeBag()
override func prepareForReuse() {
super.prepareForReuse()
disposeBag = DisposeBag()
}
func setup(viewModel: IncidentViewModelItem) {
self.viewModel = viewModel
viewModel.iconImage?
.subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background))
.observeOn(MainScheduler.asyncInstance)
.subscribe(onSuccess: { [weak self] (image) in
self?.iconImageView.image = image
}).disposed(by: disposeBag)
} |
Unfortunately I don't have the full picture, yet. Regardless, this isn't an issue with RxKingfisher as far as I can tell since it works on the "happy path", so it's just some issue with scheduling / other code that you have there which I can't see |
I'm not using this library but have an ~identical implementation wrapping KingfisherManager and downloading an image. I found that the task getting cancelled causes a re-entrancy anomaly. I've debugged a few re-entrancy anomalies before but I'm struggling to figure out why cancelling the task does it here. I'm not sure if it's the same thing @PabloDomine is experiencing but figured I'd add my info here just in case it helps. Commenting out the In the stack, I notice that the error block had been called several frames before task.cancel() gets called, which must be what's causing the unwanted cycle. |
Ah okay, I think I figured out what's going on here. If a task is cancelled, it appears that the error block is called twice in the same run loop – once for the request timing out, and once for the task being cancelled. I think the right approach here to only send error states when the error is not the task being cancelled (for this use case I don't think we would ever want that.) I don't think there are any downsides to filtering out task cancelled errors, but maybe someone can back me up on that. I'll put up a quick PR with a fix and we can use that to have further discussion if that's helpful! |
Thank you for stepping in @eliotfowler and sorry for the radio silence. |
I'm trying to retrieve an image using the KingfisherManager like so:
When the image is not valid, for example:
I get the following error:
With the following log, depending on which error I had. For example, in case it's a svg image:
I tried to silence the Reentrancy anomaly warning adding
.observeOn(MainScheduler.asyncInstance)
but it won't work.Could this be in issue when detecting an error in the RxKingfisher library?
Thank you!
The text was updated successfully, but these errors were encountered: