-
Notifications
You must be signed in to change notification settings - Fork 10
speeding up the gallery, a bit #720
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
base: master
Are you sure you want to change the base?
Conversation
by serializing json off of the main thread
by prefetching gallery's thumbnails
theospears
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this is needed! Added a few questions, but also happy to merge as-is if you think this is the best approach.
| let goal = fetchedResultsController.object(at: indexPath) | ||
| return try? goal.thumbUrl.asURL() | ||
| } | ||
| let downloader = ImageDownloader.default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently GoalImageView has its own static ImageDownloader. Should we be either having this code use that downloader, or moving that to use the default one? I'm not sure if multiple instances share cache between them?
| case .success(let data): | ||
| let asJSON = try? JSONSerialization.jsonObject(with: data) | ||
| return asJSON | ||
| case .success(let data): return try await Task.detached { try JSONSerialization.jsonObject(with: data) }.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are your thoughts on this solution vs making RequestManager an actor so all its work is done on a background thread?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching it over to actor seems like a more complete solution.
Summary
Upon returning to the gallery, especially after bring the app back into the foreground, scrolling the gallery can be very choppy.
This PR reduces some of the lagginess by moving json serializing off of the main thread and by prefetching the gallery's thumbnails.
Validation
Used app in Simulator
#588 mentioned a slow gallery.