Bug 232860

Summary: [GStreamer] Won't play media and video in GtkOffscreenWindow
Product: WebKit Reporter: Po Lu <luangruo>
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bugs-noreply, calvaris, luangruo, mcatanzaro, philn, s930054123yaoyao
Priority: P2    
Version: Other   
Hardware: PC   
OS: Linux   

Description Po Lu 2021-11-08 17:00:02 PST
I can't get video to play in a WebKitWebView attached to a
GtkOffscreenWindow.  After setting up the logic to pass through button
events, and upon clicking the "play" button in, for instance, the
video at the front page of gnu.org, the playback area flickers white
for a second, then does nothing.

Media set to autoplay doesn't play either, with
`media-playback-requires-user-gesture' set to TRUE in WebKitSettings.

Following the instructions in the WebKitGTK/Debugging wiki page, no
gst.log is produced with the following environment variables upon
trying to play a video:

   export GST_DEBUG="3,webkit*:6" GST_DEBUG_FILE="$HOME/gst.log" \
          GST_DEBUG_NO_COLOR=1 WEBKIT_FORCE_SANDBOX=0

With a GST build with logs enabled.

With media logs enabled, I see the following output in the journal:

-- Journal begins at Mon 2021-11-01 18:10:02 CST. --
Nov 08 19:55:02 hostname WebKitWebProcess[658126]: MediaElementSession::clientDataBufferingTimerFired(8FE379B8B31B3CE5) visible = false
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: HTMLMediaElement::play(8FE379B8B31B3CE5)
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: MediaElementSession::playbackStateChangePermitted(8FE379B8B31B3CE5) state = 0
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: MediaElementSession::removeBehaviorRestriction(8FE379B8B31B3CE5) removed RequireUserGestureForAudioRateChange, RequireUserGestureForFullscreen, RequireUserGestureToControlControlsManager
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: HTMLMediaElement::playInternal(8FE379B8B31B3CE5)
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: PlatformMediaSessionManager::addSession(0) (8FE379B8B31B3CE5)
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: MediaElementSession::clientWillBeginPlayback(8FE379B8B31B3CE5) state = Autoplaying
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: PlatformMediaSessionManager::setCurrentSession(0) (8FE379B8B31B3CE5)
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: PlatformMediaSessionManager::sessionWillBeginPlayback(0) (8FE379B8B31B3CE5) returning true
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: MediaElementSession::setState(8FE379B8B31B3CE5) Playing
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: HTMLMediaElement::setShouldDelayLoadEvent(8FE379B8B31B3CE5) true
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: MediaElementSession::pageAllowsDataLoading(8FE379B8B31B3CE5) returning FALSE
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: HTMLMediaElement::selectMediaResource(8FE379B8B31B3CE5) not allowed to load in background, waiting
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: HTMLMediaElement::setShouldDelayLoadEvent(8FE379B8B31B3CE5) false
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: HTMLMediaElement::setShowPosterFlag(8FE379B8B31B3CE5) false
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: HTMLMediaElement::setAutoplayEventPlaybackState(8FE379B8B31B3CE5) StartedWithUserGesture
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: HTMLMediaElement::dispatchEvent(8FE379B8B31B3CE5) play
Nov 08 19:55:05 hostname WebKitWebProcess[658126]: HTMLMediaElement::dispatchEvent(8FE379B8B31B3CE5) waiting

I remember this working fine in an offscreen window about a year or so
ago, so this is probably a regression.  If it helps, I tested this on
Fedora 34, with WebKitGTK 3.34.1.  Thanks in advance.
Comment 1 Xabier Rodríguez Calvar 2021-11-10 23:16:25 PST
There should be a gst.log file in your home if you applied those env vars.
Comment 2 Po Lu 2021-11-10 23:25:22 PST
(In reply to Xabier Rodríguez Calvar from comment #1)
> There should be a gst.log file in your home if you applied those env vars.

There was no such log.  But running `GST_DEBUG=5 gst-launch-1.0
fakesrc ! fakesink' with those environment variables set did produce a
large log, so the environment variables are correct.
Comment 3 Liang-jie Lee 2023-04-06 07:02:02 PDT
Is there any update on this bug? If this can be fixed, then we can have Emacs playing videos with webkit, which is a feature wished by the community for many years.
Comment 4 Philippe Normand 2023-04-06 11:50:25 PDT
Well, we still need gst logs...