Skip to content
Permalink
Browse files
[GLIB] RemoteInspectorServer is not started if WebKitWebContext is no…
…t created already created

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

Reviewed by Carlos Garcia Campos.

Added a WebKit/UIProcess/API/glib/WebKitInitialize what implements
its own webkitInitialize() to ensure the inspector server is
initialized as early as possible, before other api calls that would
depend on the inspector server being running.

The RemoteInspectorServer initialization is not longer
asociated to the initialization of the WebProcessPoolGLib.

The webkitInitialize() extends the shared InitializeWebKit2();
and also includes the initialization of the RemoteInspectorServer
so the initialization of the remote inspector server can be now
triggered by the initialization of many other API objects too:
WebKitInputMethodContext, WebKitSettings, WebKitUserContentManager,
WebKitWebContext, WebKitWebsiteDataManager,
WebKitUserContentFilterStore, WebKitWebViewBase.

* SourcesGTK.txt:
* SourcesWPE.txt:
* UIProcess/API/glib/WebKitInitialize.cpp: Added.
(WebKit::initializeRemoteInspectorServer):
(WebKit::webkitInitialize):
* UIProcess/API/glib/WebKitInitialize.h: Added.
* UIProcess/API/glib/WebKitInputMethodContext.cpp:
(webkit_input_method_context_class_init):
* UIProcess/API/glib/WebKitSettings.cpp:
(webkit_settings_class_init):
* UIProcess/API/glib/WebKitUserContentFilterStore.cpp:
(webkit_user_content_filter_store_class_init):
* UIProcess/API/glib/WebKitUserContentManager.cpp:
* UIProcess/API/glib/WebKitWebContext.cpp:
(webkit_web_context_class_init):
* UIProcess/API/glib/WebKitWebsiteDataManager.cpp:
(webkit_website_data_manager_class_init):
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkit_web_view_base_class_init):
* UIProcess/glib/WebProcessPoolGLib.cpp:
(WebKit::WebProcessPool::platformInitialize):
(WebKit::initializeRemoteInspectorServer): Deleted.


Canonical link: https://commits.webkit.org/229087@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
psaavedra committed Sep 8, 2020
1 parent 9f3d2e4 commit f9453fb6f9ef777110b48f7bc083e7b75a5f3b9f
Showing 13 changed files with 175 additions and 36 deletions.
@@ -1,3 +1,49 @@
2020-09-08 Pablo Saavedra <psaavedra@igalia.com>

[GLIB] RemoteInspectorServer is not started if WebKitWebContext is not created already created
https://bugs.webkit.org/show_bug.cgi?id=216120

Reviewed by Carlos Garcia Campos.

Added a WebKit/UIProcess/API/glib/WebKitInitialize what implements
its own webkitInitialize() to ensure the inspector server is
initialized as early as possible, before other api calls that would
depend on the inspector server being running.

The RemoteInspectorServer initialization is not longer
asociated to the initialization of the WebProcessPoolGLib.

The webkitInitialize() extends the shared InitializeWebKit2();
and also includes the initialization of the RemoteInspectorServer
so the initialization of the remote inspector server can be now
triggered by the initialization of many other API objects too:
WebKitInputMethodContext, WebKitSettings, WebKitUserContentManager,
WebKitWebContext, WebKitWebsiteDataManager,
WebKitUserContentFilterStore, WebKitWebViewBase.

* SourcesGTK.txt:
* SourcesWPE.txt:
* UIProcess/API/glib/WebKitInitialize.cpp: Added.
(WebKit::initializeRemoteInspectorServer):
(WebKit::webkitInitialize):
* UIProcess/API/glib/WebKitInitialize.h: Added.
* UIProcess/API/glib/WebKitInputMethodContext.cpp:
(webkit_input_method_context_class_init):
* UIProcess/API/glib/WebKitSettings.cpp:
(webkit_settings_class_init):
* UIProcess/API/glib/WebKitUserContentFilterStore.cpp:
(webkit_user_content_filter_store_class_init):
* UIProcess/API/glib/WebKitUserContentManager.cpp:
* UIProcess/API/glib/WebKitWebContext.cpp:
(webkit_web_context_class_init):
* UIProcess/API/glib/WebKitWebsiteDataManager.cpp:
(webkit_website_data_manager_class_init):
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkit_web_view_base_class_init):
* UIProcess/glib/WebProcessPoolGLib.cpp:
(WebKit::WebProcessPool::platformInitialize):
(WebKit::initializeRemoteInspectorServer): Deleted.

2020-09-07 Commit Queue <commit-queue@webkit.org>

