Skip to content

Conversation

carlosgcampos
Copy link
Contributor

@carlosgcampos carlosgcampos commented Jun 1, 2023

b29369c

[GStreamer] Create and activate the GstGLContext in the compositing thread
https://bugs.webkit.org/show_bug.cgi?id=257599

Reviewed by NOBODY (OOPS!).

We currently create the GstGLContext wrapping the sharing context and
it's activated in the main thread. That means, among other things, that
gst sends all GL operations on the context to the main thread. Another
side effect is that the sharing context is made current in the main
thread and remains forever. This patch creates the GstGLContext wrapping
the compositing GL context and activated in the compositing thread,
ensuring all GL operations happen in the compositing thread.

* Source/WebCore/SourcesGTK.txt: Add PageGStreamer.cpp to compilation.
* Source/WebCore/SourcesWPE.txt: Ditto.
* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerGstGLContext const): Get the GstGLContext from the Page.
* Source/WebCore/html/HTMLMediaElement.h:
* Source/WebCore/page/Page.h:
(WebCore::Page::setCompositingRunLoop): Set the compositing RunLoop and reset the GstGLContext.
(WebCore::Page::compositingRunLoop const): Get the compositing RunLoop.
* Source/WebCore/page/gstreamer/PageGStreamer.cpp: Added.
(WebCore::queryGstGLAPI): Helper to get the GstGLAPI of the current GL context.
(WebCore::Page::gstGLContext): Get or create the GstGLContext.
* Source/WebCore/platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::gstGLContext): Ask the client for the GstGLContext.
* Source/WebCore/platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerGstGLContext const):
* Source/WebCore/platform/graphics/PlatformDisplay.cpp:
(WebCore::PlatformDisplay::terminateEGLDisplay): Remove GstGLContext from PlatformDisplay.
* Source/WebCore/platform/graphics/PlatformDisplay.h:
* Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp:
(webkit_gl_video_sink_class_init): Remove change_state, since the context is now set by
MediaPlayerPrivateGStreamer on needs-context message.
(webKitGLVideoSinkProbePlatform): Remove the check of GstGLDisplay.
(requestGLContext): Deleted.
(setGLContext): Deleted.
(webKitGLVideoSinkChangeState): Deleted.
* Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::handleNeedContextMessage): Handle GL display and context messages.
(WebCore::MediaPlayerPrivateGStreamer::createVideoSinkGL): Check we have a GstGLContext.
* Source/WebCore/platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp:
(WebCore::PlatformDisplay::gstGLDisplay const): Simplify to just get or create the GstGLDisplay.
(createGstGLDisplay): Deleted.
(PlatformDisplay::tryEnsureGstGLContext const): Deleted.
(PlatformDisplay::gstGLDisplay const): Deleted.
(PlatformDisplay::gstGLContext const): Deleted.
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
(WebKit::LayerTreeHost::LayerTreeHost): Set the compositing run loop on the page.
(WebKit::LayerTreeHost::~LayerTreeHost): Reset the compositing run loop on the page.

b29369c

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 🧪 api-mac ✅ 🛠 gtk
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ❌ 🧪 gtk-wk2
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🧪 api-gtk
✅ 🛠 tv 🧪 mac-AS-debug-wk2
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

…hread

https://bugs.webkit.org/show_bug.cgi?id=257599

Reviewed by NOBODY (OOPS!).

We currently create the GstGLContext wrapping the sharing context and
it's activated in the main thread. That means, among other things, that
gst sends all GL operations on the context to the main thread. Another
side effect is that the sharing context is made current in the main
thread and remains forever. This patch creates the GstGLContext wrapping
the compositing GL context and activated in the compositing thread,
ensuring all GL operations happen in the compositing thread.

* Source/WebCore/SourcesGTK.txt: Add PageGStreamer.cpp to compilation.
* Source/WebCore/SourcesWPE.txt: Ditto.
* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerGstGLContext const): Get the GstGLContext from the Page.
* Source/WebCore/html/HTMLMediaElement.h:
* Source/WebCore/page/Page.h:
(WebCore::Page::setCompositingRunLoop): Set the compositing RunLoop and reset the GstGLContext.
(WebCore::Page::compositingRunLoop const): Get the compositing RunLoop.
* Source/WebCore/page/gstreamer/PageGStreamer.cpp: Added.
(WebCore::queryGstGLAPI): Helper to get the GstGLAPI of the current GL context.
(WebCore::Page::gstGLContext): Get or create the GstGLContext.
* Source/WebCore/platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::gstGLContext): Ask the client for the GstGLContext.
* Source/WebCore/platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerGstGLContext const):
* Source/WebCore/platform/graphics/PlatformDisplay.cpp:
(WebCore::PlatformDisplay::terminateEGLDisplay): Remove GstGLContext from PlatformDisplay.
* Source/WebCore/platform/graphics/PlatformDisplay.h:
* Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp:
(webkit_gl_video_sink_class_init): Remove change_state, since the context is now set by
MediaPlayerPrivateGStreamer on needs-context message.
(webKitGLVideoSinkProbePlatform): Remove the check of GstGLDisplay.
(requestGLContext): Deleted.
(setGLContext): Deleted.
(webKitGLVideoSinkChangeState): Deleted.
* Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::handleNeedContextMessage): Handle GL display and context messages.
(WebCore::MediaPlayerPrivateGStreamer::createVideoSinkGL): Check we have a GstGLContext.
* Source/WebCore/platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp:
(WebCore::PlatformDisplay::gstGLDisplay const): Simplify to just get or create the GstGLDisplay.
(createGstGLDisplay): Deleted.
(PlatformDisplay::tryEnsureGstGLContext const): Deleted.
(PlatformDisplay::gstGLDisplay const): Deleted.
(PlatformDisplay::gstGLContext const): Deleted.
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
(WebKit::LayerTreeHost::LayerTreeHost): Set the compositing run loop on the page.
(WebKit::LayerTreeHost::~LayerTreeHost): Reset the compositing run loop on the page.
@carlosgcampos carlosgcampos self-assigned this Jun 1, 2023
@carlosgcampos carlosgcampos added the Media Bugs related to the HTML 5 Media elements. label Jun 1, 2023
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Media Bugs related to the HTML 5 Media elements. merging-blocked Applied to prevent a change from being merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants