feat: support ELECTRON_DEFAULT_ERROR_MODE in the GPU process (#17728)
This commit is contained in:
parent
d87b3ead76
commit
fcf0af15de
8 changed files with 110 additions and 0 deletions
1
BUILD.gn
1
BUILD.gn
|
@ -436,6 +436,7 @@ static_library("electron_lib") {
|
||||||
"//content/public/browser",
|
"//content/public/browser",
|
||||||
"//content/public/child",
|
"//content/public/child",
|
||||||
"//content/public/common:service_names",
|
"//content/public/common:service_names",
|
||||||
|
"//content/public/gpu",
|
||||||
"//content/public/renderer",
|
"//content/public/renderer",
|
||||||
"//content/public/utility",
|
"//content/public/utility",
|
||||||
"//device/bluetooth",
|
"//device/bluetooth",
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "atom/app/atom_content_client.h"
|
#include "atom/app/atom_content_client.h"
|
||||||
#include "atom/browser/atom_browser_client.h"
|
#include "atom/browser/atom_browser_client.h"
|
||||||
|
#include "atom/browser/atom_gpu_client.h"
|
||||||
#include "atom/browser/feature_list.h"
|
#include "atom/browser/feature_list.h"
|
||||||
#include "atom/browser/relauncher.h"
|
#include "atom/browser/relauncher.h"
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
|
@ -262,6 +263,11 @@ content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() {
|
||||||
return browser_client_.get();
|
return browser_client_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content::ContentGpuClient* AtomMainDelegate::CreateContentGpuClient() {
|
||||||
|
gpu_client_.reset(new AtomGpuClient);
|
||||||
|
return gpu_client_.get();
|
||||||
|
}
|
||||||
|
|
||||||
content::ContentRendererClient*
|
content::ContentRendererClient*
|
||||||
AtomMainDelegate::CreateContentRendererClient() {
|
AtomMainDelegate::CreateContentRendererClient() {
|
||||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||||
|
|
|
@ -27,6 +27,7 @@ class AtomMainDelegate : public content::ContentMainDelegate {
|
||||||
void PreCreateMainMessageLoop() override;
|
void PreCreateMainMessageLoop() override;
|
||||||
void PostEarlyInitialization(bool is_running_tests) override;
|
void PostEarlyInitialization(bool is_running_tests) override;
|
||||||
content::ContentBrowserClient* CreateContentBrowserClient() override;
|
content::ContentBrowserClient* CreateContentBrowserClient() override;
|
||||||
|
content::ContentGpuClient* CreateContentGpuClient() override;
|
||||||
content::ContentRendererClient* CreateContentRendererClient() override;
|
content::ContentRendererClient* CreateContentRendererClient() override;
|
||||||
content::ContentUtilityClient* CreateContentUtilityClient() override;
|
content::ContentUtilityClient* CreateContentUtilityClient() override;
|
||||||
int RunProcess(
|
int RunProcess(
|
||||||
|
@ -48,6 +49,7 @@ class AtomMainDelegate : public content::ContentMainDelegate {
|
||||||
|
|
||||||
std::unique_ptr<content::ContentBrowserClient> browser_client_;
|
std::unique_ptr<content::ContentBrowserClient> browser_client_;
|
||||||
std::unique_ptr<content::ContentClient> content_client_;
|
std::unique_ptr<content::ContentClient> content_client_;
|
||||||
|
std::unique_ptr<content::ContentGpuClient> gpu_client_;
|
||||||
std::unique_ptr<content::ContentRendererClient> renderer_client_;
|
std::unique_ptr<content::ContentRendererClient> renderer_client_;
|
||||||
std::unique_ptr<content::ContentUtilityClient> utility_client_;
|
std::unique_ptr<content::ContentUtilityClient> utility_client_;
|
||||||
|
|
||||||
|
|
25
atom/browser/atom_gpu_client.cc
Normal file
25
atom/browser/atom_gpu_client.cc
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright (c) 2019 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "atom/browser/atom_gpu_client.h"
|
||||||
|
|
||||||
|
#include "base/environment.h"
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
AtomGpuClient::AtomGpuClient() = default;
|
||||||
|
|
||||||
|
void AtomGpuClient::PreCreateMessageLoop() {
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
auto env = base::Environment::Create();
|
||||||
|
if (env->HasVar("ELECTRON_DEFAULT_ERROR_MODE"))
|
||||||
|
SetErrorMode(GetErrorMode() & ~SEM_NOGPFAULTERRORBOX);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace atom
|
25
atom/browser/atom_gpu_client.h
Normal file
25
atom/browser/atom_gpu_client.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright (c) 2019 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ATOM_BROWSER_ATOM_GPU_CLIENT_H_
|
||||||
|
#define ATOM_BROWSER_ATOM_GPU_CLIENT_H_
|
||||||
|
|
||||||
|
#include "content/public/gpu/content_gpu_client.h"
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
class AtomGpuClient : public content::ContentGpuClient {
|
||||||
|
public:
|
||||||
|
AtomGpuClient();
|
||||||
|
|
||||||
|
// content::ContentGpuClient:
|
||||||
|
void PreCreateMessageLoop() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(AtomGpuClient);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atom
|
||||||
|
|
||||||
|
#endif // ATOM_BROWSER_ATOM_GPU_CLIENT_H_
|
|
@ -232,6 +232,8 @@ filenames = {
|
||||||
"atom/browser/atom_browser_context.h",
|
"atom/browser/atom_browser_context.h",
|
||||||
"atom/browser/atom_download_manager_delegate.cc",
|
"atom/browser/atom_download_manager_delegate.cc",
|
||||||
"atom/browser/atom_download_manager_delegate.h",
|
"atom/browser/atom_download_manager_delegate.h",
|
||||||
|
"atom/browser/atom_gpu_client.cc",
|
||||||
|
"atom/browser/atom_gpu_client.h",
|
||||||
"atom/browser/atom_browser_main_parts.cc",
|
"atom/browser/atom_browser_main_parts.cc",
|
||||||
"atom/browser/atom_browser_main_parts.h",
|
"atom/browser/atom_browser_main_parts.h",
|
||||||
"atom/browser/atom_browser_main_parts_mac.mm",
|
"atom/browser/atom_browser_main_parts_mac.mm",
|
||||||
|
|
|
@ -76,3 +76,4 @@ viz_osr.patch
|
||||||
patch_the_ensure_gn_version_py_script_to_work_on_mac_ci.patch
|
patch_the_ensure_gn_version_py_script_to_work_on_mac_ci.patch
|
||||||
revert_roll_clang_356356_357569.patch
|
revert_roll_clang_356356_357569.patch
|
||||||
build_add_electron_tracing_category.patch
|
build_add_electron_tracing_category.patch
|
||||||
|
add_contentgpuclient_precreatemessageloop_callback.patch
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Milan Burda <milan.burda@gmail.com>
|
||||||
|
Date: Thu, 11 Apr 2019 14:49:20 +0200
|
||||||
|
Subject: Add ContentGpuClient::PreCreateMessageLoop() callback
|
||||||
|
|
||||||
|
Invoke in GpuMain after SetErrorMode, before starting the message loop.
|
||||||
|
Allows Electron to restore WER when ELECTRON_DEFAULT_ERROR_MODE is set.
|
||||||
|
|
||||||
|
This should be upstreamed
|
||||||
|
|
||||||
|
diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc
|
||||||
|
index 39e87967360a9c7a2856ce4df9c182c782efb2a5..ade3e7905d01b25128f477c68c10edd0f96626c3 100644
|
||||||
|
--- a/content/gpu/gpu_main.cc
|
||||||
|
+++ b/content/gpu/gpu_main.cc
|
||||||
|
@@ -234,6 +234,10 @@ int GpuMain(const MainFunctionParams& parameters) {
|
||||||
|
|
||||||
|
logging::SetLogMessageHandler(GpuProcessLogMessageHandler);
|
||||||
|
|
||||||
|
+ auto* client = GetContentClient()->gpu();
|
||||||
|
+ if (client)
|
||||||
|
+ client->PreCreateMessageLoop();
|
||||||
|
+
|
||||||
|
// We are experiencing what appear to be memory-stomp issues in the GPU
|
||||||
|
// process. These issues seem to be impacting the message loop and listeners
|
||||||
|
// registered to it. Create the message loop on the heap to guard against
|
||||||
|
@@ -329,7 +333,6 @@ int GpuMain(const MainFunctionParams& parameters) {
|
||||||
|
|
||||||
|
GpuProcess gpu_process(io_thread_priority);
|
||||||
|
|
||||||
|
- auto* client = GetContentClient()->gpu();
|
||||||
|
if (client)
|
||||||
|
client->PostIOThreadCreated(gpu_process.io_task_runner());
|
||||||
|
|
||||||
|
diff --git a/content/public/gpu/content_gpu_client.h b/content/public/gpu/content_gpu_client.h
|
||||||
|
index 20e31e1bd96395cb4350aa6ae84cc16c4ca2116b..d89af81ef9426c197a62027b514011afd10ea3ce 100644
|
||||||
|
--- a/content/public/gpu/content_gpu_client.h
|
||||||
|
+++ b/content/public/gpu/content_gpu_client.h
|
||||||
|
@@ -35,6 +35,10 @@ class CONTENT_EXPORT ContentGpuClient {
|
||||||
|
public:
|
||||||
|
virtual ~ContentGpuClient() {}
|
||||||
|
|
||||||
|
+ // Allows the embedder to perform platform-specific initialization before
|
||||||
|
+ // creating the message loop.
|
||||||
|
+ virtual void PreCreateMessageLoop() {}
|
||||||
|
+
|
||||||
|
// Initializes the registry. |registry| will be passed to a ConnectionFilter
|
||||||
|
// (which lives on the IO thread). Unlike other childthreads, the client must
|
||||||
|
// register additional interfaces on this registry rather than just creating
|
Loading…
Reference in a new issue