perf: reduce cache work and keep catalogue artwork loading - #34
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe update adds scoped sharing for remote artwork transfers, asynchronous Home snapshot preparation and ordered persistence, and startup checks that await prefetch results. It also changes catalogue artwork retention and paging to follow visible rows, and adds tests for these behaviours. ChangesHome Cache and Startup
Shared Artwork Transfers
Catalogue Artwork Window
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~55 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant StartupCaller
participant StartupContentPrefetcher
participant TVHomeMetadataCache
StartupCaller->>StartupContentPrefetcher: await authenticated content prefetch
StartupContentPrefetcher->>TVHomeMetadataCache: prepare snapshot
TVHomeMetadataCache-->>StartupContentPrefetcher: preparation result
StartupContentPrefetcher-->>StartupCaller: return whether startup can continue
sequenceDiagram
participant ImageRequest
participant VividImageDataFlights
participant URLSession
ImageRequest->>VividImageDataFlights: request bytes for URL and cache scope
VividImageDataFlights->>URLSession: start or join shared transfer
URLSession-->>VividImageDataFlights: return response data
VividImageDataFlights-->>ImageRequest: return data or cancellation
Merge Risk: 🔵 Low · up to The artwork cancellation test can fail intermittently on a slow runner. Make its synchronization deterministic; the remaining risk is limited to test reliability. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The changes affect account-scoped cached content and startup behavior, so they warrant review. The examined paths retain separate account and profile scopes and guard against stale work during account changes; no introduced security issue was established. Some recovery and security coverage remains incomplete. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 11.63% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 86 functions across 17 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: blurbery/vivid/.coderabbit.yaml
Review profile: ASSERTIVE
Plan: Advanced
Run ID: d43aa176-8a47-45f3-bc99-dede268d955e
📒 Files selected for processing (19)
docs/apple-tv-browsing.mddocs/apple-tv-focus.mdiosApp/Tests/CachePerformanceTests.swiftiosApp/Tests/HomeMetadataPreparationTests.swiftiosApp/Tests/ImageDataCoalescingTests.swiftiosApp/Tests/VividImageRetryTests.swiftiosApp/iosApp/ContentView.swiftiosApp/iosApp/Screens/Profiles/ProfileSelectionViewModel.swiftiosApp/iosApp/Shared/VividCacheScope.swiftiosApp/iosApp/Shared/VividImagePipeline.swiftiosApp/iosApp/Startup/StartupContentPrefetcher.swiftiosApp/iosApp/tvOS/Caching/CachedAsyncImage.swiftiosApp/iosApp/tvOS/Caching/HomeMetadataWriter.swiftiosApp/iosApp/tvOS/Caching/TVHomeMetadataCache.swiftiosApp/iosApp/tvOS/Profiles/TVLoginPreparation.swiftiosApp/iosApp/tvOS/Profiles/TVSavedAccountStore.swiftiosApp/iosApp/tvOS/Screens/Components/TVCatalogGrid.swiftiosApp/iosApp/tvOS/Screens/Components/TVMediaCard.swiftscripts/tests/startup-recovery-tests.py
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
|
I also checked the docstring coverage warning. I am leaving the blanket 80% target suggestion unchanged: the ordering, cancellation and cache compatibility rules already have targeted comments and updated guides. Adding docstrings to every internal helper and test would not improve the behaviour or clarify a missing contract identified by this review. No review settings were changed. |
|
@coderabbitai review |
|
Problem and reproduction
Browsing repeatedly recalculated identical artwork cache keys, queued intermediate Home snapshots and could download the same artwork separately for different consumers. Home also read and decoded its saved snapshot synchronously during startup.
On Apple TV, scrolling farther down Movies or Series could leave blank posters after the focus highlight disappeared. The artwork window followed the remembered focus position after it had left the viewport, and cards replaced their image subtree when leaving that window.
Implementation and impact
General Settings metadata save/clear controls, cache formats, image dimensions, retry limits and playback configuration are preserved. Account changes, clears and deletions invalidate stale preparation and save callbacks. Dependencies and release settings are unchanged.
Validation
03d7387): All six artwork tests passed in the focused macOS harness after replacing timing assumptions with held responses and observed waiter counts. They also passed with consumers deliberately delayed by 250 ms. Source comparison confirmed that application code outside the two read-only Debug observers is unchanged; a standalone optimised pipeline object excluded both observer symbols. Both the iOS test suite and tvOS simulator build passed in Player regression for this exact follow-up commit.python3 scripts/tests/startup-recovery-tests.py --platform ios --compile-onlyand the same command with--platform tvos --compile-only. These compile the extracted startup flows; no simulator UI was launched.VividTVRelease app and Top Shelf build with Xcode 27.0, signing/shared-login identity checks, and verification that the existing native audio fix remained linked. The app was installed in place and launched successfully.git diff --check. The iOS suite and tvOS simulator build also passed in the remote Player regression workflow for03d7387; those results are separate from the local checks above.Performance
There is no controlled before/after measurement of app startup time, FPS, memory, CPU or live-server traffic, so this PR makes no percentage speed-up claim.
Testing status
0e7f653393294f53860ce61e6f8ce27abcaebe54. The device build used the same application sources before committing, version0.14.3 (40). Review follow-up03d7387363df75e57519d3692d51afb500245564changes tests and adds Debug-only observers; it has no Release behaviour change.Design impact and approval
Documentation impact
Updated the existing Apple TV browsing and focus guides for cache preparation, shared artwork transfers, cancellation and catalogue warming.
AI disclosure
Implemented these changes with Codex as a tool.