Bug 172391 - [MediaStream] Allow transition from autoplay to play when a capture stream begins.
Summary: [MediaStream] Allow transition from autoplay to play when a capture stream be...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Eric Carlson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-05-19 15:31 PDT by Eric Carlson
Modified: 2017-05-23 17:07 PDT (History)
4 users (show)

See Also:


Attachments
WIP patch (5.03 KB, patch)
2017-05-19 15:41 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff
Proposed patch. (9.57 KB, patch)
2017-05-22 13:47 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff
Proposed patch. (9.58 KB, patch)
2017-05-22 13:50 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff
Patch (5.56 KB, patch)
2017-05-23 16:19 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Carlson 2017-05-19 15:31:07 PDT
Allow audio/video elements to transition from autoplay to play when a capture stream begin.
Comment 1 Radar WebKit Bug Importer 2017-05-19 15:32:06 PDT
<rdar://problem/32304934>
Comment 2 Eric Carlson 2017-05-19 15:41:33 PDT
Created attachment 310714 [details]
WIP patch

No test yet.
Comment 3 Build Bot 2017-05-19 15:44:14 PDT
Attachment 310714 [details] did not pass style-queue:


ERROR: Source/WebCore/ChangeLog:9:  You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.  [changelog/nonewtests] [5]
Total errors found: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 youenn fablet 2017-05-19 15:55:19 PDT
Comment on attachment 310714 [details]
WIP patch

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

> Source/WebCore/dom/Document.cpp:3497
> +        mediaStreamStateChanged();

Change the name to captureStateChanged() or mediaStreamCaptureStateChanged() maybe?

> Source/WebCore/dom/Document.h:1771
> +        HashSet<HTMLMediaElement*> m_mediaStreamStateChangeElements;

Might be able to use HashSet<std::reference_wrapper<HTMLMediaElement>>
Then in the mediaStreamStateChanged, you would have:
for (HTMLMediaElement& mediaElement : m_mediaStreamStateChangeElements)
        mediaElement.mediaStreamStateChanged();

> Source/WebCore/html/HTMLMediaElement.cpp:7500
> +        play();

There is resumeAutoplaying() which does almost the same but is also setting m_autoplaying = true as well.
Can we reuse it instead?
Comment 5 youenn fablet 2017-05-19 15:55:48 PDT
Looks good, will have a go at it whenever I am finishing my build
Comment 6 Eric Carlson 2017-05-22 13:47:29 PDT
Created attachment 310914 [details]
Proposed patch.
Comment 7 Eric Carlson 2017-05-22 13:50:45 PDT
Created attachment 310915 [details]
Proposed patch.
Comment 8 youenn fablet 2017-05-22 14:09:41 PDT
Comment on attachment 310915 [details]
Proposed patch.

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

> Source/WebCore/dom/Document.h:1772
> +        String m_idHashSalt;

nit: unneeded whitespaces

> LayoutTests/webrtc/autoplay_remote_stream.html:40
> +                        assert_true(Object.isFrozen(trackEvent.streams), "Object.isFrozen() should return true");

nit: Probably do not need all of these asserts since they are tested in other tests already.

> LayoutTests/webrtc/autoplay_remote_stream.html:49
> +                remote_video.srcObject = stream;

Shouldn't we check that remote_video is not autoplaying after setting srcObject?
IIRC, one issue was that the remote_video element was not visible or in the DOM at the time srcObject is set.
Maybe we should test these two cases?

> LayoutTests/webrtc/autoplay_remote_stream.html:65
> +                remote_video.play().then(() => resolve() );

then(resolve) maybe
Comment 9 youenn fablet 2017-05-23 16:19:06 PDT
Created attachment 311072 [details]
Patch
Comment 10 WebKit Commit Bot 2017-05-23 17:07:25 PDT
Comment on attachment 311072 [details]
Patch

Clearing flags on attachment: 311072

Committed r217311: <http://trac.webkit.org/changeset/217311>
Comment 11 WebKit Commit Bot 2017-05-23 17:07:26 PDT
All reviewed patches have been landed.  Closing bug.