Comments (6)
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!
from rxkingfisher.
I think the issue isn't in the method, it's outside of it. Can you show the method that invoked getImage?
from rxkingfisher.
Hi @freak4pc , thanks for answering me back.
The code above, belongs to the ImageInteractor class, which handles the image requests.
I'm creating the observable, without subscribing, using the method getImage
:
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 IncidentViewModelItem
I created.
In the tableview cell, I'm subscribing: (I put only the code that relates to Rx)
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)
}
from rxkingfisher.
Unfortunately I don't have the full picture, yet.
But - the fact it only happens for token refreshals probably means the reentraancy is caused by the fact getImage invokes a token refresh which invokes getImage again, which is sort of a reentrancy, but it's really hard to say.
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
from rxkingfisher.
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 task?.cancel()
in the Disposables.create { }
block fixes the issue, but is not ideal because then the resource is retrieved even when the subscription has been disposed.
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.
from rxkingfisher.
Thank you for stepping in @eliotfowler and sorry for the radio silence.
Unfortunately, I cannot test this issue under the same exact conditions anymore, since the API has changed and it's not longer returning vectorial images, but regular .jpg's.
If I have time, I will try to try this again in a different environment.
Thank you again @freak4pc and @eliotfowler!
from rxkingfisher.
Related Issues (14)
- Generic parameter 'Self' could not be inferred after Kingfisher 5.0 update HOT 2
- Cannot invoke 'bind' with an argument list of type '(to: Binder<Resource?>)' HOT 7
- Do not compile because of `Use of undeclared type 'Image'` HOT 3
- Dependency version conflicts in Carthage HOT 1
- Allow Resource to be nil HOT 4
- RxSwift 6 support HOT 1
- sdwebimage? HOT 1
- Kingfisher 6 not supported HOT 1
- 'rx' is inaccessible due to 'internal' protection level HOT 1
- Update Cartfile to support Kingfisher v6 HOT 1
- Fish
- 2.1.0 is dependency Kingfisher ~> 7 not ~> 5
- Not support with Kingfisher 5 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxkingfisher.