Bug 149888 - [iOS] <video> elements without audio tracks should not interrupt music
Summary: [iOS] <video> elements without audio tracks should not interrupt music
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: 2015-10-07 12:58 PDT by Jer Noble
Modified: 2015-12-02 13:23 PST (History)
1 user (show)

See Also:


Attachments
Patch (364.89 KB, patch)
2015-10-08 15:54 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch (365.67 KB, patch)
2015-10-09 16:48 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch (12.70 KB, patch)
2015-10-30 16:33 PDT, Jer Noble
eric.carlson: review+
jer.noble: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (20.81 KB, patch)
2015-11-02 08:54 PST, Jer Noble
no flags Details | Formatted Diff | Diff
Patch for landing (364.61 KB, patch)
2015-11-02 09:21 PST, Jer Noble
commit-queue: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (364.60 KB, patch)
2015-11-04 09:37 PST, 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 2015-10-07 12:58:51 PDT
[iOS] <video> elements without audio tracks should not interrupt music
Comment 1 Jer Noble 2015-10-08 15:54:43 PDT
Created attachment 262724 [details]
Patch
Comment 2 Darin Adler 2015-10-09 09:27:52 PDT
Comment on attachment 262724 [details]
Patch

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

Not sure exactly why the Mac build is failing.

> Source/WebCore/html/HTMLMediaElement.cpp:6450
> +bool HTMLMediaElement::producesAudio() const
> +{
> +    if (m_player && m_readyState >= HAVE_METADATA)
> +        return hasAudio();
> +    return hasTagName(HTMLNames::audioTag);
> +}

This function is hard to use correctly. It can return false for a video element and then change its mind and start returning true for the same element as the element loads content. I think it can even return true for an audio element and then start returning false for the same element as the element loads content in some strange cases. What notifies interested parties that this may have changed and it’s time to check it again?

It also seems weak design for this to call hasTagName(HTMLNames::audioTag) when we already have separate classes for the audio and video elements.

Maybe override this for video element and audio element instead of media element.

Maybe a name like “producing audio” would make it a little more clear that this is a state that can change over time.

> Tools/TestWebKitAPI/Tests/WebKit/ios/AudioSessionCategoryIOS.mm:34
> +#import <UIKit/SoftLinking.h>

On the bot: TestWebKitAPI/Tests/WebKit/ios/AudioSessionCategoryIOS.mm:34:9: fatal error: 'UIKit/SoftLinking.h' file not found
Comment 3 Jer Noble 2015-10-09 16:17:44 PDT
(In reply to comment #2)
> Comment on attachment 262724 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=262724&action=review
> 
> Not sure exactly why the Mac build is failing.
> 
> > Source/WebCore/html/HTMLMediaElement.cpp:6450
> > +bool HTMLMediaElement::producesAudio() const
> > +{
> > +    if (m_player && m_readyState >= HAVE_METADATA)
> > +        return hasAudio();
> > +    return hasTagName(HTMLNames::audioTag);
> > +}
> 
> This function is hard to use correctly. It can return false for a video
> element and then change its mind and start returning true for the same
> element as the element loads content. I think it can even return true for an
> audio element and then start returning false for the same element as the
> element loads content in some strange cases. What notifies interested
> parties that this may have changed and it’s time to check it again?

Such is the nature of video on the internet; especially with HLS (and also with MSE) video can go from having an audio track to not having one without user intervention.  However, we handle this case by re-running PlatformMediaSessionManager::updateSessionState() whenever the hasAudio() or hasVideo() change in HTMLMediaElement::mediaPlayerCharacteristicChanged().

> It also seems weak design for this to call hasTagName(HTMLNames::audioTag)
> when we already have separate classes for the audio and video elements.

True.

> Maybe override this for video element and audio element instead of media
> element.
> 
> Maybe a name like “producing audio” would make it a little more clear that
> this is a state that can change over time.

Sure.

> > Tools/TestWebKitAPI/Tests/WebKit/ios/AudioSessionCategoryIOS.mm:34
> > +#import <UIKit/SoftLinking.h>
> 
> On the bot: TestWebKitAPI/Tests/WebKit/ios/AudioSessionCategoryIOS.mm:34:9:
> fatal error: 'UIKit/SoftLinking.h' file not found

I'll try to use one of the WebKit versions of that header.
Comment 4 Jer Noble 2015-10-09 16:48:39 PDT
Created attachment 262801 [details]
Patch
Comment 5 Darin Adler 2015-10-18 16:53:36 PDT
Comment on attachment 262801 [details]
Patch

Patch does not build on Mac.
Comment 6 Jer Noble 2015-10-19 08:51:37 PDT
Looks like CanHandleRequest.cpp somehow got re-added to the TestWebKitAPI project (bad merge?).  Will fix.
Comment 7 Jer Noble 2015-10-30 16:33:27 PDT
Created attachment 264438 [details]
Patch
Comment 8 Eric Carlson 2015-10-30 16:36:57 PDT
Comment on attachment 264438 [details]
Patch

r=me
Comment 9 Jer Noble 2015-11-02 08:53:26 PST
Comment on attachment 264438 [details]
Patch

Whoops, forgot tests in this patch.
Comment 10 Jer Noble 2015-11-02 08:54:41 PST
Created attachment 264593 [details]
Patch for landing
Comment 11 Jer Noble 2015-11-02 09:21:21 PST
Created attachment 264595 [details]
Patch for landing
Comment 12 WebKit Commit Bot 2015-11-04 09:35:29 PST
Comment on attachment 264595 [details]
Patch for landing

Rejecting attachment 264595 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-02', 'validate-changelog', '--check-oops', '--non-interactive', 264595, '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

ChangeLog entry in Source/WebCore/ChangeLog contains OOPS!.

Full output: http://webkit-queues.webkit.org/results/382217
Comment 13 Jer Noble 2015-11-04 09:37:45 PST
Created attachment 264794 [details]
Patch for landing
Comment 14 WebKit Commit Bot 2015-11-04 10:49:42 PST
Comment on attachment 264794 [details]
Patch for landing

Clearing flags on attachment: 264794

Committed r192027: <http://trac.webkit.org/changeset/192027>
Comment 15 Jer Noble 2015-11-04 16:37:29 PST
<rdar://problem/22235751>