Bug 164116

Summary: [GStreamer][MSE] Fix player private selection when MSE is enabled
Product: WebKit Reporter: Enrique Ocaña <eocanha>
Component: PlatformAssignee: Enrique Ocaña <eocanha>
Status: RESOLVED FIXED    
Severity: Normal CC: calvaris, commit-queue, pnormand
Priority: P2    
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 164022    
Attachments:
Description Flags
Patch none

Description Enrique Ocaña 2016-10-28 02:32:34 PDT
It looks like the player private selection mechanism doesn't rely exclusively on the supportsType() function. Even when supportsType() returns false (a particular player declines to be selected to play a content) MediaPlayer::loadWithNextMediaEngine() can still use nextMediaEngine() and select a completely unappropriate player private for that kind of content. In that case, the expected behaviour (not met by the MSE private player) is to set networkState to MediaPlayer::FormatError. That would force a different player to be used.

This misbehaviour was the cause of the massive test crashes reported in #164022, as the MSE player was being selected to play regular videos despite not being properly configured with a MediaSourcePrivateClient (this can't happen for an MSE video).
Comment 1 Enrique Ocaña 2016-10-28 02:37:26 PDT
Created attachment 293131 [details]
Patch
Comment 2 Xabier Rodríguez Calvar 2016-10-28 02:52:21 PDT
Comment on attachment 293131 [details]
Patch

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

Anyway, if this fix only the crashes, I would wait for a more complete solution unless the solution for other bugs is incremental.

> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:275
> +    // Properly fail so the global MediaPlayer tries to fallback to the next MediaPlayerPrivate.

Make this comment a GST_TRACE. That way we can follow what is going on.

> Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:129
> +        // Properly fail so the global MediaPlayer tries to fallback to the next MediaPlayerPrivate.

Ditto

> Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:136
> +    if (UNLIKELY(!initializeGStreamerAndRegisterWebKitMSEElement()))
> +        return;

ASSERT_NOT_REACHED(). Maybe it could be interesting to do the same in other places, but it is not urgent and can be done in other bug.
Comment 3 Enrique Ocaña 2016-10-28 03:04:16 PDT
Comment on attachment 293131 [details]
Patch

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

>> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:275
>> +    // Properly fail so the global MediaPlayer tries to fallback to the next MediaPlayerPrivate.
> 
> Make this comment a GST_TRACE. That way we can follow what is going on.

Are you sure we can use GStreamer logging facilities (potentially) *before* having initialized GStreamer?
Comment 4 Philippe Normand 2016-10-28 03:39:49 PDT
gst_init() needs to be called before using the logging macros.
Comment 5 Enrique Ocaña 2016-10-28 06:01:55 PDT
(In reply to comment #4)
> gst_init() needs to be called before using the logging macros.

But in this case the logging is to be done before initializing GStreamer. Is it still worth to initialize GStreamer to log something that is supposed to be part of the normal behaviour of the player? (yield other players when the content isn't appropriate for this one).

In the OWR player, for instance, nothing is logged:

https://github.com/WebKit/webkit/blob/master/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerOwr.cpp#L126
Comment 6 Philippe Normand 2016-10-28 06:45:18 PDT
(In reply to comment #5)
> (In reply to comment #4)
> > gst_init() needs to be called before using the logging macros.
> 
> But in this case the logging is to be done before initializing GStreamer. Is
> it still worth to initialize GStreamer to log something that is supposed to
> be part of the normal behaviour of the player? (yield other players when the
> content isn't appropriate for this one).

No.

> 
> In the OWR player, for instance, nothing is logged:
> 
> https://github.com/WebKit/webkit/blob/master/Source/WebCore/platform/
> graphics/gstreamer/MediaPlayerPrivateGStreamerOwr.cpp#L126
Comment 7 Xabier Rodríguez Calvar 2016-10-31 02:26:38 PDT
(In reply to comment #3)
> Are you sure we can use GStreamer logging facilities (potentially) *before*
> having initialized GStreamer?

Forget it then.
Comment 8 Philippe Normand 2016-11-15 00:18:29 PST
Does the patch needs an update then?

It'd be great to re-enable MSE on the bots ASAP :)
Comment 9 Xabier Rodríguez Calvar 2016-11-16 09:14:19 PST
(In reply to comment #8)
> Does the patch needs an update then?

According to Quique, this only covers the crashes but there are still a couple of tests that fail so the patch is incomplete. We could land this, but then we would need another bug[s] to track the other failures that Quique reported.

> It'd be great to re-enable MSE on the bots ASAP :)

Oh yes, we could even make the option public so that you could see that it is enabled when you build it ;)
Comment 10 Enrique Ocaña 2016-12-05 12:09:52 PST
The rest of the test fixes are going to be submitted in other bugs. Can this patch have r+ in its current state, even if it's cq+ later?
Comment 11 WebKit Commit Bot 2016-12-14 02:37:06 PST
Comment on attachment 293131 [details]
Patch

Clearing flags on attachment: 293131

Committed r209796: <http://trac.webkit.org/changeset/209796>
Comment 12 WebKit Commit Bot 2016-12-14 02:37:10 PST
All reviewed patches have been landed.  Closing bug.