Skip to content
Permalink
Browse files
WebM file fail to play
https://bugs.webkit.org/show_bug.cgi?id=242854
<rdar://97190939>

Reviewed by Eric Carlson.

If a track is disabled because it contains no data, the AV MediaPlayer will
flag the content as not playable even though it will play.

We can't properly test this change for the failing file as we rely on the
MediaFormatReader plugin to decode WebM which isn't available on the EWS bots.

* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::allTracksArePlayable const):
(WebCore::MediaPlayerPrivateAVFoundationObjC::containsDisabledTracks const):
(WebCore::MediaPlayerPrivateAVFoundationObjC::assetStatus const):

Canonical link: https://commits.webkit.org/254219@main
  • Loading branch information
jyavenard committed Sep 7, 2022
1 parent a966c84 commit af6020b7b7f9b44ef5db6c7b77c54251b25a0a68
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
@@ -357,6 +357,7 @@ class MediaPlayerPrivateAVFoundationObjC final : public MediaPlayerPrivateAVFoun
void checkNewVideoFrameMetadata();

std::optional<bool> allTracksArePlayable() const;
bool containsDisabledTracks() const;
bool trackIsPlayable(AVAssetTrack*) const;

RetainPtr<AVURLAsset> m_avAsset;
@@ -1834,12 +1834,30 @@ static URL conformFragmentIdentifierForURL(const URL& url)
return std::nullopt;

for (AVAssetTrack *assetTrack : [m_avAsset tracks]) {
if (!trackIsPlayable(assetTrack))
if ([assetTrack isEnabled] && !trackIsPlayable(assetTrack))
return false;
}
return true;
}

bool MediaPlayerPrivateAVFoundationObjC::containsDisabledTracks() const
{
if (m_avPlayerItem) {
for (AVPlayerItemTrack *track in [m_avPlayerItem tracks]) {
if (![track isEnabled])
return true;
}
return false;
}

ASSERT(m_avAsset);
for (AVAssetTrack *assetTrack : [m_avAsset tracks]) {
if (![assetTrack isEnabled])
return true;
}
return false;
}

bool MediaPlayerPrivateAVFoundationObjC::trackIsPlayable(AVAssetTrack* track) const
{
if (player()->shouldCheckHardwareSupport() && !assetTrackMeetsHardwareDecodeRequirements(track, player()->mediaContentTypesRequiringHardwareSupport()))
@@ -1926,7 +1944,7 @@ static URL conformFragmentIdentifierForURL(const URL& url)
}

if (!m_cachedAssetIsPlayable)
m_cachedAssetIsPlayable = [[m_avAsset valueForKey:@"playable"] boolValue];
m_cachedAssetIsPlayable = [[m_avAsset valueForKey:@"playable"] boolValue] || containsDisabledTracks();

if (*m_cachedAssetIsPlayable && *m_cachedTracksArePlayable)
return MediaPlayerAVAssetStatusPlayable;

0 comments on commit af6020b

Please sign in to comment.