Bug 178713 - [iOS] MediaPlayer::isAvailable() takes ~150 ms during web process initialization
Summary: [iOS] MediaPlayer::isAvailable() takes ~150 ms during web process initialization
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-10-23 23:48 PDT by Wenson Hsieh
Modified: 2017-10-24 10:38 PDT (History)
4 users (show)

See Also:


Attachments
Patch (1.79 KB, patch)
2017-10-23 23:56 PDT, Wenson Hsieh
eric.carlson: review-
Details | Formatted Diff | Diff
Patch (1.73 KB, patch)
2017-10-24 09:48 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2017-10-23 23:48:55 PDT
<rdar://problem/35115906>
Comment 1 Wenson Hsieh 2017-10-23 23:56:08 PDT
Created attachment 324651 [details]
Patch
Comment 2 Eric Carlson 2017-10-24 08:51:17 PDT
Comment on attachment 324651 [details]
Patch

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

> Source/WebCore/platform/graphics/MediaPlayer.cpp:961
> +#if USE(AVFOUNDATION)
> +    if (DeprecatedGlobalSettings::isAVFoundationEnabled())
> +        return true;
> +#endif

The AVFoundation and CoreMedia frameworks are not installed on a recovery partition, so this will cause HTMLMediaElement to be in the DOM but MediaPlayerPrivateAVFoundationObjC::registerMediaEngine will fail so <audio> and <video> elements won't work. You might make MediaPlayerPrivateAVFoundationObjC::isAvailable() public and call it here instead.
Comment 3 Wenson Hsieh 2017-10-24 09:01:08 PDT
(In reply to Eric Carlson from comment #2)
> Comment on attachment 324651 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=324651&action=review
> 
> > Source/WebCore/platform/graphics/MediaPlayer.cpp:961
> > +#if USE(AVFOUNDATION)
> > +    if (DeprecatedGlobalSettings::isAVFoundationEnabled())
> > +        return true;
> > +#endif
> 
> The AVFoundation and CoreMedia frameworks are not installed on a recovery
> partition, so this will cause HTMLMediaElement to be in the DOM but
> MediaPlayerPrivateAVFoundationObjC::registerMediaEngine will fail so <audio>
> and <video> elements won't work. You might make
> MediaPlayerPrivateAVFoundationObjC::isAvailable() public and call it here
> instead.

Ah, ok...I suspected there might be a case where this would fail :/

My goal is to avoid invoking MediaPlayerPrivateAVFoundationObjC::isAvailable() altogether, since that tries to dlopen() AVFoundation...I'll see if there's another way to address this. Thanks!
Comment 4 Wenson Hsieh 2017-10-24 09:42:35 PDT
(In reply to Wenson Hsieh from comment #3)
> (In reply to Eric Carlson from comment #2)
> > Comment on attachment 324651 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=324651&action=review
> > 
> > > Source/WebCore/platform/graphics/MediaPlayer.cpp:961
> > > +#if USE(AVFOUNDATION)
> > > +    if (DeprecatedGlobalSettings::isAVFoundationEnabled())
> > > +        return true;
> > > +#endif
> > 
> > The AVFoundation and CoreMedia frameworks are not installed on a recovery
> > partition, so this will cause HTMLMediaElement to be in the DOM but
> > MediaPlayerPrivateAVFoundationObjC::registerMediaEngine will fail so <audio>
> > and <video> elements won't work. You might make
> > MediaPlayerPrivateAVFoundationObjC::isAvailable() public and call it here
> > instead.
> 
> Ah, ok...I suspected there might be a case where this would fail :/
> 
> My goal is to avoid invoking
> MediaPlayerPrivateAVFoundationObjC::isAvailable() altogether, since that
> tries to dlopen() AVFoundation...I'll see if there's another way to address
> this. Thanks!

Spoke to Eric in person -- while AVFoundation and CoreMedia may not exist in recovery partitions, this is only the case on Mac. On iOS, it is generally safe to assume that AVFoundation and CoreMedia exist (otherwise, many other system apps and frameworks would fail anyways). Since this early return is desired for improving performance on iOS-based platforms in the first place, we can just guard it with PLATFORM(IOS).
Comment 5 Wenson Hsieh 2017-10-24 09:48:41 PDT
Created attachment 324679 [details]
Patch
Comment 6 WebKit Commit Bot 2017-10-24 10:38:48 PDT
Comment on attachment 324679 [details]
Patch

Clearing flags on attachment: 324679

Committed r223897: <https://trac.webkit.org/changeset/223897>
Comment 7 WebKit Commit Bot 2017-10-24 10:38:49 PDT
All reviewed patches have been landed.  Closing bug.