summaryrefslogtreecommitdiffstats
path: root/src/core/web_engine_context.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/web_engine_context.cpp')
-rw-r--r--src/core/web_engine_context.cpp110
1 files changed, 88 insertions, 22 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index a42565c2b..286842a20 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -49,14 +49,20 @@
#include "base/task/sequence_manager/thread_controller_with_message_pump_impl.h"
#include "base/threading/thread_restrictions.h"
#include "cc/base/switches.h"
+#include "content/gpu/gpu_child_thread.h"
+#include "content/browser/compositor/surface_utils.h"
+#include "components/viz/host/host_frame_sink_manager.h"
#if QT_CONFIG(webengine_printing_and_pdf)
#include "chrome/browser/printing/print_job_manager.h"
#include "components/printing/browser/features.h"
#endif
+#include "components/discardable_memory/service/discardable_shared_memory_manager.h"
#include "components/viz/common/features.h"
#include "components/web_cache/browser/web_cache_manager.h"
+#include "content/app/service_manager_environment.h"
#include "content/browser/devtools/devtools_http_handler.h"
#include "content/browser/scheduler/browser_task_executor.h"
+#include "content/browser/startup_data_impl.h"
#include "content/browser/startup_helper.h"
#include "content/public/app/content_main.h"
#include "content/public/app/content_main_runner.h"
@@ -72,7 +78,6 @@
#include "content/public/common/main_function_params.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
-#include "gpu/ipc/host/gpu_switches.h"
#include "media/audio/audio_manager.h"
#include "media/base/media_switches.h"
#include "mojo/core/embedder/embedder.h"
@@ -82,6 +87,7 @@
#include "services/network/public/cpp/network_switches.h"
#include "services/resource_coordinator/public/cpp/resource_coordinator_features.h"
#include "services/service_manager/sandbox/switches.h"
+#include "services/tracing/public/cpp/tracing_features.h"
#include "third_party/blink/public/common/features.h"
#include "ui/events/event_switches.h"
#include "ui/native_theme/native_theme_features.h"
@@ -91,6 +97,10 @@
#include "content/public/app/sandbox_helper_win.h"
#endif // OS_WIN
+#if defined(Q_OS_MACOS)
+#include "base/mac/foundation_util.h"
+#endif
+
#ifndef QT_NO_ACCESSIBILITY
#include "accessibility_activation_observer.h"
#endif
@@ -175,6 +185,18 @@ void dummyGetPluginCallback(const std::vector<content::WebPluginInfo>&)
namespace QtWebEngineCore {
+#if defined(Q_OS_WIN)
+sandbox::SandboxInterfaceInfo *staticSandboxInterfaceInfo(sandbox::SandboxInterfaceInfo *info)
+{
+ static sandbox::SandboxInterfaceInfo *g_info = nullptr;
+ if (info) {
+ Q_ASSERT(g_info == nullptr);
+ g_info = info;
+ }
+ return g_info;
+}
+#endif
+
extern std::unique_ptr<base::MessagePump> messagePumpFactory();
bool usingSoftwareDynamicGL()
@@ -192,6 +214,26 @@ bool usingSoftwareDynamicGL()
#endif
}
+static bool waitForViz = false;
+static void completeVizCleanup()
+{
+ waitForViz = false;
+}
+
+static void cleanupVizProcess()
+{
+ auto gpuChildThread = content::GpuChildThread::instance();
+ if (!gpuChildThread)
+ return;
+ auto vizMain = gpuChildThread->viz_main();
+ auto vizCompositorThreadRunner = vizMain->viz_compositor_thread_runner();
+ if (!vizCompositorThreadRunner)
+ return;
+ waitForViz = true;
+ content::GetHostFrameSinkManager()->SetConnectionLostCallback(base::DoNothing());
+ vizCompositorThreadRunner->CleanupForShutdown(base::BindOnce(&completeVizCleanup));
+}
+
scoped_refptr<QtWebEngineCore::WebEngineContext> WebEngineContext::m_handle;
bool WebEngineContext::m_destroyed = false;
@@ -238,14 +280,21 @@ void WebEngineContext::destroy()
if (m_devtoolsServer)
m_devtoolsServer->stop();
- // Normally the GPU thread is shut down when the GpuProcessHost is destroyed
- // on IO thread (triggered by ~BrowserMainRunner). But by that time the UI
- // task runner is not working anymore so we need to do this earlier.
- destroyGpuProcess();
base::MessagePump::Delegate *delegate =
static_cast<base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl *>(
m_runLoop->delegate_);
+ // Normally the GPU thread is shut down when the GpuProcessHost is destroyed
+ // on IO thread (triggered by ~BrowserMainRunner). But by that time the UI
+ // task runner is not working anymore so we need to do this earlier.
+ if (features::IsVizDisplayCompositorEnabled()) {
+ cleanupVizProcess();
+ while (waitForViz) {
+ while (delegate->DoWork()){}
+ QThread::msleep(50);
+ }
+ }
+ destroyGpuProcess();
// Flush the UI message loop before quitting.
while (delegate->DoWork()) { }
@@ -278,6 +327,11 @@ void WebEngineContext::destroy()
// Destroy the main runner, this stops main message loop
m_browserRunner.reset();
+ // These would normally be in the content-runner, but we allocated them separately:
+ m_startupData.reset();
+ m_serviceManagerEnvironment.reset();
+ m_discardableSharedMemoryManager.reset();
+
// Destroying content-runner will force Chromium at_exit calls to run, and
// reap child processes.
m_contentRunner.reset();
@@ -366,6 +420,7 @@ ProxyAuthentication WebEngineContext::qProxyNetworkAuthentication(QString host,
const static char kChromiumFlagsEnv[] = "QTWEBENGINE_CHROMIUM_FLAGS";
const static char kDisableSandboxEnv[] = "QTWEBENGINE_DISABLE_SANDBOX";
+const static char kDisableInProcGpuThread[] = "QTWEBENGINE_DISABLE_GPU_THREAD";
static void appendToFeatureList(std::string &featureList, const char *feature)
{
@@ -390,7 +445,13 @@ WebEngineContext::WebEngineContext()
: m_mainDelegate(new ContentMainDelegateQt)
, m_globalQObject(new QObject())
{
- base::ThreadPool::Create("Browser");
+#if defined(Q_OS_MACOS)
+ // The bundled handling is currently both completely broken in Chromium,
+ // and unnecessary for us.
+ base::mac::SetOverrideAmIBundled(false);
+#endif
+
+ base::ThreadPoolInstance::Create("Browser");
m_contentRunner.reset(content::ContentMainRunner::Create());
m_browserRunner = content::BrowserMainRunner::Create();
@@ -436,9 +497,7 @@ WebEngineContext::WebEngineContext()
// Enable sandboxing on OS X and Linux (Desktop / Embedded) by default.
bool disable_sandbox = qEnvironmentVariableIsSet(kDisableSandboxEnv);
if (!disable_sandbox) {
-#if defined(Q_OS_WIN)
- parsedCommandLine->AppendSwitch(service_manager::switches::kNoSandbox);
-#elif defined(Q_OS_LINUX)
+#if defined(Q_OS_LINUX)
parsedCommandLine->AppendSwitch(service_manager::switches::kDisableSetuidSandbox);
#endif
} else {
@@ -460,8 +519,6 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
// Same problem with Pepper using OpenGL images.
parsedCommandLine->AppendSwitch(switches::kDisablePepper3DImageChromium);
- // Same problem with select popups.
- parsedCommandLine->AppendSwitch(switches::kDisableNativeGpuMemoryBuffers);
#endif
#if defined(Q_OS_WIN)
@@ -487,11 +544,11 @@ WebEngineContext::WebEngineContext()
if (isDesktopGLOrSoftware || isGLES2Context)
parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext);
#endif
-
- bool threadedGpu = true;
+ bool threadedGpu = false;
#ifndef QT_NO_OPENGL
threadedGpu = QOpenGLContext::supportsThreadedOpenGL();
#endif
+ threadedGpu = threadedGpu && !qEnvironmentVariableIsSet(kDisableInProcGpuThread);
bool enableViz = ((threadedGpu && !parsedCommandLine->HasSwitch("disable-viz-display-compositor"))
|| parsedCommandLine->HasSwitch("enable-viz-display-compositor"));
@@ -505,10 +562,11 @@ WebEngineContext::WebEngineContext()
// This is deprecated behavior, and will be removed in a future Chromium version, as per
// upstream Chromium commit ba52f56207a4b9d70b34880fbff2352e71a06422.
appendToFeatureList(enableFeatures, features::kAllowContentInitiatedDataUrlNavigations.name);
+
+ appendToFeatureList(enableFeatures, features::kTracingServiceInProcess.name);
+
// The video-capture service is not functioning at this moment (since 69)
appendToFeatureList(disableFeatures, features::kMojoVideoCapture.name);
- // Breaks WebEngineNewViewRequest.userInitiated API (since 73)
- appendToFeatureList(disableFeatures, features::kUserActivationV2.name);
// We do not yet support the network-service, but it is enabled by default since 75.
appendToFeatureList(disableFeatures, network::features::kNetworkService.name);
@@ -522,6 +580,7 @@ WebEngineContext::WebEngineContext()
// Explicitly tell Chromium about default-on features we do not support
appendToFeatureList(disableFeatures, features::kBackgroundFetch.name);
appendToFeatureList(disableFeatures, features::kOriginTrials.name);
+ appendToFeatureList(disableFeatures, features::kSmsReceiver.name);
appendToFeatureList(disableFeatures, features::kWebAuth.name);
appendToFeatureList(disableFeatures, features::kWebAuthCable.name);
appendToFeatureList(disableFeatures, features::kWebPayments.name);
@@ -536,8 +595,6 @@ WebEngineContext::WebEngineContext()
}
if (!enableViz) {
- // Surface synchronization breaks our current graphics integration (since 65)
- appendToFeatureList(disableFeatures, features::kEnableSurfaceSynchronization.name);
// Viz Display Compositor is enabled by default since 73. Doesn't work for us (also implies SurfaceSynchronization)
appendToFeatureList(disableFeatures, features::kVizDisplayCompositor.name);
// VideoSurfaceLayer is enabled by default since 75. We don't support it.
@@ -569,7 +626,7 @@ WebEngineContext::WebEngineContext()
|| usingANGLE())
{
if (qt_gl_global_share_context()->isOpenGLES()) {
- glType = gl::kGLImplementationEGLName;
+ glType = usingANGLE() ? gl::kGLImplementationANGLEName : gl::kGLImplementationEGLName;
} else {
QOpenGLContext context;
QSurfaceFormat format;
@@ -638,27 +695,36 @@ WebEngineContext::WebEngineContext()
content::ContentMainParams contentMainParams(m_mainDelegate.get());
#if defined(OS_WIN)
+ contentMainParams.sandbox_info = staticSandboxInterfaceInfo();
sandbox::SandboxInterfaceInfo sandbox_info = {0};
- content::InitializeSandboxInfo(&sandbox_info);
- contentMainParams.sandbox_info = &sandbox_info;
+ if (!contentMainParams.sandbox_info) {
+ content::InitializeSandboxInfo(&sandbox_info);
+ contentMainParams.sandbox_info = &sandbox_info;
+ }
#endif
m_contentRunner->Initialize(contentMainParams);
- mojo::core::Init();
+ mojo::core::Configuration mojoConfiguration;
+ mojoConfiguration.is_broker_process = true;
+ mojo::core::Init(mojoConfiguration);
// This block mirrors ContentMainRunnerImpl::RunServiceManager():
m_mainDelegate->PreCreateMainMessageLoop();
- base::MessageLoop::InitMessagePumpForUIFactory(messagePumpFactory);
+ base::MessagePump::OverrideMessagePumpForUIFactory(messagePumpFactory);
content::BrowserTaskExecutor::Create();
m_mainDelegate->PostEarlyInitialization(false);
content::StartBrowserThreadPool();
content::BrowserTaskExecutor::PostFeatureListSetup();
+ m_discardableSharedMemoryManager = std::make_unique<discardable_memory::DiscardableSharedMemoryManager>();
+ m_serviceManagerEnvironment = std::make_unique<content::ServiceManagerEnvironment>(content::BrowserTaskExecutor::CreateIOThread());
+ m_startupData = m_serviceManagerEnvironment->CreateBrowserStartupData();
// Once the MessageLoop has been created, attach a top-level RunLoop.
m_runLoop.reset(new base::RunLoop);
m_runLoop->BeforeRun();
content::MainFunctionParams mainParams(*base::CommandLine::ForCurrentProcess());
+ mainParams.startup_data = m_startupData.get();
m_browserRunner->Initialize(mainParams);
m_devtoolsServer.reset(new DevToolsServerQt());