Title: [291038] trunk/Source
Revision
291038
Author
carlo...@webkit.org
Date
2022-03-09 04:43:36 -0800 (Wed, 09 Mar 2022)

Log Message

[GTK][WPE] Stop using the env var WEBKIT_INSPECTOR_SERVER to connect to the inspector
https://bugs.webkit.org/show_bug.cgi?id=237646

Reviewed by Adrian Perez de Castro.

Source/_javascript_Core:

Add RemoteInspector::s_inspectorServerAddress to keep the remote inspector server address instead of the
environment variable used to start the server.

* inspector/remote/RemoteInspector.h:
* inspector/remote/glib/RemoteInspectorGlib.cpp:
(Inspector::RemoteInspector::RemoteInspector): Only call start if s_inspectorServerAddress is not null.
(Inspector::RemoteInspector::start): Use s_inspectorServerAddress instead of querying the environment.

Source/WebKit:

Use it only in the UI process to start the server, but propagate the address to web process using creation
parameters.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const): Encode inspectorServerAddress.
(WebKit::WebProcessCreationParameters::decode): Decode inspectorServerAddress.
* Shared/WebProcessCreationParameters.h: Add inspectorServerAddress.
* UIProcess/API/glib/WebKitInitialize.cpp:
(WebKit::initializeRemoteInspectorServer): Set RemoteInspector::s_inspectorServerAddress if the server started
successfully.
* UIProcess/glib/WebProcessPoolGLib.cpp:
(WebKit::WebProcessPool::platformInitializeWebProcess): Set inspectorServerAddress parameter from
RemoteInspector::s_inspectorServerAddress value.
* WebProcess/glib/WebProcessGLib.cpp:
(WebKit::WebProcess::platformInitializeWebProcess): Set RemoteInspector::s_inspectorServerAddress from creation
parameter value.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (291037 => 291038)


--- trunk/Source/_javascript_Core/ChangeLog	2022-03-09 12:37:00 UTC (rev 291037)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-03-09 12:43:36 UTC (rev 291038)
@@ -1,3 +1,18 @@
+2022-03-09  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK][WPE] Stop using the env var WEBKIT_INSPECTOR_SERVER to connect to the inspector
+        https://bugs.webkit.org/show_bug.cgi?id=237646
+
+        Reviewed by Adrian Perez de Castro.
+
+        Add RemoteInspector::s_inspectorServerAddress to keep the remote inspector server address instead of the
+        environment variable used to start the server.
+
+        * inspector/remote/RemoteInspector.h:
+        * inspector/remote/glib/RemoteInspectorGlib.cpp:
+        (Inspector::RemoteInspector::RemoteInspector): Only call start if s_inspectorServerAddress is not null.
+        (Inspector::RemoteInspector::start): Use s_inspectorServerAddress instead of querying the environment.
+
 2022-03-08  Robin Morisset  <rmoris...@apple.com>
 
         [WTF] LikelyDenseUnsignedIntegerSet::add can cause a reindexing of the entire bit vector with every call in the worst case

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h (291037 => 291038)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h	2022-03-09 12:37:00 UTC (rev 291037)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h	2022-03-09 12:43:36 UTC (rev 291038)
@@ -121,6 +121,10 @@
 #if PLATFORM(COCOA)
     static void setNeedMachSandboxExtension(bool needExtension) { needMachSandboxExtension = needExtension; }
 #endif
+#if USE(GLIB)
+    static void setInspectorServerAddress(CString&& address) { s_inspectorServerAddress = WTFMove(address); }
+    static const CString& inspectorServerAddress() { return s_inspectorServerAddress; }
+#endif
     static void startDisabled();
     static RemoteInspector& singleton();
     friend class LazyNeverDestroyed<RemoteInspector>;
@@ -247,6 +251,9 @@
 #if PLATFORM(COCOA)
     static std::atomic<bool> needMachSandboxExtension;
 #endif
+#if USE(GLIB)
+    static CString s_inspectorServerAddress;
+#endif
 
     // Targets can be registered from any thread at any time.
     // Any target can send messages over the XPC connection.

Modified: trunk/Source/_javascript_Core/inspector/remote/glib/RemoteInspectorGlib.cpp (291037 => 291038)