Unreviewed, reverting r266645.
@@ -141,6 +141,7 @@ UIProcess/API/glib/WebKitFormSubmissionRequest.cpp @no-unify
UIProcess/API/glib/WebKitGeolocationManager.cpp @no-unify
UIProcess/API/glib/WebKitGeolocationPermissionRequest.cpp @no-unify
UIProcess/API/glib/WebKitIconLoadingClient.cpp @no-unify
UIProcess/API/glib/WebKitInitialize.cpp @no-unify
UIProcess/API/glib/WebKitInjectedBundleClient.cpp @no-unify
UIProcess/API/glib/WebKitInputMethodContext.cpp @no-unify
UIProcess/API/glib/WebKitInstallMissingMediaPluginsPermissionRequest.cpp @no-unify
@@ -132,6 +132,7 @@ UIProcess/API/glib/WebKitFormClient.cpp @no-unify
UIProcess/API/glib/WebKitFormSubmissionRequest.cpp @no-unify
UIProcess/API/glib/WebKitGeolocationManager.cpp @no-unify
UIProcess/API/glib/WebKitGeolocationPermissionRequest.cpp @no-unify
UIProcess/API/glib/WebKitInitialize.cpp @no-unify
UIProcess/API/glib/WebKitInjectedBundleClient.cpp @no-unify
UIProcess/API/glib/WebKitInputMethodContext.cpp @no-unify
UIProcess/API/glib/WebKitInstallMissingMediaPluginsPermissionRequest.cpp @no-unify
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2020 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include "WebKitInitialize.h"

#include <JavaScriptCore/RemoteInspectorServer.h>
#include <WebKit/Shared/WebKit2Initialize.h>
#include <wtf/glib/GUniquePtr.h>

namespace WebKit {

#if ENABLE(REMOTE_INSPECTOR)
static void initializeRemoteInspectorServer(const char* address)
{
if (Inspector::RemoteInspectorServer::singleton().isRunning())
return;

if (!address[0])
return;

GUniquePtr<char> inspectorAddress(g_strdup(address));
char* portPtr = g_strrstr(inspectorAddress.get(), ":");
if (!portPtr)
return;

*portPtr = '\0';
portPtr++;
guint64 port = g_ascii_strtoull(portPtr, nullptr, 10);
if (!port)
return;

Inspector::RemoteInspectorServer::singleton().start(inspectorAddress.get(), port);
}
#endif

void webkitInitialize()
{
static std::once_flag onceFlag;

std::call_once(onceFlag, [] {
InitializeWebKit2();
#if ENABLE(REMOTE_INSPECTOR)
if (const char* address = g_getenv("WEBKIT_INSPECTOR_SERVER"))
initializeRemoteInspectorServer(address);
#endif
});
}

} // namespace WebKit
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2020 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

namespace WebKit {

void webkitInitialize();

}
@@ -21,6 +21,7 @@
#include "WebKitInputMethodContext.h"

