Skip to content
Permalink
Browse files
[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/JavaScriptCore:

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.


Canonical link: https://commits.webkit.org/248212@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291038 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carlosgcampos committed Mar 9, 2022
1 parent ea7bd5c commit 1693bf85775b25ee0e39d44b721b96691f2dca2d
Showing 9 changed files with 71 additions and 4 deletions.
@@ -1,3 +1,18 @@
2022-03-09 Carlos Garcia Campos <cgarcia@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 <rmorisset@apple.com>

[WTF] LikelyDenseUnsignedIntegerSet::add can cause a reindexing of the entire bit vector with every call in the worst case
@@ -120,6 +120,10 @@ class JS_EXPORT_PRIVATE RemoteInspector final

#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();
@@ -247,6 +251,9 @@ class JS_EXPORT_PRIVATE RemoteInspector final
#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.
@@ -38,6 +38,8 @@

namespace Inspector {

CString RemoteInspector::s_inspectorServerAddress;

RemoteInspector& RemoteInspector::singleton()
{
static LazyNeverDestroyed<RemoteInspector> shared;
@@ -50,7 +52,7 @@ RemoteInspector& RemoteInspector::singleton()

RemoteInspector::RemoteInspector()
{
if (g_getenv("WEBKIT_INSPECTOR_SERVER"))
if (!s_inspectorServerAddress.isNull())
start();
}

@@ -65,14 +67,14 @@ void RemoteInspector::start()
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;
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);
}

@@ -1,3 +1,27 @@
2022-03-09 Carlos Garcia Campos <cgarcia@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 <youenn@apple.com>

Scope capture sources by page identifiers
@@ -213,6 +213,7 @@ void WebProcessCreationParameters::encode(IPC::Encoder& encoder) const
#if USE(GLIB)
encoder << applicationID;
encoder << applicationName;
encoder << inspectorServerAddress;
#endif

#if USE(ATSPI)
@@ -577,6 +578,12 @@ bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreat
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)
@@ -255,6 +255,7 @@ struct WebProcessCreationParameters {
#if USE(GLIB)
String applicationID;
String applicationName;
CString inspectorServerAddress;
#endif

#if USE(ATSPI)
@@ -27,6 +27,7 @@
#include "WebKitInitialize.h"

#include "WebKit2Initialize.h"
#include <JavaScriptCore/RemoteInspector.h>
#include <JavaScriptCore/RemoteInspectorServer.h>
#include <mutex>
#include <wtf/glib/GUniquePtr.h>
@@ -53,7 +54,10 @@ static void initializeRemoteInspectorServer(const char* address)
if (!port)
return;

Inspector::RemoteInspectorServer::singleton().start(inspectorAddress.get(), port);
if (!Inspector::RemoteInspectorServer::singleton().start(inspectorAddress.get(), port))
return;

Inspector::RemoteInspector::setInspectorServerAddress(address);
}
#endif

@@ -32,6 +32,7 @@
#include "MemoryPressureMonitor.h"
#include "WebMemoryPressureHandler.h"
#include "WebProcessCreationParameters.h"
#include <JavaScriptCore/RemoteInspector.h>
#include <WebCore/PlatformDisplay.h>
#include <wtf/FileSystem.h>

@@ -118,6 +119,8 @@ void WebProcessPool::platformInitializeWebProcess(const WebProcessProxy& process
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();
@@ -31,6 +31,7 @@
#include "WebKitWebExtensionPrivate.h"
#include "WebPage.h"
#include "WebProcessCreationParameters.h"
#include <JavaScriptCore/RemoteInspector.h>

#if USE(GSTREAMER)
#include <WebCore/GStreamerCommon.h>
@@ -152,6 +153,9 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters& para
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

0 comments on commit 1693bf8

Please sign in to comment.