--- trunk/Source/_javascript_Core/inspector/remote/glib/RemoteInspectorGlib.cpp	2022-03-09 12:37:00 UTC (rev 291037)
+++ trunk/Source/_javascript_Core/inspector/remote/glib/RemoteInspectorGlib.cpp	2022-03-09 12:43:36 UTC (rev 291038)
@@ -38,6 +38,8 @@
 
 namespace Inspector {
 
+CString RemoteInspector::s_inspectorServerAddress;
+
 RemoteInspector& RemoteInspector::singleton()
 {
     static LazyNeverDestroyed<RemoteInspector> shared;
@@ -50,7 +52,7 @@
 
 RemoteInspector::RemoteInspector()
 {
-    if (g_getenv("WEBKIT_INSPECTOR_SERVER"))
+    if (!s_inspectorServerAddress.isNull())
         start();
 }
 
@@ -65,7 +67,7 @@
     m_cancellable = adoptGRef(g_cancellable_new());
 
     GRefPtr<GSocketClient> socketClient = adoptGRef(g_socket_client_new());
-    g_socket_client_connect_to_host_async(socketClient.get(), g_getenv("WEBKIT_INSPECTOR_SERVER"), 0, m_cancellable.get(),
+    g_socket_client_connect_to_host_async(socketClient.get(), s_inspectorServerAddress.data(), 0, m_cancellable.get(),
         [](GObject* client, GAsyncResult* result, gpointer userData) {
             RemoteInspector* inspector = static_cast<RemoteInspector*>(userData);
             GUniqueOutPtr<GError> error;
@@ -72,7 +74,7 @@
             if (GRefPtr<GSocketConnection> connection = adoptGRef(g_socket_client_connect_to_host_finish(G_SOCKET_CLIENT(client), result, &error.outPtr())))
                 inspector->setupConnection(SocketConnection::create(WTFMove(connection), messageHandlers(), inspector));
             else if (!g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED))
-                g_warning("RemoteInspector failed to connect to inspector server at: %s: %s", g_getenv("WEBKIT_INSPECTOR_SERVER"), error->message);
+                g_warning("RemoteInspector failed to connect to inspector server at: %s: %s", s_inspectorServerAddress.data(), error->message);
         }, this);
 }
 

Modified: trunk/Source/WebKit/ChangeLog (291037 => 291038)


--- trunk/Source/WebKit/ChangeLog	2022-03-09 12:37:00 UTC (rev 291037)
+++ trunk/Source/WebKit/ChangeLog	2022-03-09 12:43:36 UTC (rev 291038)
@@ -1,3 +1,27 @@
+2022-03-09  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK][WPE] Stop using the env var WEBKIT_INSPECTOR_SERVER to connect to the inspector
+        https://bugs.webkit.org/show_bug.cgi?id=237646
+
+        Reviewed by Adrian Perez de Castro.
+
+        Use it only in the UI process to start the server, but propagate the address to web process using creation
+        parameters.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode const): Encode inspectorServerAddress.
+        (WebKit::WebProcessCreationParameters::decode): Decode inspectorServerAddress.
+        * Shared/WebProcessCreationParameters.h: Add inspectorServerAddress.
+        * UIProcess/API/glib/WebKitInitialize.cpp:
+        (WebKit::initializeRemoteInspectorServer): Set RemoteInspector::s_inspectorServerAddress if the server started
+        successfully.
+        * UIProcess/glib/WebProcessPoolGLib.cpp:
+        (WebKit::WebProcessPool::platformInitializeWebProcess): Set inspectorServerAddress parameter from
+        RemoteInspector::s_inspectorServerAddress value.
+        * WebProcess/glib/WebProcessGLib.cpp:
+        (WebKit::WebProcess::platformInitializeWebProcess): Set RemoteInspector::s_inspectorServerAddress from creation
+        parameter value.
+
 2022-03-09  Youenn Fablet  <you...@apple.com>
 
         Scope capture sources by page identifiers

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (291037 => 291038)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2022-03-09 12:37:00 UTC (rev 291037)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2022-03-09 12:43:36 UTC (rev 291038)
@@ -213,6 +213,7 @@
 #if USE(GLIB)
     encoder << applicationID;
     encoder << applicationName;