#include "WebKitEnumTypes.h"
#include "WebKitInitialize.h"
#include "WebKitInputMethodContextPrivate.h"
#include "WebKitWebView.h"
#include <glib/gi18n-lib.h>
@@ -203,6 +204,8 @@ static void webkitInputMethodContextGetProperty(GObject* object, guint propId, G

static void webkit_input_method_context_class_init(WebKitInputMethodContextClass* klass)
{
WebKit::webkitInitialize();

GObjectClass* gObjectClass = G_OBJECT_CLASS(klass);
gObjectClass->set_property = webkitInputMethodContextSetProperty;
gObjectClass->get_property = webkitInputMethodContextGetProperty;
@@ -32,6 +32,7 @@
#include "WebKitSettings.h"

#include "WebKitEnumTypes.h"
#include "WebKitInitialize.h"
#include "WebKitSettingsPrivate.h"
#include "WebPageProxy.h"
#include "WebPreferences.h"
@@ -606,6 +607,8 @@ static void webKitSettingsGetProperty(GObject* object, guint propId, GValue* val

static void webkit_settings_class_init(WebKitSettingsClass* klass)
{
webkitInitialize();

GObjectClass* gObjectClass = G_OBJECT_CLASS(klass);
gObjectClass->constructed = webKitSettingsConstructed;
gObjectClass->dispose = webKitSettingsDispose;
@@ -29,6 +29,7 @@
#include "APIContentRuleList.h"
#include "APIContentRuleListStore.h"
#include "WebKitError.h"
#include "WebKitInitialize.h"
#include "WebKitUserContent.h"
#include "WebKitUserContentPrivate.h"
#include <WebCore/ContentExtensionError.h>
@@ -40,6 +41,8 @@
#include <wtf/glib/GUniquePtr.h>
#include <wtf/glib/WTFGType.h>

using namespace WebKit;

/**
* SECTION: WebKitUserContentFilterStore
* @Short_description: Handles storage of user content filters on disk.
@@ -116,6 +119,8 @@ static void webkitUserContentFilterStoreConstructed(GObject* object)

static void webkit_user_content_filter_store_class_init(WebKitUserContentFilterStoreClass* storeClass)
{
webkitInitialize();

GObjectClass* gObjectClass = G_OBJECT_CLASS(storeClass);

gObjectClass->get_property = webkitUserContentFilterStoreGetProperty;
@@ -22,6 +22,7 @@

#include "APISerializedScriptValue.h"
#include "InjectUserScriptImmediately.h"
#include "WebKitInitialize.h"
#include "WebKitJavascriptResultPrivate.h"
#include "WebKitUserContentManagerPrivate.h"
#include "WebKitUserContentPrivate.h"
@@ -78,6 +79,8 @@ static guint signals[LAST_SIGNAL] = { 0, };

static void webkit_user_content_manager_class_init(WebKitUserContentManagerClass* klass)
{
webkitInitialize();

GObjectClass* gObjectClass = G_OBJECT_CLASS(klass);

/**
@@ -32,12 +32,12 @@
#include "TextCheckerState.h"
#include "WebAutomationSession.h"
#include "WebCertificateInfo.h"
#include "WebKit2Initialize.h"
#include "WebKitAutomationSessionPrivate.h"
#include "WebKitDownloadClient.h"
#include "WebKitDownloadPrivate.h"
#include "WebKitFaviconDatabasePrivate.h"
#include "WebKitGeolocationManagerPrivate.h"
#include "WebKitInitialize.h"
#include "WebKitInjectedBundleClient.h"
#include "WebKitNetworkProxySettingsPrivate.h"
#include "WebKitNotificationProvider.h"
@@ -463,13 +463,13 @@ static void webkitWebContextDispose(GObject* object)

static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass)
{
webkitInitialize();

GObjectClass* gObjectClass = G_OBJECT_CLASS(webContextClass);

bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");

InitializeWebKit2();

gObjectClass->get_property = webkitWebContextGetProperty;
gObjectClass->set_property = webkitWebContextSetProperty;
gObjectClass->constructed = webkitWebContextConstructed;
@@ -21,6 +21,7 @@
#include "WebKitWebsiteDataManager.h"

#include "WebKitCookieManagerPrivate.h"
#include "WebKitInitialize.h"
#include "WebKitPrivate.h"
#include "WebKitWebsiteDataManagerPrivate.h"
#include "WebKitWebsiteDataPrivate.h"
@@ -244,6 +245,8 @@ static void webkitWebsiteDataManagerConstructed(GObject* object)

static void webkit_website_data_manager_class_init(WebKitWebsiteDataManagerClass* findClass)
{
webkitInitialize();

GObjectClass* gObjectClass = G_OBJECT_CLASS(findClass);

gObjectClass->get_property = webkitWebsiteDataManagerGetProperty;
@@ -46,6 +46,7 @@
#include "WebInspectorProxy.h"
#include "WebKit2Initialize.h"
#include "WebKitEmojiChooser.h"
#include "WebKitInitialize.h"
#include "WebKitInputMethodContextImplGtk.h"
#include "WebKitWebViewAccessible.h"
#include "WebKitWebViewBaseInternal.h"
@@ -2024,9 +2025,9 @@ static void webkit_web_view_base_class_init(WebKitWebViewBaseClass* webkitWebVie
#endif

// Before creating a WebKitWebViewBasePriv we need to be sure that WebKit is started.
// Usually starting a context triggers InitializeWebKit2, but in case
// Usually starting a context triggers webkitInitialize, but in case
// we create a view without asking before for a default_context we get a crash.
WebKit::InitializeWebKit2();
WebKit::webkitInitialize();

gtk_widget_class_set_css_name(widgetClass, "webkitwebview");
}
@@ -31,10 +31,8 @@
#include "LegacyGlobalSettings.h"
#include "WebMemoryPressureHandler.h"
#include "WebProcessCreationParameters.h"
#include <JavaScriptCore/RemoteInspectorServer.h>
#include <WebCore/PlatformDisplay.h>
#include <wtf/FileSystem.h>
#include <wtf/glib/GUniquePtr.h>

#if USE(GSTREAMER)
#include <WebCore/GStreamerCommon.h>
@@ -54,30 +52,6 @@

namespace WebKit {

#if ENABLE(REMOTE_INSPECTOR)
static void initializeRemoteInspectorServer(const char* address)
{
if (Inspector::RemoteInspectorServer::singleton().isRunning())
return;

if (!address[0])
return;

GUniquePtr<char> inspectorAddress(g_strdup(address));
char* portPtr = g_strrstr(inspectorAddress.get(), ":");
if (!portPtr)
return;

*portPtr = '\0';
portPtr++;
guint64 port = g_ascii_strtoull(portPtr, nullptr, 10);
if (!port)
return;

Inspector::RemoteInspectorServer::singleton().start(inspectorAddress.get(), port);
}
#endif

static bool memoryPressureMonitorDisabled()
{
static const char* disableMemoryPressureMonitor = getenv("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR");
@@ -92,11 +66,6 @@ void WebProcessPool::platformInitialize()
if (const char* forceComplexText = getenv("WEBKIT_FORCE_COMPLEX_TEXT"))
m_alwaysUsesComplexTextCodePath = !strcmp(forceComplexText, "1");

#if ENABLE(REMOTE_INSPECTOR)
if (const char* address = g_getenv("WEBKIT_INSPECTOR_SERVER"))
initializeRemoteInspectorServer(address);
#endif

if (!memoryPressureMonitorDisabled())
installMemoryPressureHandler();
}

0 comments on commit f9453fb

Please sign in to comment.