Fix the nil url always returns Error will cause infinity onAppear
call and image manager to load, which waste CPU
#235
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.
closing #234
Background
This is because the fixed-point logic driver by SwiftUI, will recursivelly trigger placeholder's
onAppear
(because v2.2.0 use UUID as ID for placeholder), and trigger the ImageManager to load and always failed immediately, trigger another else condition in View.body, and anothersetupPlaceholder && ImageManager load
, finally may consuming CPU because it's un-ended.This fix use the URL as ID, if the nil url is provided, only one
onAppear
will trigger, so it's end.Tips
Also, I think the nil URL design is a bad design for SwiftUI, but good design for UIKit.
Although it's introduced from #2 , may removed in the future