Bug 178713

Summary: [iOS] MediaPlayer::isAvailable() takes ~150 ms during web process initialization
Product: WebKit Reporter: Wenson Hsieh <wenson_hsieh>
Component: WebCore Misc.Assignee: Wenson Hsieh <wenson_hsieh>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, eric.carlson, jer.noble, thorton
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
eric.carlson: review-
Patch none

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.