Title: [287176] releases/WebKitGTK/webkit-2.34/Source
Revision
287176
Author
[email protected]
Date
2021-12-17 02:11:36 -0800 (Fri, 17 Dec 2021)

Log Message

Merge r286676 - [GStreamer] Fill in client-name property on audio sinks
https://bugs.webkit.org/show_bug.cgi?id=233826

Patch by Philippe Normand <[email protected]> on 2021-12-08
Reviewed by Xabier Rodriguez-Calvar.

The audio sink client-name property is now set on sinks that support this property, such as
pulsesink and pipewiresink. This is picked-up by GNOME settings and the corresponding audio
streams now appear as owned by the WebKit application (MiniBrowser, ephy, etc) instead of
"WebKitWebProcess".

When the audio mixer is enabled, no media.role property is set, because the mixer can accept
music and/or video roles simultaneously, so it doesn't make sense in this context.

* platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
(WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer): Drive-by refactoring, using
a lambda instead of a static callback function.
(WebCore::autoAudioSinkChildAddedCallback): Deleted.
* platform/graphics/gstreamer/GStreamerAudioMixer.cpp:
(WebCore::GStreamerAudioMixer::GStreamerAudioMixer):
* platform/graphics/gstreamer/GStreamerCommon.cpp:
(WebCore::createAutoAudioSink):
(WebCore::createPlatformAudioSink):
* platform/graphics/gstreamer/GStreamerCommon.h:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
(WebCore::MediaPlayerPrivateGStreamer::createAudioSink):
(WebCore::MediaPlayerPrivateGStreamer::setAudioStreamPropertiesCallback): Deleted.
(WebCore::MediaPlayerPrivateGStreamer::setAudioStreamProperties): Deleted.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/ChangeLog (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/ChangeLog	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/ChangeLog	2021-12-17 10:11:36 UTC (rev 287176)
@@ -1,3 +1,35 @@
+2021-12-08  Philippe Normand  <[email protected]>
+
+        [GStreamer] Fill in client-name property on audio sinks
+        https://bugs.webkit.org/show_bug.cgi?id=233826
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        The audio sink client-name property is now set on sinks that support this property, such as
+        pulsesink and pipewiresink. This is picked-up by GNOME settings and the corresponding audio
+        streams now appear as owned by the WebKit application (MiniBrowser, ephy, etc) instead of
+        "WebKitWebProcess".
+
+        When the audio mixer is enabled, no media.role property is set, because the mixer can accept
+        music and/or video roles simultaneously, so it doesn't make sense in this context.
+
+        * platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
+        (WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer): Drive-by refactoring, using
+        a lambda instead of a static callback function.
+        (WebCore::autoAudioSinkChildAddedCallback): Deleted.
+        * platform/graphics/gstreamer/GStreamerAudioMixer.cpp:
+        (WebCore::GStreamerAudioMixer::GStreamerAudioMixer):
+        * platform/graphics/gstreamer/GStreamerCommon.cpp:
+        (WebCore::createAutoAudioSink):
+        (WebCore::createPlatformAudioSink):
+        * platform/graphics/gstreamer/GStreamerCommon.h:
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
+        (WebCore::MediaPlayerPrivateGStreamer::createAudioSink):
+        (WebCore::MediaPlayerPrivateGStreamer::setAudioStreamPropertiesCallback): Deleted.
+        (WebCore::MediaPlayerPrivateGStreamer::setAudioStreamProperties): Deleted.
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
+
 2021-09-08  Fujii Hironori  <[email protected]>
 
         KeyboardEvent should setDefaultHandled if EventHandler::startKeyboardScrolling returns true

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/PlatformGTK.cmake (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/PlatformGTK.cmake	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/PlatformGTK.cmake	2021-12-17 10:11:36 UTC (rev 287176)
@@ -27,6 +27,7 @@
     "${WEBCORE_DIR}/page/gtk"
     "${WEBCORE_DIR}/platform/adwaita"
     "${WEBCORE_DIR}/platform/generic"
+    "${WEBCORE_DIR}/platform/glib"
     "${WEBCORE_DIR}/platform/gtk"
     "${WEBCORE_DIR}/platform/graphics/egl"
     "${WEBCORE_DIR}/platform/graphics/glx"
@@ -53,6 +54,8 @@
 list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
     platform/adwaita/ScrollbarThemeAdwaita.h
 
+    platform/glib/ApplicationGLib.h
+
     platform/graphics/x11/PlatformDisplayX11.h
     platform/graphics/x11/XErrorTrapper.h
     platform/graphics/x11/XUniquePtr.h

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/PlatformWPE.cmake (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/PlatformWPE.cmake	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/PlatformWPE.cmake	2021-12-17 10:11:36 UTC (rev 287176)
@@ -19,6 +19,7 @@
 list(APPEND WebCore_PRIVATE_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}/accessibility/atk"
     "${WEBCORE_DIR}/platform/adwaita"
+    "${WEBCORE_DIR}/platform/glib"
     "${WEBCORE_DIR}/platform/graphics/egl"
     "${WEBCORE_DIR}/platform/graphics/epoxy"
     "${WEBCORE_DIR}/platform/graphics/glx"
@@ -36,6 +37,8 @@
 )
 
 list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
+    platform/glib/ApplicationGLib.h
+
     platform/graphics/wayland/PlatformDisplayWayland.h
     platform/graphics/wayland/WlUniquePtr.h
 )

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/SourcesGLib.txt (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/SourcesGLib.txt	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/SourcesGLib.txt	2021-12-17 10:11:36 UTC (rev 287176)
@@ -23,6 +23,7 @@
 
 platform/audio/glib/AudioBusGLib.cpp
 
+platform/glib/ApplicationGLib.cpp
 platform/glib/FileMonitorGLib.cpp
 platform/glib/KeyedDecoderGlib.cpp
 platform/glib/KeyedEncoderGlib.cpp

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp	2021-12-17 10:11:36 UTC (rev 287176)
@@ -92,12 +92,6 @@
     return destination->handleMessage(message);
 }
 
-static void autoAudioSinkChildAddedCallback(GstChildProxy*, GObject* object, gchar*, gpointer)
-{
-    if (GST_IS_AUDIO_BASE_SINK(object))
-        g_object_set(GST_AUDIO_BASE_SINK(object), "buffer-time", static_cast<gint64>(100000), nullptr);
-}
-
 Ref<AudioDestination> AudioDestination::create(AudioIOCallback& callback, const String&, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate)
 {
     initializeDebugCategory();
@@ -135,7 +129,7 @@
     m_src = GST_ELEMENT_CAST(g_object_new(WEBKIT_TYPE_WEB_AUDIO_SRC, "rate", sampleRate,
         "bus", m_renderBus.get(), "destination", this, "frames", AudioUtilities::renderQuantumSize, nullptr));
 
-    GRefPtr<GstElement> audioSink = createPlatformAudioSink();
+    GRefPtr<GstElement> audioSink = createPlatformAudioSink("music");
     m_audioSinkAvailable = audioSink;
     if (!audioSink) {
         GST_ERROR("Failed to create GStreamer audio sink element");
@@ -145,7 +139,10 @@
     // Probe platform early on for a working audio output device. This is not needed for the WebKit
     // custom audio sink because it doesn't rely on autoaudiosink.
     if (!WEBKIT_IS_AUDIO_SINK(audioSink.get())) {
-        g_signal_connect(audioSink.get(), "child-added", G_CALLBACK(autoAudioSinkChildAddedCallback), nullptr);
+        g_signal_connect(audioSink.get(), "child-added", G_CALLBACK(+[](GstChildProxy*, GObject* object, gchar*, gpointer) {
+            if (GST_IS_AUDIO_BASE_SINK(object))
+                g_object_set(GST_AUDIO_BASE_SINK(object), "buffer-time", static_cast<gint64>(100000), nullptr);
+        }), nullptr);
 
         // Autoaudiosink does the real sink detection in the GST_STATE_NULL->READY transition
         // so it's best to roll it to READY as soon as possible to ensure the underlying platform

Added: releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/glib/ApplicationGLib.cpp (0 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/glib/ApplicationGLib.cpp	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/glib/ApplicationGLib.cpp	2021-12-17 10:11:36 UTC (rev 287176)
@@ -0,0 +1,51 @@
+/*
+ *  Copyright (C) 2021 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "ApplicationGLib.h"
+
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+static String gApplicationName;
+static String gApplicationID;
+
+void setApplicationName(const String& applicationName)
+{
+    gApplicationName = applicationName;
+}
+
+const char* getApplicationName()
+{
+    if (!gApplicationName.isEmpty())
+        return gApplicationName.ascii().data();
+    return "WebKit";
+}
+
+void setApplicationID(const String& applicationID)
+{
+    gApplicationID = applicationID;
+}
+
+const String& getApplicationID()
+{
+    return gApplicationID;
+}
+
+} // namespace WebCore

Added: releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/glib/ApplicationGLib.h (0 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/glib/ApplicationGLib.h	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/glib/ApplicationGLib.h	2021-12-17 10:11:36 UTC (rev 287176)
@@ -0,0 +1,35 @@
+/*
+ *  Copyright (C) 2021 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#pragma once
+
+#if USE(GLIB)
+
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+WEBCORE_EXPORT void setApplicationName(const String&);
+WEBCORE_EXPORT const char* getApplicationName();
+
+WEBCORE_EXPORT void setApplicationID(const String&);
+WEBCORE_EXPORT const String& getApplicationID();
+
+} // namespace WebCore
+
+#endif // USE(GLIB)

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp	2021-12-17 10:11:36 UTC (rev 287176)
@@ -48,7 +48,7 @@
     connectSimpleBusMessageCallback(m_pipeline.get());
 
     m_mixer = makeGStreamerElement("audiomixer", nullptr);
-    GstElement* audioSink = makeGStreamerElement("autoaudiosink", nullptr);
+    auto* audioSink = createAutoAudioSink({ });
 
     gst_bin_add_many(GST_BIN_CAST(m_pipeline.get()), m_mixer.get(), audioSink, nullptr);
     gst_element_link(m_mixer.get(), audioSink);

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2021-12-17 10:11:36 UTC (rev 287176)
@@ -23,8 +23,10 @@
 
 #if USE(GSTREAMER)
 
+#include "ApplicationGLib.h"
 #include "GLVideoSinkGStreamer.h"
 #include "GStreamerAudioMixer.h"
+#include "GUniquePtrGStreamer.h"
 #include "GstAllocatorFastMalloc.h"
 #include "IntSize.h"
 #include "RuntimeApplicationChecks.h"
@@ -440,8 +442,27 @@
     return equal(GST_OBJECT_NAME(gst_element_get_factory(element)), name);
 }
 
-GstElement* createPlatformAudioSink()
+GstElement* createAutoAudioSink(const String& role)
 {
+    auto* audioSink = makeGStreamerElement("autoaudiosink", nullptr);
+    g_signal_connect_data(audioSink, "child-added", G_CALLBACK(+[](GstChildProxy*, GObject* object, gchar*, gpointer userData) {
+        auto* role = reinterpret_cast<StringImpl*>(userData);
+        auto* objectClass = G_OBJECT_GET_CLASS(object);
+        if (role && g_object_class_find_property(objectClass, "stream-properties")) {
+            GUniquePtr<GstStructure> properties(gst_structure_new("stream-properties", "media.role", G_TYPE_STRING, role->utf8().data(), nullptr));
+            g_object_set(object, "stream-properties", properties.get(), nullptr);
+            GST_DEBUG("Set media.role as %s on %" GST_PTR_FORMAT, role->utf8().data(), GST_ELEMENT_CAST(object));
+        }
+        if (g_object_class_find_property(objectClass, "client-name"))
+            g_object_set(object, "client-name", getApplicationName(), nullptr);
+    }), role.isolatedCopy().releaseImpl().leakRef(), static_cast<GClosureNotify>([](gpointer userData, GClosure*) {
+        reinterpret_cast<StringImpl*>(userData)->deref();
+    }), static_cast<GConnectFlags>(0));
+    return audioSink;
+}
+
+GstElement* createPlatformAudioSink(const String& role)
+{
     GstElement* audioSink = webkitAudioSinkNew();
     if (!audioSink) {
         // This means the WebKit audio sink configuration failed. It can happen for the following reasons:
@@ -450,7 +471,7 @@
         //   runtime requirements are not fullfilled.
         // - the sink was created for the WPE port, audio mixing was not requested and no
         //   WPEBackend-FDO audio receiver has been registered at runtime.
-        audioSink = makeGStreamerElement("autoaudiosink", nullptr);
+        audioSink = createAutoAudioSink(role);
     }
 
     return audioSink;

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h	2021-12-17 10:11:36 UTC (rev 287176)
@@ -26,6 +26,7 @@
 #include <gst/gst.h>
 #include <gst/video/video-format.h>
 #include <gst/video/video-info.h>
+#include <optional>
 #include <wtf/MediaTime.h>
 #include <wtf/ThreadSafeRefCounted.h>
 
@@ -294,7 +295,8 @@
 bool isGStreamerPluginAvailable(const char* name);
 bool gstElementFactoryEquals(GstElement*, const char* name);
 
-GstElement* createPlatformAudioSink();
+GstElement* createAutoAudioSink(const String& role);
+GstElement* createPlatformAudioSink(const String& role);
 
 bool webkitGstSetElementStateSynchronously(GstElement*, GstState, Function<bool(GstMessage*)>&& = [](GstMessage*) -> bool {
     return true;

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2021-12-17 10:11:36 UTC (rev 287176)
@@ -200,10 +200,6 @@
     if (m_fillTimer.isActive())
         m_fillTimer.stop();
 
-    auto* sink = audioSink();
-    if (sink && !WEBKIT_IS_AUDIO_SINK(sink))
-        g_signal_handlers_disconnect_by_func(G_OBJECT(sink), reinterpret_cast<gpointer>(setAudioStreamPropertiesCallback), this);
-
     m_readyTimerHandler.stop();
     for (auto& missingPluginCallback : m_missingPluginCallbacks) {
         if (missingPluginCallback)
@@ -884,23 +880,6 @@
     }
 }
 
-void MediaPlayerPrivateGStreamer::setAudioStreamPropertiesCallback(MediaPlayerPrivateGStreamer* player, GObject* object)
-{
-    player->setAudioStreamProperties(object);
-}
-
-void MediaPlayerPrivateGStreamer::setAudioStreamProperties(GObject* object)
-{
-    if (g_strcmp0(G_OBJECT_TYPE_NAME(object), "GstPulseSink"))
-        return;
-
-    const char* role = m_player->isVideoPlayer() ? "video" : "music";
-    GUniquePtr<GstStructure> properties(gst_structure_new("stream-properties", "media.role", G_TYPE_STRING, role, nullptr));
-    g_object_set(object, "stream-properties", properties.get(), nullptr);
-    GUniquePtr<gchar> elementName(gst_element_get_name(GST_ELEMENT(object)));
-    GST_DEBUG_OBJECT(pipeline(), "Set media.role as %s at %s", role, elementName.get());
-}
-
 void MediaPlayerPrivateGStreamer::sourceSetupCallback(MediaPlayerPrivateGStreamer* player, GstElement* sourceElement)
 {
     player->sourceSetup(sourceElement);
@@ -1249,14 +1228,12 @@
 
 GstElement* MediaPlayerPrivateGStreamer::createAudioSink()
 {
-    GstElement* audioSink = createPlatformAudioSink();
+    const char* role = m_player->isVideoPlayer() ? "video" : "music";
+    GstElement* audioSink = createPlatformAudioSink(role);
     RELEASE_ASSERT(audioSink);
     if (!audioSink)
         return nullptr;
 
-    if (!WEBKIT_IS_AUDIO_SINK(audioSink))
-        g_signal_connect_swapped(audioSink, "child-added", G_CALLBACK(setAudioStreamPropertiesCallback), this);
-
 #if ENABLE(WEB_AUDIO)
     GstElement* audioSinkBin = gst_bin_new("audio-sink");
     ensureAudioSourceProvider();

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2021-12-17 10:11:36 UTC (rev 287176)
@@ -301,13 +301,10 @@
     template <typename TrackPrivateType> void notifyPlayerOfTrack();
 
     void ensureAudioSourceProvider();
-    void setAudioStreamProperties(GObject*);
 
     virtual bool doSeek(const MediaTime& position, float rate, GstSeekFlags);
     void invalidateCachedPosition() const;
 
-    static void setAudioStreamPropertiesCallback(MediaPlayerPrivateGStreamer*, GObject*);
-
     static void sourceSetupCallback(MediaPlayerPrivateGStreamer*, GstElement*);
     static void videoChangedCallback(MediaPlayerPrivateGStreamer*);
     static void audioChangedCallback(MediaPlayerPrivateGStreamer*);

Modified: releases/WebKitGTK/webkit-2.34/Source/WebKit/Shared/WebProcessCreationParameters.cpp (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2021-12-17 10:11:36 UTC (rev 287176)
@@ -214,6 +214,11 @@
 #if PLATFORM(GTK) || PLATFORM(WPE)
     encoder << memoryPressureHandlerConfiguration;
 #endif
+
+#if USE(GLIB)
+    encoder << applicationID;
+    encoder << applicationName;
+#endif
 }
 
 bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreationParameters& parameters)
@@ -587,6 +592,13 @@
     parameters.memoryPressureHandlerConfiguration = WTFMove(*memoryPressureHandlerConfiguration);
 #endif
 
+#if USE(GLIB)
+    if (!decoder.decode(parameters.applicationID))
+        return false;
+    if (!decoder.decode(parameters.applicationName))
+        return false;
+#endif
+
     return true;
 }
 

Modified: releases/WebKitGTK/webkit-2.34/Source/WebKit/Shared/WebProcessCreationParameters.h (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebKit/Shared/WebProcessCreationParameters.h	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebKit/Shared/WebProcessCreationParameters.h	2021-12-17 10:11:36 UTC (rev 287176)
@@ -260,6 +260,11 @@
 #if PLATFORM(GTK) || PLATFORM(WPE)
     std::optional<MemoryPressureHandler::Configuration> memoryPressureHandlerConfiguration;
 #endif
+
+#if USE(GLIB)
+    String applicationID;
+    String applicationName;
+#endif
 };
 
 } // namespace WebKit

Modified: releases/WebKitGTK/webkit-2.34/Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp	2021-12-17 10:11:36 UTC (rev 287176)
@@ -129,6 +129,22 @@
     return memfd;
 }
 
+static const char* applicationId(GError** error)
+{
+    GApplication* app = g_application_get_default();
+    if (!app) {
+        g_set_error_literal(error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, "GApplication is required.");
+        return nullptr;
+    }
+
+    const char* appID = g_application_get_application_id(app);
+    if (!appID) {
+        g_set_error_literal(error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, "GApplication must have a valid ID.");
+        return nullptr;
+    }
+    return appID;
+}
+
 static int createFlatpakInfo()
 {
     static NeverDestroyed<GUniquePtr<char>> data;
@@ -137,13 +153,10 @@
     if (!data.get()) {
         // xdg-desktop-portal relates your name to certain permissions so we want
         // them to be application unique which is best done via GApplication.
-        GApplication* app = g_application_get_default();
-        if (!app)
-            g_error("GApplication is required for xdg-desktop-portal access in the WebKit sandbox.");
-
-        const char* appID = g_application_get_application_id(app);
+        GUniqueOutPtr<GError> error;
+        const char* appID = applicationId(&error.outPtr());
         if (!appID)
-            g_error("GApplication must have a valid ID for xdg-desktop-portal access in the WebKit sandbox.");
+            g_error("Unable to configure xdg-desktop-portal access in the WebKit sandbox: %s", error->message);
 
         GUniquePtr<GKeyFile> keyFile(g_key_file_new());
         g_key_file_set_string(keyFile.get(), "Application", "name", appID);

Modified: releases/WebKitGTK/webkit-2.34/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp	2021-12-17 10:11:36 UTC (rev 287176)
@@ -109,6 +109,11 @@
 #endif
 
     parameters.memoryPressureHandlerConfiguration = m_configuration->memoryPressureHandlerConfiguration();
+
+    GApplication* app = g_application_get_default();
+    if (app)
+        parameters.applicationID = g_application_get_application_id(app);
+    parameters.applicationName = g_get_application_name();
 }
 
 void WebProcessPool::platformInvalidateContext()

Modified: releases/WebKitGTK/webkit-2.34/Source/WebKit/WebProcess/glib/WebProcessGLib.cpp (287175 => 287176)


--- releases/WebKitGTK/webkit-2.34/Source/WebKit/WebProcess/glib/WebProcessGLib.cpp	2021-12-17 09:01:48 UTC (rev 287175)
+++ releases/WebKitGTK/webkit-2.34/Source/WebKit/WebProcess/glib/WebProcessGLib.cpp	2021-12-17 10:11:36 UTC (rev 287176)
@@ -35,6 +35,7 @@
 #include <WebCore/GStreamerCommon.h>
 #endif
 
+#include <WebCore/ApplicationGLib.h>
 #include <WebCore/MemoryCache.h>
 
 #if PLATFORM(WAYLAND)
@@ -108,6 +109,12 @@
 
     if (parameters.memoryPressureHandlerConfiguration)
         MemoryPressureHandler::singleton().setConfiguration(WTFMove(*parameters.memoryPressureHandlerConfiguration));
+
+    if (!parameters.applicationID.isEmpty())
+        WebCore::setApplicationID(parameters.applicationID);
+
+    if (!parameters.applicationName.isEmpty())
+        WebCore::setApplicationName(parameters.applicationName);
 }
 
 void WebProcess::platformSetWebsiteDataStoreParameters(WebProcessDataStoreParameters&&)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to