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 another setupPlaceholder && 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
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