Skip to content
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

End of Year: preload stories #471

Merged
merged 10 commits into from
Nov 2, 2022
Merged

End of Year: preload stories #471

merged 10 commits into from
Nov 2, 2022

Conversation

leandroalonso
Copy link
Member

📘 Project: #376

To provide a better experience for the users, the app preloads the next 2 stories. The assets that are preloaded are:

  1. Image covers
  2. Podcast colors

Those are requested if they do not exist, and they are requests only once (images by using Kingfisher and colors by using the current ColorManager).

This also changes how the StoriesView is rendered to avoid Stories being re-created hundreds of time.

To test

Playing stories without skipping to next/previous

  1. Enable the endOfYear flag in FeatureFlag.swift
  2. Do a fresh install of the app
  3. Login to an account with a few items on Listening History
  4. Use a tool like Network Link Conditioner to change the speed of your connection (to 3G, for example)
  5. When the prompt appears, tap "View My 2022"
  6. ✅ Leave the stories to play and check that most stuff should be ready when the stories appear

Skipping

  1. Enable the endOfYear flag in FeatureFlag.swift
  2. Do a fresh install of the app
  3. Login to an account with a few items on Listening History
  4. Use a tool like Network Link Conditioner to change the speed of your connection (to 3G, for example)
  5. When the prompt appears, tap "View My 2022"
  6. ✅ Quickly goes to the next story and you should be able to see that the background is opaque but once colors are downloaded it changes

Number of Stories View

A bit of context: StoriesModel had the progress property as a published one. Each time that changed, StoriesView was invalidated and re-rendered again. In turn, this caused the current story to be invalidated and re-rendered again.

In terms of allocation, this wasn't a big problem because the views are mainly structs, but the CPU usage was going up due to the view being invalidated every 0.01s.

I moved the progress to another object that is used only by the progress indicators, now the StoriesView is only invalidated when the current story changes.

To test:

  1. Enable the endOfYear flag in FeatureFlag.swift
  2. Run the app and make sure you're logged in to an account with a few items on Listening History
  3. Run Instruments > Allocations and start recording the current Pocket Casts instance
  4. Add "Story" to the "Detail Filter"
  5. Check that only 1 to 2 total Story views area created

Checklist

  • I have considered if this change warrants user-facing release notes and have added them to CHANGELOG.md if necessary.
  • I have considered adding unit tests for my changes.
  • I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics.

@leandroalonso leandroalonso added the [Project] End of Year 2023 End of Year project label Nov 1, 2022
@leandroalonso leandroalonso added this to the Future milestone Nov 1, 2022
@leandroalonso leandroalonso requested a review from a team as a code owner November 1, 2022 13:48
@leandroalonso leandroalonso mentioned this pull request Nov 1, 2022
36 tasks
Base automatically changed from task/376-top-categories to trunk November 2, 2022 15:04
Copy link
Contributor

@emilylaguna emilylaguna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, left some comments to clean up a few items and an idea for default colors.

None of them are blockers though.

podcasts/End of Year/Stories/DynamicBackgroundView.swift Outdated Show resolved Hide resolved
podcasts/End of Year/Stories/DynamicBackgroundView.swift Outdated Show resolved Hide resolved
podcasts/End of Year/Views/StoryIndicator.swift Outdated Show resolved Hide resolved
@leandroalonso leandroalonso merged commit 415c1a3 into trunk Nov 2, 2022
@leandroalonso leandroalonso deleted the task/376-preload-stories branch November 2, 2022 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Project] End of Year 2023 End of Year project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants