Skip to content

Fix the nil url always returns Error will cause infinity onAppear call and image manager to load, which waste CPU #235

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

Merged
merged 1 commit into from
Sep 23, 2022

Conversation

dreampiggy
Copy link
Collaborator

@dreampiggy dreampiggy commented Sep 23, 2022

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 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

…all and image manager to load, which waste CPU

Instead, use url as identity to avoid this
@dreampiggy dreampiggy merged commit 53ac75c into master Sep 23, 2022
@dreampiggy dreampiggy added this to the 2.2.1 milestone Sep 23, 2022
@dreampiggy dreampiggy added the webimage WebImage struct label Sep 23, 2022
@dreampiggy dreampiggy linked an issue Sep 23, 2022 that may be closed by this pull request
@dreampiggy dreampiggy deleted the fix_nil_url_fixed_point branch September 2, 2023 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
webimage WebImage struct
Projects
None yet
Development

Successfully merging this pull request may close these issues.

V2.2.0 iOS 16.0 cpu up to 100%
1 participant