Bug 209341 - Ensure media cache directory is created before passing to AVURLAsset.
Summary: Ensure media cache directory is created before passing to AVURLAsset.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jer Noble
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-03-20 09:08 PDT by Jer Noble
Modified: 2020-03-20 15:36 PDT (History)
6 users (show)

See Also:


Attachments
Patch (2.66 KB, patch)
2020-03-20 09:13 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch (7.72 KB, patch)
2020-03-20 10:07 PDT, Jer Noble
eric.carlson: review+
Details | Formatted Diff | Diff
Patch for landing (7.75 KB, patch)
2020-03-20 11:14 PDT, Jer Noble
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jer Noble 2020-03-20 09:08:12 PDT
Ensure media cache directory is created before passing to AVURLAsset.
Comment 1 Jer Noble 2020-03-20 09:10:11 PDT
<rdar://51539885>
Comment 2 Jer Noble 2020-03-20 09:13:12 PDT
Created attachment 394089 [details]
Patch
Comment 3 Eric Carlson 2020-03-20 09:28:33 PDT
Comment on attachment 394089 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394089&action=review

> Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:850
>      bool usePersistentCache = player()->shouldUsePersistentCache();
>      [options setObject:@(!usePersistentCache) forKey:AVURLAssetUsesNoPersistentCacheKey];
>      
> -    if (usePersistentCache)
> -        [options setObject:assetCacheForPath(player()->mediaCacheDirectory()) forKey:AVURLAssetCacheKey];
> +    if (usePersistentCache) {
> +        auto mediaCacheDirectory = player()->mediaCacheDirectory();
> +        if (FileSystem::fileIsDirectory(mediaCacheDirectory, ShouldFollowSymbolicLinks::Yes) || FileSystem::makeAllDirectories(mediaCacheDirectory))
> +            [options setObject:assetCacheForPath(mediaCacheDirectory) forKey:AVURLAssetCacheKey];
> +        else
> +            ASSERT_NOT_REACHED();
> +    }

As we discussed, 'usePersistentCache' should be false if 'player()->mediaCacheDirectory()' is empty
Comment 4 Jer Noble 2020-03-20 10:07:32 PDT
Created attachment 394095 [details]
Patch
Comment 5 Eric Carlson 2020-03-20 10:21:08 PDT
Comment on attachment 394095 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394095&action=review

> Source/WebKitLegacy/mac/ChangeLog:9
> +        directory by default; ensure that it's media cache directory is set during initialization.

"it's" :-O

> Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:874
>      [options setObject:@(!usePersistentCache) forKey:AVURLAssetUsesNoPersistentCacheKey];
>      
> -    if (usePersistentCache)
> -        [options setObject:assetCacheForPath(player()->mediaCacheDirectory()) forKey:AVURLAssetCacheKey];
> +    if (usePersistentCache) {
> +        if (auto* assetCache = ensureAssetCacheExistsForPath(player()->mediaCacheDirectory()))
> +            [options setObject:assetCache forKey:AVURLAssetCacheKey];
> +        else

Shouldn't we set AVURLAssetUsesNoPersistentCacheKey to NO if ensureAssetCacheExistsForPath() return nil?
Comment 6 Jer Noble 2020-03-20 11:14:13 PDT
Created attachment 394103 [details]
Patch for landing
Comment 7 EWS 2020-03-20 15:36:51 PDT
Committed r258795: <https://trac.webkit.org/changeset/258795>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 394103 [details].