Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HybridImageLoader.requestImage(forView:)kicked off an async load and then unconditionally assigned the result to the view'simageView, with no cancellation and no way to tell whether that result was still wanted.In a list, that means:
prepareForRecycle()clearing the image doesn't help, because it runs before the stale completion lands. The same happens without recycling whenever theimageprop changes mid-load and the two loads resolve out of order (easy to hit, since a cachedHybridImageLoaderresolves instantly while an uncached one doesn't).This adds a monotonic per-view request token:
beginImageRequest()starts a request and invalidates any in-flight onecancelImageRequest()invalidates without starting a new one (called fromdropImage)isImageRequestValid(token)is checked right before the result is appliedOn iOS this is exposed as a new
ImageRequestTrackingprotocol next toNativeImageView, so third-party image views can opt into it. Views that don't conform keep working exactly as before, they just don't get cancellation.react-native-nitro-web-imageis unaffected - SDWebImage and Coil already scope requests to the target view.Testing
Not verified on device - CI builds cover compilation.