mirror of
git://jb55.com/damus
synced 2024-09-30 00:40:45 +00:00
26d2627a1c
This commit implements a simple but functional video cache. It works by providing a method called `maybe_cached_url`, where a video URL can be passed in, and this method will either return the URL of a cached version of this video if available, or the original URL if not. It also downloads new video URLs on the background into the cache folder for use next time. Functional testing ------------------- PASS Device: iPhone 15 simulator iOS: 17.4 Damus: Approximately this commit Setup: - Debug connection - Expiry time locally changed to 5 minutes Steps: 1. Basic functionality 1. Go to a profile with lots of videos 2. Scroll down 3. Filter logs to only logs that start with "Loading video with URL" 4. Check that most videos are being loaded from external URLs. PASS 5. Now restart the app and go to that same profile 6. Scroll down and watch logs. Videos should now be loaded with an internal file URL. PASS 2. Automatic cache refresh after expiry 1. Go to the video-heavy profile, make note of the external URL. 2. Go to a different screen and then come back to that video. Make sure the file was loaded from cache. PASS 3. Now go to a different screen and wait 5 minutes. 4. Come back to the same video. It should be loaded from the external URL. PASS 3. "Clear cache" button functionality 1. Go to the video-heavy profile, make note of the external URL. 2. Go to a different screen and then come back to that video. Make sure the file was loaded from cache. PASS 3. Now quit the app (to ensure file is not in use when trying to delete it) 4. Clear cache in settings 5. Go back to the same video. It should now be loaded from the external URL. PASS Performance testing ----------------------- Device: iPhone 13 mini iOS: 17.3.1 Damus: This commit Baseline: 87de88861adb3b41d73998452e7c876ab5ee06bf Setup: - Debug connection - Expiry time locally changed to 5 minutes - Running on Profile mode, with XCode Instruments Steps: 1. Start recording network activity with XCode Instruments 2. Go to a video-heavy profile (e.g. Julian Figueroa) 3. Scroll down to a specific video (Make sure to scroll through at least 5 videos) 4. Stop recording and measure the "Bytes In" from "Network connections" 5. Repeat this for all test configurations Results: - Baseline (No caching support): 26.74 MiB - This commit (First run, cleared cache): 40.52 MiB - This commit (Second run, cache filled with videos): 8.13 MiB Automated test coverage ------------------------ PASS Device: iPhone 15 simulator iOS: 17.4 Damus: This commit Coverage: - Ran new automated tests multiple times. PASS 3/3 times - Ran all other automated tests. PASS Signed-off-by: Daniel D’Aquino <daniel@daquino.me> Link: 20240411004129.84436-3-daniel@daquino.me Signed-off-by: William Casarin <jb55@jb55.com> |
||
---|---|---|
.. | ||
__Snapshots__/EventViewTests | ||
Assets | ||
Mocking | ||
Models | ||
Util | ||
AuthIntegrationTests.swift | ||
Bech32ObjectTests.swift | ||
Bech32Tests.swift | ||
ContentParserTests.swift | ||
DamusCacheManagerTests.swift | ||
DamusPurpleImpendingExpirationTests.swift | ||
damusTests.swift | ||
DMTests.swift | ||
EventGroupViewTests.swift | ||
EventViewTests.swift | ||
FormatTests.swift | ||
HashtagTests.swift | ||
ImageMetadataTest.swift | ||
InvoiceTests.swift | ||
KeychainStorageTests.swift | ||
LikeTests.swift | ||
ListTests.swift | ||
LocalizationUtilTests.swift | ||
LongPostTests.swift | ||
NIP19Tests.swift | ||
NostrEventTests.swift | ||
NostrScriptTests.swift | ||
NoteContentViewTests.swift | ||
PostViewTests.swift | ||
ProfileViewTests.swift | ||
RelayPoolTests.swift | ||
RelayURLTests.swift | ||
ReplyDescriptionTests.swift | ||
ReplyTests.swift | ||
RequestTests.swift | ||
TimeAgoTests.swift | ||
TranslationTests.swift | ||
TrieTests.swift | ||
UrlTests.swift | ||
UserSearchAppendTests.swift | ||
UserSearchCacheTests.swift | ||
VideoCacheTests.swift | ||
WalletConnectTests.swift | ||
ZapTests.swift |