+    encoder << inspectorServerAddress;
 #endif
 
 #if USE(ATSPI)
@@ -577,6 +578,12 @@
         return false;
     if (!decoder.decode(parameters.applicationName))
         return false;
+
+    std::optional<CString> inspectorServerAddress;
+    decoder >> inspectorServerAddress;
+    if (!inspectorServerAddress)
+        return false;
+    parameters.inspectorServerAddress = WTFMove(*inspectorServerAddress);
 #endif
 
 #if USE(ATSPI)

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (291037 => 291038)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2022-03-09 12:37:00 UTC (rev 291037)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2022-03-09 12:43:36 UTC (rev 291038)
@@ -255,6 +255,7 @@
 #if USE(GLIB)
     String applicationID;
     String applicationName;
+    CString inspectorServerAddress;
 #endif
 
 #if USE(ATSPI)

Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitInitialize.cpp (291037 => 291038)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitInitialize.cpp	2022-03-09 12:37:00 UTC (rev 291037)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitInitialize.cpp	2022-03-09 12:43:36 UTC (rev 291038)
@@ -27,6 +27,7 @@
 #include "WebKitInitialize.h"
 
 #include "WebKit2Initialize.h"
+#include <_javascript_Core/RemoteInspector.h>
 #include <_javascript_Core/RemoteInspectorServer.h>
 #include <mutex>
 #include <wtf/glib/GUniquePtr.h>
@@ -53,7 +54,10 @@
     if (!port)
         return;
 
-    Inspector::RemoteInspectorServer::singleton().start(inspectorAddress.get(), port);
+    if (!Inspector::RemoteInspectorServer::singleton().start(inspectorAddress.get(), port))
+        return;
+
+    Inspector::RemoteInspector::setInspectorServerAddress(address);
 }
 #endif
 

Modified: trunk/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp (291037 => 291038)


--- trunk/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp	2022-03-09 12:37:00 UTC (rev 291037)
+++ trunk/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp	2022-03-09 12:43:36 UTC (rev 291038)
@@ -32,6 +32,7 @@
 #include "MemoryPressureMonitor.h"
 #include "WebMemoryPressureHandler.h"
 #include "WebProcessCreationParameters.h"
+#include <_javascript_Core/RemoteInspector.h>
 #include <WebCore/PlatformDisplay.h>
 #include <wtf/FileSystem.h>
 
@@ -118,6 +119,8 @@
         parameters.applicationID = g_application_get_application_id(app);
     parameters.applicationName = g_get_application_name();
 
+    parameters.inspectorServerAddress = Inspector::RemoteInspector::inspectorServerAddress();
+
 #if USE(ATSPI)
     static const char* accessibilityBusAddress = getenv("WEBKIT_A11Y_BUS_ADDRESS");
     parameters.accessibilityBusAddress = accessibilityBusAddress ? String::fromUTF8(accessibilityBusAddress) : WebCore::PlatformDisplay::sharedDisplay().accessibilityBusAddress();

Modified: trunk/Source/WebKit/WebProcess/glib/WebProcessGLib.cpp (291037 => 291038)


--- trunk/Source/WebKit/WebProcess/glib/WebProcessGLib.cpp	2022-03-09 12:37:00 UTC (rev 291037)
+++ trunk/Source/WebKit/WebProcess/glib/WebProcessGLib.cpp	2022-03-09 12:43:36 UTC (rev 291038)
@@ -31,6 +31,7 @@
 #include "WebKitWebExtensionPrivate.h"
 #include "WebPage.h"
 #include "WebProcessCreationParameters.h"
+#include <_javascript_Core/RemoteInspector.h>
 
 #if USE(GSTREAMER)
 #include <WebCore/GStreamerCommon.h>
@@ -152,6 +153,9 @@
     if (!parameters.applicationName.isEmpty())
         WebCore::setApplicationName(parameters.applicationName);
 
+    if (!parameters.inspectorServerAddress.isNull())
+        Inspector::RemoteInspector::setInspectorServerAddress(WTFMove(parameters.inspectorServerAddress));
+
 #if USE(ATSPI)
     AccessibilityAtspi::singleton().connect(parameters.accessibilityBusAddress);
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to