From 90af9bce6d158a9ee70d82c1c2b04825a6c58897 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 21 May 2019 16:02:14 -0700 Subject: [PATCH] feat: add app.allowRendererProcessReuse property to allow runtime disable of site instance overrides spec: add tests for the new allowRendererProcessReuse property feat: add console warnings / errors for loading non context-aware native modules * Only error if the patch is disabled * Warn all the time, this will ship in Electron 7 --- DEPS | 2 +- atom/browser/api/atom_api_app.cc | 11 +++- atom/browser/api/atom_api_app.h | 2 + atom/browser/atom_browser_client.cc | 12 ++++ atom/browser/atom_browser_client.h | 5 ++ atom/common/options_switches.cc | 2 + atom/common/options_switches.h | 1 + atom/renderer/atom_renderer_client.cc | 15 ++++- docs/api/app.md | 13 ++++ .../common/chromium/blink_world_context.patch | 10 +-- .../build_add_electron_tracing_category.patch | 2 +- .../common/chromium/can_create_window.patch | 22 +++---- ...cross_site_document_resource_handler.patch | 10 +-- .../disable_color_correct_rendering.patch | 50 +++++++-------- ...requirement_for_beforeunload_dialogs.patch | 4 +- ...screen_rendering_with_viz_compositor.patch | 64 ++++++++++--------- .../common/chromium/frame_host_manager.patch | 26 ++++---- .../render_widget_host_view_base.patch | 19 +++--- .../chromium/resource_file_conflict.patch | 6 +- .../common/chromium/webview_cross_drag.patch | 4 +- .../worker_context_will_destroy.patch | 22 +++---- spec-main/api-app-spec.ts | 20 ++++++ .../api/site-instance-overrides/index.html | 1 + .../api/site-instance-overrides/main.js | 33 ++++++++++ .../api/site-instance-overrides/package.json | 4 ++ .../api/site-instance-overrides/preload.js | 3 + 26 files changed, 240 insertions(+), 123 deletions(-) create mode 100644 spec/fixtures/api/site-instance-overrides/index.html create mode 100644 spec/fixtures/api/site-instance-overrides/main.js create mode 100644 spec/fixtures/api/site-instance-overrides/package.json create mode 100644 spec/fixtures/api/site-instance-overrides/preload.js diff --git a/DEPS b/DEPS index 93fc1946a5c11..0134d3dc97019 100644 --- a/DEPS +++ b/DEPS @@ -12,7 +12,7 @@ vars = { 'chromium_version': 'ab588d36191964c4bca8de5c320534d95606c861', 'node_version': - 'a86a4a160dc520c61a602c949a32a1bc4c0fc633', + 'dee0db9864a001ffc16440f725f4952a1a417069', 'nan_version': '960dd6c70fc9eb136efdf37b4bef18fadbc3436f', diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 3dba8915fddf9..5a9ca423e7ece 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -1286,6 +1286,13 @@ std::string App::GetUserAgentFallback() { return AtomBrowserClient::Get()->GetUserAgent(); } +void App::SetBrowserClientCanUseCustomSiteInstance(bool should_disable) { + AtomBrowserClient::Get()->SetCanUseCustomSiteInstance(should_disable); +} +bool App::CanBrowserClientUseCustomSiteInstance() { + return AtomBrowserClient::Get()->CanUseCustomSiteInstance(); +} + #if defined(OS_MACOSX) bool App::MoveToApplicationsFolder(mate::Arguments* args) { return ui::cocoa::AtomBundleMover::Move(args); @@ -1467,7 +1474,9 @@ void App::BuildPrototype(v8::Isolate* isolate, #endif .SetProperty("userAgentFallback", &App::GetUserAgentFallback, &App::SetUserAgentFallback) - .SetMethod("enableSandbox", &App::EnableSandbox); + .SetMethod("enableSandbox", &App::EnableSandbox) + .SetProperty("allowRendererProcessReuse", &App::CanBrowserClientUseCustomSiteInstance, + &App::SetBrowserClientCanUseCustomSiteInstance); } } // namespace api diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index f08b8b427aff7..c10e4b0ecbb95 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -213,6 +213,8 @@ class App : public AtomBrowserClient::Delegate, void EnableSandbox(mate::Arguments* args); void SetUserAgentFallback(const std::string& user_agent); std::string GetUserAgentFallback(); + void SetBrowserClientCanUseCustomSiteInstance(bool should_disable); + bool CanBrowserClientUseCustomSiteInstance(); #if defined(OS_MACOSX) bool MoveToApplicationsFolder(mate::Arguments* args); diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index d1c0872f19bdc..9df16333c6dc7 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -403,6 +403,14 @@ void AtomBrowserClient::OverrideWebkitPrefs(content::RenderViewHost* host, web_preferences->OverrideWebkitPrefs(prefs); } +void AtomBrowserClient::SetCanUseCustomSiteInstance(bool should_disable) { + disable_process_restart_tricks_ = should_disable; +} + +bool AtomBrowserClient::CanUseCustomSiteInstance() { + return disable_process_restart_tricks_; +} + content::ContentBrowserClient::SiteInstanceForNavigationType AtomBrowserClient::ShouldOverrideSiteInstanceForNavigation( content::RenderFrameHost* current_rfh, @@ -509,6 +517,10 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches( web_preferences->AppendCommandLineSwitches(command_line); SessionPreferences::AppendExtraCommandLineSwitches( web_contents->GetBrowserContext(), command_line); + if (CanUseCustomSiteInstance()) { + command_line->AppendSwitch( + switches::kDisableElectronSiteInstanceOverrides); + } } } diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index e30873d2074c8..e741e6b5279fb 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -67,6 +67,9 @@ class AtomBrowserClient : public content::ContentBrowserClient, std::string GetUserAgent() const override; void SetUserAgent(const std::string& user_agent); + void SetCanUseCustomSiteInstance(bool should_disable); + bool CanUseCustomSiteInstance() override; + protected: void RenderProcessWillLaunch( content::RenderProcessHost* host, @@ -253,6 +256,8 @@ class AtomBrowserClient : public content::ContentBrowserClient, std::string user_agent_override_ = ""; + bool disable_process_restart_tricks_ = false; + DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient); }; diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index f551fe3a29073..a51eb6fd17862 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -232,6 +232,8 @@ const char kScrollBounce[] = "scroll-bounce"; const char kHiddenPage[] = "hidden-page"; const char kNativeWindowOpen[] = "native-window-open"; const char kWebviewTag[] = "webview-tag"; +const char kDisableElectronSiteInstanceOverrides[] = + "disable-electron-site-instance-overrides"; // Command switch passed to renderer process to control nodeIntegration. const char kNodeIntegrationInWorker[] = "node-integration-in-worker"; diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index 93efae3b12cb8..d1548ce816a60 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -118,6 +118,7 @@ extern const char kNodeIntegrationInWorker[]; extern const char kWebviewTag[]; extern const char kNodeIntegrationInSubFrames[]; extern const char kDisableHtmlFullscreenWindowResize[]; +extern const char kDisableElectronSiteInstanceOverrides[]; extern const char kWidevineCdmPath[]; extern const char kWidevineCdmVersion[]; diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 16275d5262f72..02cb61da06dc0 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -104,6 +104,13 @@ void AtomRendererClient::DidCreateScriptContext( // Setup node environment for each window. node::Environment* env = node_bindings_->CreateEnvironment(context); + auto* command_line = base::CommandLine::ForCurrentProcess(); + // If we have disabled the site instance overrides we should prevent loading + // any non-context aware native module + if (command_line->HasSwitch(switches::kDisableElectronSiteInstanceOverrides)) + env->ForceOnlyContextAwareNativeModules(); + env->WarnNonContextAwareNativeModules(); + environments_.insert(env); // Add Electron extended APIs. @@ -145,9 +152,11 @@ void AtomRendererClient::WillReleaseScriptContext( // Destroy the node environment. We only do this if node support has been // enabled for sub-frames to avoid a change-of-behavior / introduce crashes // for existing users. - // TODO(MarshallOfSOund): Free the environment regardless of this switch - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kNodeIntegrationInSubFrames)) + // We also do this if we have disable electron site instance overrides to + // avoid memory leaks + auto* command_line = base::CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kNodeIntegrationInSubFrames) || + command_line->HasSwitch(switches::kDisableElectronSiteInstanceOverrides)) node::FreeEnvironment(env); // ElectronBindings is tracking node environments. diff --git a/docs/api/app.md b/docs/api/app.md index ee9ab5da500ea..09e694792eefe 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -1306,3 +1306,16 @@ This is the user agent that will be used when no user agent is set at the `webContents` or `session` level. It is useful for ensuring that your entire app has the same user agent. Set to a custom value as early as possible in your app's initialization to ensure that your overridden value is used. + +### `app.allowRendererProcessReuse` + +A `Boolean` which when `true` disables the overrides that Electron has in place +to ensure renderer processes are restarted on every navigation. The current +default value for this property is `false`. + +The intention is for these overrides to become disabled by default and then at +some point in the future this property will be removed. This property impacts +which native modules you can use in the renderer process. For more information +on the direction Electron is going with renderer process restarts and usage of +native modules in the renderer process please check out this +[Tracking Issue](https://github.com/electron/electron/issues/18397). diff --git a/patches/common/chromium/blink_world_context.patch b/patches/common/chromium/blink_world_context.patch index f1785d30e7ff7..5c66f4cb1bb70 100644 --- a/patches/common/chromium/blink_world_context.patch +++ b/patches/common/chromium/blink_world_context.patch @@ -5,7 +5,7 @@ Subject: blink_world_context.patch diff --git a/third_party/blink/public/web/web_local_frame.h b/third_party/blink/public/web/web_local_frame.h -index 8f34337725ac16cea102030f852c5d8ab1d70fcc..7ff160ccf78f3fdca8c1f63f7c3bd53ab7396b91 100644 +index 82fb3fdfe6bfa8c8d885ee133270b6f2564325a8..f3bad71eab608d3b9ac0e08446c9e520f47e9b10 100644 --- a/third_party/blink/public/web/web_local_frame.h +++ b/third_party/blink/public/web/web_local_frame.h @@ -355,6 +355,9 @@ class WebLocalFrame : public WebFrame { @@ -19,10 +19,10 @@ index 8f34337725ac16cea102030f852c5d8ab1d70fcc..7ff160ccf78f3fdca8c1f63f7c3bd53a // that the script evaluated to with callback. Script execution can be // suspend. diff --git a/third_party/blink/renderer/core/frame/web_local_frame_impl.cc b/third_party/blink/renderer/core/frame/web_local_frame_impl.cc -index bbeaed0122ba447891196852d815fac465040046..0f03d4c3a84afb5203da55a2fc2e2b16d3618710 100644 +index c8174f4b93b78b9368ef38ecb56e9eccf0b71467..73c2bed83ce240574065e3699617d091a581e9e9 100644 --- a/third_party/blink/renderer/core/frame/web_local_frame_impl.cc +++ b/third_party/blink/renderer/core/frame/web_local_frame_impl.cc -@@ -869,6 +869,13 @@ v8::Local WebLocalFrameImpl::GlobalProxy() const { +@@ -873,6 +873,13 @@ v8::Local WebLocalFrameImpl::GlobalProxy() const { return MainWorldScriptContext()->Global(); } @@ -37,10 +37,10 @@ index bbeaed0122ba447891196852d815fac465040046..0f03d4c3a84afb5203da55a2fc2e2b16 return BindingSecurity::ShouldAllowAccessToFrame( CurrentDOMWindow(V8PerIsolateData::MainThreadIsolate()), diff --git a/third_party/blink/renderer/core/frame/web_local_frame_impl.h b/third_party/blink/renderer/core/frame/web_local_frame_impl.h -index f7884356209f7c1be523de11ce5f97187c6e24d1..fae16b85298bb1086c3ea493ae754683528594a6 100644 +index 3db1bec7516a40eb2f654574baa108e99ff9fb2d..fb5b43e48e455d64ce986cb5490291fc1c18d8ba 100644 --- a/third_party/blink/renderer/core/frame/web_local_frame_impl.h +++ b/third_party/blink/renderer/core/frame/web_local_frame_impl.h -@@ -147,6 +147,8 @@ class CORE_EXPORT WebLocalFrameImpl final +@@ -146,6 +146,8 @@ class CORE_EXPORT WebLocalFrameImpl final int argc, v8::Local argv[]) override; v8::Local MainWorldScriptContext() const override; diff --git a/patches/common/chromium/build_add_electron_tracing_category.patch b/patches/common/chromium/build_add_electron_tracing_category.patch index 3c44539e75d39..8f70f10b724d1 100644 --- a/patches/common/chromium/build_add_electron_tracing_category.patch +++ b/patches/common/chromium/build_add_electron_tracing_category.patch @@ -8,7 +8,7 @@ categories in use are known / declared. This patch is required for us to introduce a new Electron category. diff --git a/base/trace_event/builtin_categories.h b/base/trace_event/builtin_categories.h -index 860caacd290b4d0df909a4eacc7a358701d7362a..d79d3f214cedd8df3b5c61d7f91c096701d33bf0 100644 +index 97055b4bdaf0dc38b8d248fefddfcf8c68c123b9..6dbe407151dfc5a9168df77f42932e51b802377f 100644 --- a/base/trace_event/builtin_categories.h +++ b/base/trace_event/builtin_categories.h @@ -61,6 +61,7 @@ diff --git a/patches/common/chromium/can_create_window.patch b/patches/common/chromium/can_create_window.patch index 2c3a9f920f1e6..8a878428289e2 100644 --- a/patches/common/chromium/can_create_window.patch +++ b/patches/common/chromium/can_create_window.patch @@ -5,10 +5,10 @@ Subject: can_create_window.patch diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc -index de3b289f7286b5b3fc4550e35a2534217e34e1e2..4e8ce36e862aefa2107d9bc86f92b14e1ec1c323 100644 +index 797264d0cb4236ffc91f366cf6be30643cb7bf2b..c0cd0b41088773eb6226f2074d62a798346d1f72 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc -@@ -3674,6 +3674,7 @@ void RenderFrameHostImpl::CreateNewWindow( +@@ -3712,6 +3712,7 @@ void RenderFrameHostImpl::CreateNewWindow( last_committed_origin_, params->window_container_type, params->target_url, params->referrer.To(), params->frame_name, params->disposition, *params->features, @@ -17,7 +17,7 @@ index de3b289f7286b5b3fc4550e35a2534217e34e1e2..4e8ce36e862aefa2107d9bc86f92b14e &no_javascript_access); diff --git a/content/common/frame.mojom b/content/common/frame.mojom -index ee0ca5d5b76756ab4123652b02298eede20f22e0..51c89138745cf587a483771b4716b5cabef91eb3 100644 +index 82882159b0bac6d47d678c485de0aacc7db06c2d..dd2299094b79d82da7ec1cd8f559050b6f0e2af5 100644 --- a/content/common/frame.mojom +++ b/content/common/frame.mojom @@ -291,6 +291,10 @@ struct CreateNewWindowParams { @@ -32,7 +32,7 @@ index ee0ca5d5b76756ab4123652b02298eede20f22e0..51c89138745cf587a483771b4716b5ca // Operation result when the renderer asks the browser to create a new window. diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc -index 23b7c63cd45e05830134072fbe7baff86b8380f6..22815b555961fb5aa267f747372b3c3397ea2ae8 100644 +index ce9d0ede84da62061278f7fb0c543fc2e8a0216e..3729dcc9ea3272c943754a92c6ed1d7a1fd8fcf3 100644 --- a/content/public/browser/content_browser_client.cc +++ b/content/public/browser/content_browser_client.cc @@ -518,6 +518,8 @@ bool ContentBrowserClient::CanCreateWindow( @@ -45,7 +45,7 @@ index 23b7c63cd45e05830134072fbe7baff86b8380f6..22815b555961fb5aa267f747372b3c33 bool opener_suppressed, bool* no_javascript_access) { diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h -index 1041df57b14a4cdca9a542108825ab933311b9ee..89bcd0a8e3ea9b966f6b7c18f0514da83a6b2b98 100644 +index 449941ddc4d43dc4cb164f6af9dcc69991dddc8b..4c84fb3648b3de36015b325246559f8aefe2ebd5 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h @@ -177,6 +177,7 @@ class RenderFrameHost; @@ -66,7 +66,7 @@ index 1041df57b14a4cdca9a542108825ab933311b9ee..89bcd0a8e3ea9b966f6b7c18f0514da8 bool opener_suppressed, bool* no_javascript_access); diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc -index a9508139d626447ebf54edf1281337b9f7a3f406..ee84732bc535538f95fc2c767060dca50fbdf561 100644 +index 49e1e5647f700350a07ad88306a06122d0f0f204..39c5ce2a631cc1d78e36dbda506212b87f5a1939 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -77,6 +77,7 @@ @@ -77,7 +77,7 @@ index a9508139d626447ebf54edf1281337b9f7a3f406..ee84732bc535538f95fc2c767060dca5 #include "content/renderer/media/audio/audio_device_factory.h" #include "content/renderer/media/stream/media_stream_device_observer.h" #include "content/renderer/media/video_capture/video_capture_impl_manager.h" -@@ -1368,6 +1369,8 @@ WebView* RenderViewImpl::CreateView( +@@ -1358,6 +1359,8 @@ WebView* RenderViewImpl::CreateView( } params->features = ConvertWebWindowFeaturesToMojoWindowFeatures(features); @@ -87,10 +87,10 @@ index a9508139d626447ebf54edf1281337b9f7a3f406..ee84732bc535538f95fc2c767060dca5 // moved on send. bool is_background_tab = diff --git a/content/shell/browser/web_test/web_test_content_browser_client.cc b/content/shell/browser/web_test/web_test_content_browser_client.cc -index 04149aa4478cfbd0e1aafaed23dbddca3d3b161a..40d1f8c342c86510a91a973c4aeb1bda5b8e42f9 100644 +index 3e3f251af3c531fca379f7fa00f67d671bbe2d5f..e77427146729664247e4dd3313f8533a78059bf7 100644 --- a/content/shell/browser/web_test/web_test_content_browser_client.cc +++ b/content/shell/browser/web_test/web_test_content_browser_client.cc -@@ -296,6 +296,8 @@ bool WebTestContentBrowserClient::CanCreateWindow( +@@ -299,6 +299,8 @@ bool WebTestContentBrowserClient::CanCreateWindow( const std::string& frame_name, WindowOpenDisposition disposition, const blink::mojom::WindowFeatures& features, @@ -100,10 +100,10 @@ index 04149aa4478cfbd0e1aafaed23dbddca3d3b161a..40d1f8c342c86510a91a973c4aeb1bda bool opener_suppressed, bool* no_javascript_access) { diff --git a/content/shell/browser/web_test/web_test_content_browser_client.h b/content/shell/browser/web_test/web_test_content_browser_client.h -index 6413e5f117d7dfd4a61779d4c971c28a14a86082..a02e232249cf99c55ec5b07a94b29f0a6d4a38bf 100644 +index 8b9ae118bca4678c315d820af6b4dbe850943ed4..acde862d6d48429db5936f2e6735017dc2ef647e 100644 --- a/content/shell/browser/web_test/web_test_content_browser_client.h +++ b/content/shell/browser/web_test/web_test_content_browser_client.h -@@ -68,6 +68,8 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient { +@@ -69,6 +69,8 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient { const std::string& frame_name, WindowOpenDisposition disposition, const blink::mojom::WindowFeatures& features, diff --git a/patches/common/chromium/cross_site_document_resource_handler.patch b/patches/common/chromium/cross_site_document_resource_handler.patch index cf4202066c6e4..e821acfa1a62e 100644 --- a/patches/common/chromium/cross_site_document_resource_handler.patch +++ b/patches/common/chromium/cross_site_document_resource_handler.patch @@ -8,10 +8,10 @@ this patch can be removed once we switch to network service, where the embedders have a chance to design their URLLoaders. diff --git a/content/browser/loader/cross_site_document_resource_handler.cc b/content/browser/loader/cross_site_document_resource_handler.cc -index 9e65e50de1d45d8435145b56bf7108a8c0272065..3103e4caa2adf853277774092cbd645fd8ece952 100644 +index 2151c5b9698e9a2768875d04a2297956cc4c0d41..8a316a117ab367bcbac947894cbe1bc2428de93e 100644 --- a/content/browser/loader/cross_site_document_resource_handler.cc +++ b/content/browser/loader/cross_site_document_resource_handler.cc -@@ -666,6 +666,9 @@ bool CrossSiteDocumentResourceHandler::ShouldBlockBasedOnHeaders( +@@ -671,6 +671,9 @@ bool CrossSiteDocumentResourceHandler::ShouldBlockBasedOnHeaders( return false; } @@ -22,7 +22,7 @@ index 9e65e50de1d45d8435145b56bf7108a8c0272065..3103e4caa2adf853277774092cbd645f } diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc -index 22815b555961fb5aa267f747372b3c3397ea2ae8..dd582ad7e2911d049575a25eb7990e50bdebc73e 100644 +index 3729dcc9ea3272c943754a92c6ed1d7a1fd8fcf3..787cd81b26508d3e04956721f0e7cec2f457aa60 100644 --- a/content/public/browser/content_browser_client.cc +++ b/content/public/browser/content_browser_client.cc @@ -56,6 +56,10 @@ BrowserMainParts* ContentBrowserClient::CreateBrowserMainParts( @@ -37,10 +37,10 @@ index 22815b555961fb5aa267f747372b3c3397ea2ae8..dd582ad7e2911d049575a25eb7990e50 const base::Location& from_here, const scoped_refptr& task_runner, diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h -index 89bcd0a8e3ea9b966f6b7c18f0514da83a6b2b98..8e217f7098c766ec708be6f14b5b68456c0cb6f1 100644 +index 4c84fb3648b3de36015b325246559f8aefe2ebd5..bf9b3a601fc16d5070e4467a258a047f47b059f3 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h -@@ -218,6 +218,9 @@ class CONTENT_EXPORT ContentBrowserClient { +@@ -219,6 +219,9 @@ class CONTENT_EXPORT ContentBrowserClient { virtual BrowserMainParts* CreateBrowserMainParts( const MainFunctionParams& parameters); diff --git a/patches/common/chromium/disable_color_correct_rendering.patch b/patches/common/chromium/disable_color_correct_rendering.patch index 62ad5a53ae5cb..32de45a30d170 100644 --- a/patches/common/chromium/disable_color_correct_rendering.patch +++ b/patches/common/chromium/disable_color_correct_rendering.patch @@ -32,7 +32,7 @@ index 092fb1b7ea3626b7649472c35ec20bf1a6aaf4cd..fed8dd322faba387ebd0508228f84776 // Image Decode Service and raster tiles without images until the decode is // ready. diff --git a/components/viz/common/display/renderer_settings.h b/components/viz/common/display/renderer_settings.h -index fc3bd4e31a24fa9135381959c8729a5e13368d48..5ab9b8c63128a5b964457eed2100316e777f542e 100644 +index 78041fcb9647f740c6a142ec65f2418712c6286c..04e75ac40c38a38bdec634d1aa645854cb1a80d6 100644 --- a/components/viz/common/display/renderer_settings.h +++ b/components/viz/common/display/renderer_settings.h @@ -23,6 +23,7 @@ class VIZ_COMMON_EXPORT RendererSettings { @@ -65,10 +65,10 @@ index 78a6b5739caed8c3925f303c52ed107be8e4ccfe..ddbf660e594c1a991d4e758fa11b1b2e !command_line->HasSwitch(switches::kUIDisablePartialSwap); #if defined(OS_WIN) diff --git a/components/viz/service/display/gl_renderer.cc b/components/viz/service/display/gl_renderer.cc -index 418ae433b97d41c9fd32eb416139ef8a9551afab..8c9c7b4e7969599e81e4a2c1255e71b65bb0e66f 100644 +index edf8e92edadae9354962a98712e3bc0ac7410fbe..553c181f04180185acfcf865e59c6dea839cc973 100644 --- a/components/viz/service/display/gl_renderer.cc +++ b/components/viz/service/display/gl_renderer.cc -@@ -79,6 +79,9 @@ +@@ -80,6 +80,9 @@ using gpu::gles2::GLES2Interface; @@ -78,7 +78,7 @@ index 418ae433b97d41c9fd32eb416139ef8a9551afab..8c9c7b4e7969599e81e4a2c1255e71b6 namespace viz { namespace { -@@ -553,8 +556,9 @@ void GLRenderer::DoDrawQuad(const DrawQuad* quad, +@@ -554,8 +557,9 @@ void GLRenderer::DoDrawQuad(const DrawQuad* quad, void GLRenderer::DrawDebugBorderQuad(const DebugBorderDrawQuad* quad) { SetBlendEnabled(quad->ShouldDrawWithBlending()); @@ -90,7 +90,7 @@ index 418ae433b97d41c9fd32eb416139ef8a9551afab..8c9c7b4e7969599e81e4a2c1255e71b6 // Use the full quad_rect for debug quads to not move the edges based on // partial swaps. -@@ -1400,7 +1404,8 @@ void GLRenderer::ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params, +@@ -1353,7 +1357,8 @@ void GLRenderer::ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params, params->use_aa ? USE_AA : NO_AA, mask_mode, mask_for_background, params->use_color_matrix, tint_gl_composited_content_, ShouldApplyRoundedCorner(params->quad)), @@ -100,7 +100,7 @@ index 418ae433b97d41c9fd32eb416139ef8a9551afab..8c9c7b4e7969599e81e4a2c1255e71b6 } void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) { -@@ -1871,8 +1876,8 @@ void GLRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad, +@@ -1824,8 +1829,8 @@ void GLRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad, SetUseProgram(ProgramKey::SolidColor(use_aa ? USE_AA : NO_AA, tint_gl_composited_content_, ShouldApplyRoundedCorner(quad)), @@ -111,7 +111,7 @@ index 418ae433b97d41c9fd32eb416139ef8a9551afab..8c9c7b4e7969599e81e4a2c1255e71b6 SetShaderColor(color, opacity); if (current_program_->rounded_corner_rect_location() != -1) { SetShaderRoundedCorner( -@@ -2028,8 +2033,8 @@ void GLRenderer::DrawContentQuadAA(const ContentDrawQuadBase* quad, +@@ -1980,8 +1985,8 @@ void GLRenderer::DrawContentQuadAA(const ContentDrawQuadBase* quad, : NON_PREMULTIPLIED_ALPHA, false, false, tint_gl_composited_content_, ShouldApplyRoundedCorner(quad)), @@ -122,7 +122,7 @@ index 418ae433b97d41c9fd32eb416139ef8a9551afab..8c9c7b4e7969599e81e4a2c1255e71b6 if (current_program_->tint_color_matrix_location() != -1) { auto matrix = cc::DebugColors::TintCompositedContentColorTransformMatrix(); -@@ -2126,8 +2131,8 @@ void GLRenderer::DrawContentQuadNoAA(const ContentDrawQuadBase* quad, +@@ -2077,8 +2082,8 @@ void GLRenderer::DrawContentQuadNoAA(const ContentDrawQuadBase* quad, !quad->ShouldDrawWithBlending(), has_tex_clamp_rect, tint_gl_composited_content_, ShouldApplyRoundedCorner(quad)), @@ -133,7 +133,7 @@ index 418ae433b97d41c9fd32eb416139ef8a9551afab..8c9c7b4e7969599e81e4a2c1255e71b6 if (current_program_->tint_color_matrix_location() != -1) { auto matrix = cc::DebugColors::TintCompositedContentColorTransformMatrix(); -@@ -2230,7 +2235,7 @@ void GLRenderer::DrawYUVVideoQuad(const YUVVideoDrawQuad* quad, +@@ -2181,7 +2186,7 @@ void GLRenderer::DrawYUVVideoQuad(const YUVVideoDrawQuad* quad, DCHECK_NE(src_color_space, src_color_space.GetAsFullRangeRGB()); gfx::ColorSpace dst_color_space = @@ -142,7 +142,7 @@ index 418ae433b97d41c9fd32eb416139ef8a9551afab..8c9c7b4e7969599e81e4a2c1255e71b6 // Force sRGB output on Windows for overlay candidate video quads to match // DirectComposition behavior in case these switch between overlays and // compositing. See https://crbug.com/811118 for details. -@@ -2386,8 +2391,8 @@ void GLRenderer::DrawStreamVideoQuad(const StreamVideoDrawQuad* quad, +@@ -2337,8 +2342,8 @@ void GLRenderer::DrawStreamVideoQuad(const StreamVideoDrawQuad* quad, SetUseProgram(ProgramKey::VideoStream(tex_coord_precision, ShouldApplyRoundedCorner(quad)), @@ -153,7 +153,7 @@ index 418ae433b97d41c9fd32eb416139ef8a9551afab..8c9c7b4e7969599e81e4a2c1255e71b6 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()); -@@ -2444,8 +2449,8 @@ void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) { +@@ -2395,8 +2400,8 @@ void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) { draw_cache_.nearest_neighbor ? GL_NEAREST : GL_LINEAR); // Bind the program to the GL state. @@ -164,7 +164,7 @@ index 418ae433b97d41c9fd32eb416139ef8a9551afab..8c9c7b4e7969599e81e4a2c1255e71b6 if (current_program_->rounded_corner_rect_location() != -1) { SetShaderRoundedCorner( -@@ -3138,7 +3143,9 @@ void GLRenderer::PrepareGeometry(BoundGeometry binding) { +@@ -3089,7 +3094,9 @@ void GLRenderer::PrepareGeometry(BoundGeometry binding) { void GLRenderer::SetUseProgram(const ProgramKey& program_key_no_color, const gfx::ColorSpace& src_color_space, const gfx::ColorSpace& dst_color_space) { @@ -175,7 +175,7 @@ index 418ae433b97d41c9fd32eb416139ef8a9551afab..8c9c7b4e7969599e81e4a2c1255e71b6 ProgramKey program_key = program_key_no_color; const gfx::ColorTransform* color_transform = -@@ -3492,7 +3499,7 @@ void GLRenderer::CopyRenderPassDrawQuadToOverlayResource( +@@ -3443,7 +3450,7 @@ void GLRenderer::CopyRenderPassDrawQuadToOverlayResource( *overlay_texture = FindOrCreateOverlayTexture( params.quad->render_pass_id, iosurface_width, iosurface_height, @@ -184,7 +184,7 @@ index 418ae433b97d41c9fd32eb416139ef8a9551afab..8c9c7b4e7969599e81e4a2c1255e71b6 *new_bounds = gfx::RectF(updated_dst_rect.origin(), gfx::SizeF((*overlay_texture)->texture.size())); -@@ -3696,8 +3703,9 @@ void GLRenderer::FlushOverdrawFeedback(const gfx::Rect& output_rect) { +@@ -3647,8 +3654,9 @@ void GLRenderer::FlushOverdrawFeedback(const gfx::Rect& output_rect) { PrepareGeometry(SHARED_BINDING); @@ -196,17 +196,17 @@ index 418ae433b97d41c9fd32eb416139ef8a9551afab..8c9c7b4e7969599e81e4a2c1255e71b6 gfx::Transform render_matrix; render_matrix.Translate(0.5 * output_rect.width() + output_rect.x(), -@@ -3857,3 +3865,5 @@ gfx::Size GLRenderer::GetRenderPassBackingPixelSize( +@@ -3808,3 +3816,5 @@ gfx::Size GLRenderer::GetRenderPassBackingPixelSize( } } // namespace viz + +#undef PATCH_CS diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc -index 53fc82c1f2cc0cfb7a6ce909fea6c025dff26b43..ec00a673df6a8f1c372fc8dff7cf508502c3767b 100644 +index f19bbb46ea6f3962f83d10fb400ae55584a17a9e..c5dff79af54a03ef888e4474e5ea53689e8e8cd7 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc -@@ -192,6 +192,7 @@ GpuTerminationStatus ConvertToGpuTerminationStatus( +@@ -191,6 +191,7 @@ GpuTerminationStatus ConvertToGpuTerminationStatus( // Command-line switches to propagate to the GPU process. static const char* const kSwitchNames[] = { @@ -215,10 +215,10 @@ index 53fc82c1f2cc0cfb7a6ce909fea6c025dff26b43..ec00a673df6a8f1c372fc8dff7cf5085 service_manager::switches::kGpuSandboxAllowSysVShm, service_manager::switches::kGpuSandboxFailuresFatal, diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc -index 50f63a2c8f8ec447545d2b2c80afef34ad4a7fef..8728e19fe5087927b4d6aa8cccaf09258aae9ea4 100644 +index f58456df8d856346a2350b87ecd84de5b75e0d13..e0b39de61eb43f2ac779e273d3df937e38c201c4 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc -@@ -220,6 +220,7 @@ +@@ -217,6 +217,7 @@ #include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches_util.h" #include "ui/display/display_switches.h" @@ -226,7 +226,7 @@ index 50f63a2c8f8ec447545d2b2c80afef34ad4a7fef..8728e19fe5087927b4d6aa8cccaf0925 #include "ui/gl/gl_switches.h" #include "ui/native_theme/native_theme_features.h" -@@ -2935,6 +2936,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( +@@ -2912,6 +2913,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( // Propagate the following switches to the renderer command line (along // with any associated values) if present in the browser command line. static const char* const kSwitchNames[] = { @@ -235,10 +235,10 @@ index 50f63a2c8f8ec447545d2b2c80afef34ad4a7fef..8728e19fe5087927b4d6aa8cccaf0925 network::switches::kExplicitlyAllowedPorts, service_manager::switches::kDisableInProcessStackTraces, diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc -index abbcf4ba59a1f3f31ae83055030414de61ec20c5..0f34f2ef40afcda39bc3297dc69128e441be6cf5 100644 +index 33817ba20ae6cbfec8a28313092df9c10b1bf966..ea1a574c1f6d2a0f880391b21397c2cb342cbc77 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc -@@ -2818,6 +2818,9 @@ cc::LayerTreeSettings RenderWidget::GenerateLayerTreeSettings( +@@ -2810,6 +2810,9 @@ cc::LayerTreeSettings RenderWidget::GenerateLayerTreeSettings( settings.main_frame_before_activation_enabled = cmd.HasSwitch(cc::switches::kEnableMainFrameBeforeActivation); @@ -288,7 +288,7 @@ index 88ec94963569588ed2882193a28197879dcb1090..eae37577bc9b1872c0162f55de218553 if (color_space == ColorSpace::CreateSRGB()) { base::ScopedCFTypeRef srgb_icc( diff --git a/ui/gfx/switches.cc b/ui/gfx/switches.cc -index 53de88695661a12f9820a0319901d4565a775c4a..12735b7b95a0bb45e08707467d21e59f4b77e2b5 100644 +index 189e147e908fdab38972f4f9b0ce212347a4ec2e..2a0a480d8513abc609b82f3d1eb24695d4f2146f 100644 --- a/ui/gfx/switches.cc +++ b/ui/gfx/switches.cc @@ -7,6 +7,8 @@ @@ -301,10 +301,10 @@ index 53de88695661a12f9820a0319901d4565a775c4a..12735b7b95a0bb45e08707467d21e59f // sharpness, kerning, hinting and layout. const char kDisableFontSubpixelPositioning[] = diff --git a/ui/gfx/switches.h b/ui/gfx/switches.h -index 3b87320bf5318ad4d30205f8a48f19c8037e61c6..f18f8db6feab73169ad9f95f33c52799d5d53049 100644 +index c95989ae7da12585fc417a680aef6c55e4b7a8d7..9e180a6decd72e510cecfec1f43fd1ac70e8b8f7 100644 --- a/ui/gfx/switches.h +++ b/ui/gfx/switches.h -@@ -11,6 +11,8 @@ +@@ -10,6 +10,8 @@ namespace switches { diff --git a/patches/common/chromium/disable_user_gesture_requirement_for_beforeunload_dialogs.patch b/patches/common/chromium/disable_user_gesture_requirement_for_beforeunload_dialogs.patch index 2dc19966792f0..0bba8022f7230 100644 --- a/patches/common/chromium/disable_user_gesture_requirement_for_beforeunload_dialogs.patch +++ b/patches/common/chromium/disable_user_gesture_requirement_for_beforeunload_dialogs.patch @@ -6,10 +6,10 @@ Subject: disable_user_gesture_requirement_for_beforeunload_dialogs.patch See https://github.com/electron/electron/issues/10754 diff --git a/third_party/blink/renderer/core/dom/document.cc b/third_party/blink/renderer/core/dom/document.cc -index 0428b3e958705d6d7df3fcd1efd18d66e591b1b0..33c37f5106f5ffe5bb39bd65a4a36f58b9b8e0fd 100644 +index bb3aff0859f1a6998889aa4b3fb2ca1143c0ed24..eb950ec3352634980447b91e46a652a877eb8782 100644 --- a/third_party/blink/renderer/core/dom/document.cc +++ b/third_party/blink/renderer/core/dom/document.cc -@@ -3592,7 +3592,9 @@ bool Document::DispatchBeforeUnloadEvent(ChromeClient* chrome_client, +@@ -3649,7 +3649,9 @@ bool Document::DispatchBeforeUnloadEvent(ChromeClient* chrome_client, "frame that never had a user gesture since its load. " "https://www.chromestatus.com/feature/5082396709879808"; Intervention::GenerateReport(frame_, "BeforeUnloadNoGesture", message); diff --git a/patches/common/chromium/feat_offscreen_rendering_with_viz_compositor.patch b/patches/common/chromium/feat_offscreen_rendering_with_viz_compositor.patch index ec7eaa8d1a7aa..0cf134f6f4278 100644 --- a/patches/common/chromium/feat_offscreen_rendering_with_viz_compositor.patch +++ b/patches/common/chromium/feat_offscreen_rendering_with_viz_compositor.patch @@ -5,7 +5,7 @@ Subject: feat: offscreen rendering with viz compositor diff --git a/components/viz/host/host_display_client.cc b/components/viz/host/host_display_client.cc -index ca788f5288132456d1142004b95f57678b082800..441ec3c34a8a4617d3a4b4d20ac864773b697589 100644 +index f5e18df4e06e24d3bdd51308abde48e217444848..41017d9d53b1c0d563ea0901f5cae407c6cf1560 100644 --- a/components/viz/host/host_display_client.cc +++ b/components/viz/host/host_display_client.cc @@ -18,6 +18,10 @@ @@ -30,7 +30,7 @@ index ca788f5288132456d1142004b95f57678b082800..441ec3c34a8a4617d3a4b4d20ac86477 if (!NeedsToUseLayerWindow(widget_)) { DLOG(ERROR) << "HWND shouldn't be using a layered window"; return; -@@ -56,7 +60,11 @@ void HostDisplayClient::CreateLayeredWindowUpdater( +@@ -56,8 +60,12 @@ void HostDisplayClient::CreateLayeredWindowUpdater( layered_window_updater_ = std::make_unique(widget_, std::move(request)); @@ -42,9 +42,10 @@ index ca788f5288132456d1142004b95f57678b082800..441ec3c34a8a4617d3a4b4d20ac86477 #endif +} - } // namespace viz + #if defined(USE_X11) + void HostDisplayClient::DidCompleteSwapWithNewSize(const gfx::Size& size) { diff --git a/components/viz/host/host_display_client.h b/components/viz/host/host_display_client.h -index af64385aa93f7abc7a85e1f6eec3c99134e0d2b5..011007ba451e71d46d02cb2d28f6489fe2a805ec 100644 +index 5e5c5da4a3cfc927df3fb120fcab647e927271c1..8c6ec95f309660fb83012a13c7b9bb64b782e7d9 100644 --- a/components/viz/host/host_display_client.h +++ b/components/viz/host/host_display_client.h @@ -30,17 +30,17 @@ class VIZ_HOST_EXPORT HostDisplayClient : public mojom::DisplayClient { @@ -66,8 +67,8 @@ index af64385aa93f7abc7a85e1f6eec3c99134e0d2b5..011007ba451e71d46d02cb2d28f6489f mojom::LayeredWindowUpdaterRequest request) override; -#endif - mojo::Binding binding_; - #if defined(OS_MACOSX) || defined(OS_WIN) + #if defined(USE_X11) + void DidCompleteSwapWithNewSize(const gfx::Size& size) override; diff --git a/components/viz/host/layered_window_updater_impl.cc b/components/viz/host/layered_window_updater_impl.cc index d3a49ed8be8dc11b86af67cdd600b05ddc0fc486..88bf86f3938b8267d731b52c8c3baa35d3128c7a 100644 --- a/components/viz/host/layered_window_updater_impl.cc @@ -97,10 +98,10 @@ index 93c52d2b928cba6e98723e19b005fb7bd7089a58..4dc645e770a2a039ed8e4ff4de555767 private: const HWND hwnd_; diff --git a/components/viz/service/BUILD.gn b/components/viz/service/BUILD.gn -index 6ad1ea5324d2f11ecb18a6ccc5a493f5b5412716..1e47a1b8409702df96b28b2d6d98d9f12991a486 100644 +index e2bb3f029f754a5d4d3902af0c0c87da762182eb..10b369fe9ac1e7739c288c4ccf09f621ea444bab 100644 --- a/components/viz/service/BUILD.gn +++ b/components/viz/service/BUILD.gn -@@ -116,6 +116,8 @@ viz_component("service") { +@@ -117,6 +117,8 @@ viz_component("service") { "display_embedder/output_surface_provider_impl.h", "display_embedder/server_shared_bitmap_manager.cc", "display_embedder/server_shared_bitmap_manager.h", @@ -110,7 +111,7 @@ index 6ad1ea5324d2f11ecb18a6ccc5a493f5b5412716..1e47a1b8409702df96b28b2d6d98d9f1 "display_embedder/software_output_surface.h", "display_embedder/viz_process_context_provider.cc", diff --git a/components/viz/service/display_embedder/output_surface_provider_impl.cc b/components/viz/service/display_embedder/output_surface_provider_impl.cc -index 264c56995171182940b223da06b809eebf78e918..cafc117436bdfb5600e5dfbcd2edf21fe505eeea 100644 +index 8fe397588eb47224d48a8642b814583d11cc9c09..a7072c8e16434d3b15db1599f43d8fab5a97bdf3 100644 --- a/components/viz/service/display_embedder/output_surface_provider_impl.cc +++ b/components/viz/service/display_embedder/output_surface_provider_impl.cc @@ -18,6 +18,7 @@ @@ -121,7 +122,7 @@ index 264c56995171182940b223da06b809eebf78e918..cafc117436bdfb5600e5dfbcd2edf21f #include "components/viz/service/display_embedder/software_output_surface.h" #include "components/viz/service/display_embedder/viz_process_context_provider.h" #include "components/viz/service/gl/gpu_service_impl.h" -@@ -240,6 +241,19 @@ OutputSurfaceProviderImpl::CreateSoftwareOutputDeviceForPlatform( +@@ -243,6 +244,19 @@ OutputSurfaceProviderImpl::CreateSoftwareOutputDeviceForPlatform( if (headless_) return std::make_unique(); @@ -139,8 +140,8 @@ index 264c56995171182940b223da06b809eebf78e918..cafc117436bdfb5600e5dfbcd2edf21f +#endif + #if defined(OS_WIN) - return CreateSoftwareOutputDeviceWinGpu( - surface_handle, &output_device_backing_, display_client); + return CreateSoftwareOutputDeviceWin(surface_handle, &output_device_backing_, + display_client); diff --git a/components/viz/service/display_embedder/software_output_device_mac.cc b/components/viz/service/display_embedder/software_output_device_mac.cc index b9357082293cc55650144ccbc8bada8fe6d1cac4..b4cb07e26d1504719f80e5835c1cb5f138b9f1ab 100644 --- a/components/viz/service/display_embedder/software_output_device_mac.cc @@ -176,10 +177,10 @@ index f3867356e3d641416e00e6d115ae9ae2a0be90ab..b1d192d2b20ccb63fba07093101d745e diff --git a/components/viz/service/display_embedder/software_output_device_proxy.cc b/components/viz/service/display_embedder/software_output_device_proxy.cc new file mode 100644 -index 0000000000000000000000000000000000000000..c784a841f74e7a6215595fd8b1166655857f3e31 +index 0000000000000000000000000000000000000000..bbca3a43b5ba8bcf1e3a4dab4509b903b7117f36 --- /dev/null +++ b/components/viz/service/display_embedder/software_output_device_proxy.cc -@@ -0,0 +1,167 @@ +@@ -0,0 +1,168 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. @@ -256,12 +257,13 @@ index 0000000000000000000000000000000000000000..c784a841f74e7a6215595fd8b1166655 +} + +void SoftwareOutputDeviceProxy::OnSwapBuffers( -+ base::OnceClosure swap_ack_callback) { ++ SoftwareOutputDevice::SwapBuffersCallback swap_ack_callback) { + DCHECK(swap_ack_callback_.is_null()); + + // We aren't waiting on DrawAck() and can immediately run the callback. + if (!waiting_on_draw_ack_) { -+ task_runner_->PostTask(FROM_HERE, std::move(swap_ack_callback)); ++ task_runner_->PostTask(FROM_HERE, ++ base::BindOnce(std::move(swap_ack_callback), viewport_pixel_size_)); + return; + } + @@ -343,13 +345,13 @@ index 0000000000000000000000000000000000000000..c784a841f74e7a6215595fd8b1166655 + TRACE_EVENT_ASYNC_END0("viz", "SoftwareOutputDeviceProxy::Draw", this); + + waiting_on_draw_ack_ = false; -+ std::move(swap_ack_callback_).Run(); ++ std::move(swap_ack_callback_).Run(viewport_pixel_size_); +} + +} // namespace viz diff --git a/components/viz/service/display_embedder/software_output_device_proxy.h b/components/viz/service/display_embedder/software_output_device_proxy.h new file mode 100644 -index 0000000000000000000000000000000000000000..01e1e2f0860faa1afe42c342c8905a7f838bd363 +index 0000000000000000000000000000000000000000..ff3c0217812a8370a20aa528f117e928fd1b95f4 --- /dev/null +++ b/components/viz/service/display_embedder/software_output_device_proxy.h @@ -0,0 +1,88 @@ @@ -414,7 +416,7 @@ index 0000000000000000000000000000000000000000..01e1e2f0860faa1afe42c342c8905a7f + ~SoftwareOutputDeviceProxy() override; + + // SoftwareOutputDevice implementation. -+ void OnSwapBuffers(base::OnceClosure swap_ack_callback) override; ++ void OnSwapBuffers(SoftwareOutputDevice::SwapBuffersCallback swap_ack_callback) override; + + // SoftwareOutputDeviceBase implementation. + void ResizeDelegated() override; @@ -429,7 +431,7 @@ index 0000000000000000000000000000000000000000..01e1e2f0860faa1afe42c342c8905a7f + + std::unique_ptr canvas_; + bool waiting_on_draw_ack_ = false; -+ base::OnceClosure swap_ack_callback_; ++ SoftwareOutputDevice::SwapBuffersCallback swap_ack_callback_; + +#if !defined(WIN32) + base::WritableSharedMemoryMapping shm_mapping_; @@ -442,7 +444,7 @@ index 0000000000000000000000000000000000000000..01e1e2f0860faa1afe42c342c8905a7f + +#endif // COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_SOFTWARE_OUTPUT_DEVICE_PROXY_H_ diff --git a/components/viz/service/display_embedder/software_output_device_win.cc b/components/viz/service/display_embedder/software_output_device_win.cc -index a339eaa4dc9ccec292b3df9f31adf1ad45119a77..33146bbe7bb01fbe24cea10d79cad2748dd04a24 100644 +index 4e3f0255d5fe4991004a50768932c36c42d999ff..bf352091cef00482e3cec74cd523e469e1bffa0d 100644 --- a/components/viz/service/display_embedder/software_output_device_win.cc +++ b/components/viz/service/display_embedder/software_output_device_win.cc @@ -11,6 +11,7 @@ @@ -453,7 +455,7 @@ index a339eaa4dc9ccec292b3df9f31adf1ad45119a77..33146bbe7bb01fbe24cea10d79cad274 #include "mojo/public/cpp/system/platform_handle.h" #include "services/viz/privileged/interfaces/compositing/layered_window_updater.mojom.h" #include "skia/ext/platform_canvas.h" -@@ -321,7 +322,7 @@ void SoftwareOutputDeviceWinProxy::EndPaintDelegated( +@@ -268,7 +269,7 @@ void SoftwareOutputDeviceWinProxy::EndPaintDelegated( if (!canvas_) return; @@ -462,7 +464,7 @@ index a339eaa4dc9ccec292b3df9f31adf1ad45119a77..33146bbe7bb01fbe24cea10d79cad274 &SoftwareOutputDeviceWinProxy::DrawAck, base::Unretained(this))); waiting_on_draw_ack_ = true; -@@ -362,8 +363,13 @@ std::unique_ptr CreateSoftwareOutputDeviceWinGpu( +@@ -300,8 +301,13 @@ std::unique_ptr CreateSoftwareOutputDeviceWin( display_client->CreateLayeredWindowUpdater( mojo::MakeRequest(&layered_window_updater)); @@ -479,10 +481,10 @@ index a339eaa4dc9ccec292b3df9f31adf1ad45119a77..33146bbe7bb01fbe24cea10d79cad274 return std::make_unique(hwnd, backing); } diff --git a/services/viz/privileged/interfaces/compositing/display_private.mojom b/services/viz/privileged/interfaces/compositing/display_private.mojom -index f43ad2f0aeeb4e088c087b0c83cbf35aa764dfef..f88fda16a6f6e88d38b3a3e27a7daed8c4c270f8 100644 +index deb327b7705462d2cc07edb9d37528035377af8b..bc6958aa7e4dc14d3e0cf040299642825194e2fc 100644 --- a/services/viz/privileged/interfaces/compositing/display_private.mojom +++ b/services/viz/privileged/interfaces/compositing/display_private.mojom -@@ -73,12 +73,14 @@ interface DisplayPrivate { +@@ -77,12 +77,14 @@ interface DisplayPrivate { }; interface DisplayClient { @@ -510,7 +512,7 @@ index 360cab3eee4c5189a55269d76daa1d78a98ed3d3..6834242f23d27fd6d428c2cd6040206a + Draw(gfx.mojom.Rect damage_rect) => (); }; diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h -index d1352c059e0ef414e36408648d389b479aab9e28..9326d44cdf9d92b6c7603e8697255b9c204eccf0 100644 +index 494241c374b7ffac0fa89549dc1b8a30359eb17f..5ac7c707374ebcb5510c76017edfcceee97b599e 100644 --- a/ui/compositor/compositor.h +++ b/ui/compositor/compositor.h @@ -23,6 +23,7 @@ @@ -547,7 +549,7 @@ index d1352c059e0ef414e36408648d389b479aab9e28..9326d44cdf9d92b6c7603e8697255b9c // Sets the root of the layer tree drawn by this Compositor. The root layer // must have no parent. The compositor's root layer is reset if the root layer // is destroyed. NULL can be passed to reset the root layer, in which case the -@@ -463,6 +476,8 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient, +@@ -454,6 +467,8 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient, ui::ContextFactory* context_factory_; ui::ContextFactoryPrivate* context_factory_private_; @@ -557,21 +559,21 @@ index d1352c059e0ef414e36408648d389b479aab9e28..9326d44cdf9d92b6c7603e8697255b9c Layer* root_layer_ = nullptr; diff --git a/ui/compositor/host/host_context_factory_private.cc b/ui/compositor/host/host_context_factory_private.cc -index f8b1e4b8c64809bf3b151f0578e3bfe6f5b2d6b6..d866753c01bce623c45435fc01cfbac3841afc90 100644 +index 0ff1e05244e0e64bc2456dc3d53dd2378dce1a3c..7ca7f5e0cb73c8f6560ff9730d3880a07befe663 100644 --- a/ui/compositor/host/host_context_factory_private.cc +++ b/ui/compositor/host/host_context_factory_private.cc -@@ -70,8 +70,12 @@ void HostContextFactoryPrivate::ConfigureCompositor( +@@ -99,8 +99,12 @@ void HostContextFactoryPrivate::ConfigureCompositor( mojo::MakeRequest(&root_params->compositor_frame_sink_client); root_params->display_private = mojo::MakeRequest(&compositor_data.display_private); - compositor_data.display_client = -- std::make_unique(compositor->widget()); +- std::make_unique(compositor); + if (compositor->delegate()) + compositor_data.display_client = compositor->delegate()->CreateHostDisplayClient( + compositor); + else + compositor_data.display_client = -+ std::make_unique(compositor->widget()); ++ std::make_unique(compositor); root_params->display_client = compositor_data.display_client->GetBoundPtr(resize_task_runner_) .PassInterface(); diff --git a/patches/common/chromium/frame_host_manager.patch b/patches/common/chromium/frame_host_manager.patch index 0005e383605d3..8c243d4d362f2 100644 --- a/patches/common/chromium/frame_host_manager.patch +++ b/patches/common/chromium/frame_host_manager.patch @@ -8,16 +8,16 @@ and respond with custom instance. Also allows for us to at-runtime enable or disable this patch. diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc -index 2314c6d1d29ebc61d5156644617e9eb088df5d43..05e6f77d047ecfe7430a89f2d6dcbd25bc8bc5df 100644 +index b5301d164138f21ca8ae01abfb153efde51ec324..886b6d3beb3e2d7b13a15af830bea6fb5a567cba 100644 --- a/content/browser/frame_host/render_frame_host_manager.cc +++ b/content/browser/frame_host/render_frame_host_manager.cc -@@ -2108,6 +2108,20 @@ bool RenderFrameHostManager::InitRenderView( +@@ -2127,6 +2127,20 @@ bool RenderFrameHostManager::InitRenderView( scoped_refptr RenderFrameHostManager::GetSiteInstanceForNavigationRequest( const NavigationRequest& request) { -+ BrowserContext* browser_context; ++ BrowserContext* browser_context = nullptr; + scoped_refptr candidate_site_instance; -+ if (!GetContentClient()->browser()->ShouldDisableElectronProcessRestartTricks()) { ++ if (!GetContentClient()->browser()->CanUseCustomSiteInstance()) { + browser_context = + delegate_->GetControllerForRenderManager().GetBrowserContext(); + // If the navigation can swap SiteInstances, compute the SiteInstance it @@ -32,12 +32,12 @@ index 2314c6d1d29ebc61d5156644617e9eb088df5d43..05e6f77d047ecfe7430a89f2d6dcbd25 // First, check if the navigation can switch SiteInstances. If not, the // navigation should use the current SiteInstance. SiteInstance* current_site_instance = render_frame_host_->GetSiteInstance(); -@@ -2140,6 +2154,53 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest( +@@ -2159,6 +2173,53 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest( request.common_params().url); no_renderer_swap_allowed |= request.from_begin_navigation() && !can_renderer_initiate_transfer; + -+ if (!GetContentClient()->browser()->ShouldDisableElectronProcessRestartTricks()) { ++ if (!GetContentClient()->browser()->CanUseCustomSiteInstance()) { + bool has_response_started = + (request.state() == NavigationRequest::RESPONSE_STARTED || + request.state() == NavigationRequest::FAILED) && @@ -86,11 +86,11 @@ index 2314c6d1d29ebc61d5156644617e9eb088df5d43..05e6f77d047ecfe7430a89f2d6dcbd25 } else { // Subframe navigations will use the current renderer, unless specifically // allowed to swap processes. -@@ -2151,23 +2212,28 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest( +@@ -2170,23 +2231,28 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest( if (no_renderer_swap_allowed && !should_swap_for_error_isolation) return scoped_refptr(current_site_instance); -+ if (GetContentClient()->browser()->ShouldDisableElectronProcessRestartTricks()) { ++ if (GetContentClient()->browser()->CanUseCustomSiteInstance()) { // If the navigation can swap SiteInstances, compute the SiteInstance it // should use. // TODO(clamy): We should also consider as a candidate SiteInstance the @@ -118,14 +118,14 @@ index 2314c6d1d29ebc61d5156644617e9eb088df5d43..05e6f77d047ecfe7430a89f2d6dcbd25 } diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc -index dd582ad7e2911d049575a25eb7990e50bdebc73e..5d1f43aa1bb50791ea0df6792ce7783ec1b8b9d0 100644 +index 787cd81b26508d3e04956721f0e7cec2f457aa60..8e62a5dd26595411757e03078ed0e44646c47a52 100644 --- a/content/public/browser/content_browser_client.cc +++ b/content/public/browser/content_browser_client.cc @@ -51,6 +51,20 @@ void OverrideOnBindInterface(const service_manager::BindSourceInfo& remote_info, handle); } -+bool ContentBrowserClient::ShouldDisableElectronProcessRestartTricks() { ++bool ContentBrowserClient::CanUseCustomSiteInstance() { + return false; +} + @@ -143,10 +143,10 @@ index dd582ad7e2911d049575a25eb7990e50bdebc73e..5d1f43aa1bb50791ea0df6792ce7783e const MainFunctionParams& parameters) { return nullptr; diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h -index 8e217f7098c766ec708be6f14b5b68456c0cb6f1..bac66523eea2eb3b06dc7ca54f41f84ca4834bf5 100644 +index bf9b3a601fc16d5070e4467a258a047f47b059f3..3c35eddc2498157c2b98bab55991d8aa195954f6 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h -@@ -210,8 +210,40 @@ CONTENT_EXPORT void OverrideOnBindInterface( +@@ -211,8 +211,40 @@ CONTENT_EXPORT void OverrideOnBindInterface( // the observer interfaces.) class CONTENT_EXPORT ContentBrowserClient { public: @@ -168,7 +168,7 @@ index 8e217f7098c766ec708be6f14b5b68456c0cb6f1..bac66523eea2eb3b06dc7ca54f41f84c virtual ~ContentBrowserClient() {} + // Electron: Allows disabling the below ShouldOverride patch -+ virtual bool ShouldDisableElectronProcessRestartTricks(); ++ virtual bool CanUseCustomSiteInstance(); + + // Electron: Allows overriding the SiteInstance when navigating. + virtual SiteInstanceForNavigationType ShouldOverrideSiteInstanceForNavigation( diff --git a/patches/common/chromium/render_widget_host_view_base.patch b/patches/common/chromium/render_widget_host_view_base.patch index ff2c3ec61e723..700c31e052e79 100644 --- a/patches/common/chromium/render_widget_host_view_base.patch +++ b/patches/common/chromium/render_widget_host_view_base.patch @@ -5,10 +5,10 @@ Subject: render_widget_host_view_base.patch diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc -index 534eb188b875739afe1b1267358c86155a163fe1..717241fde2f0987a77fe12281e76936a454c1d96 100644 +index a2902adc59b6b4083334130f3a8e29fca0c440d2..34673d9ab62311c458a581f98865014f01c4bcc0 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.cc +++ b/content/browser/renderer_host/render_widget_host_view_base.cc -@@ -666,6 +666,15 @@ viz::FrameSinkId RenderWidgetHostViewBase::FrameSinkIdAtPoint( +@@ -660,6 +660,15 @@ viz::FrameSinkId RenderWidgetHostViewBase::FrameSinkIdAtPoint( return frame_sink_id.is_valid() ? frame_sink_id : GetFrameSinkId(); } @@ -25,21 +25,22 @@ index 534eb188b875739afe1b1267358c86155a163fe1..717241fde2f0987a77fe12281e76936a const blink::WebMouseEvent& event, const ui::LatencyInfo& latency) { diff --git a/content/browser/renderer_host/render_widget_host_view_base.h b/content/browser/renderer_host/render_widget_host_view_base.h -index ce353fb6f6e6c1fef82a9295c336705bff87959a..aa26976864de74f1ebb151b384d33e8e805debc9 100644 +index 903131f45d4fa82af9a6315227505b54ee0f1560..6450a05a4829731d3dc2338fd51ef6d0720b7fcb 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.h +++ b/content/browser/renderer_host/render_widget_host_view_base.h -@@ -23,8 +23,10 @@ +@@ -24,9 +24,11 @@ #include "components/viz/common/surfaces/surface_id.h" #include "components/viz/host/hit_test/hit_test_query.h" #include "content/browser/renderer_host/event_with_latency_info.h" +#include "content/browser/web_contents/web_contents_view.h" #include "content/common/content_export.h" + #include "content/common/tab_switch_time_recorder.h" #include "content/public/browser/render_frame_metadata_provider.h" +#include "content/public/browser/render_widget_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/common/input_event_ack_state.h" #include "content/public/common/screen_info.h" -@@ -83,10 +85,12 @@ class CursorManager; +@@ -75,10 +77,12 @@ class CursorManager; class MouseWheelPhaseHandler; class RenderWidgetHostImpl; class RenderWidgetHostViewBaseObserver; @@ -52,9 +53,9 @@ index ce353fb6f6e6c1fef82a9295c336705bff87959a..aa26976864de74f1ebb151b384d33e8e class WebCursor; class DelegatedFrameHost; struct TextInputState; -@@ -142,6 +146,9 @@ class CONTENT_EXPORT RenderWidgetHostViewBase - GetTouchSelectionControllerClientManager() override; - void SetLastTabChangeStartTime(base::TimeTicks start_time) final; +@@ -136,6 +140,9 @@ class CONTENT_EXPORT RenderWidgetHostViewBase + bool destination_is_loaded, + bool destination_is_frozen) final; + virtual void InitAsGuest(RenderWidgetHostView* parent_host_view, + RenderWidgetHostViewGuest* guest_view) {} @@ -62,7 +63,7 @@ index ce353fb6f6e6c1fef82a9295c336705bff87959a..aa26976864de74f1ebb151b384d33e8e // This only needs to be overridden by RenderWidgetHostViewBase subclasses // that handle content embedded within other RenderWidgetHostViews. gfx::PointF TransformPointToRootCoordSpaceF( -@@ -368,6 +375,11 @@ class CONTENT_EXPORT RenderWidgetHostViewBase +@@ -364,6 +371,11 @@ class CONTENT_EXPORT RenderWidgetHostViewBase virtual void ProcessGestureEvent(const blink::WebGestureEvent& event, const ui::LatencyInfo& latency); diff --git a/patches/common/chromium/resource_file_conflict.patch b/patches/common/chromium/resource_file_conflict.patch index 7d88b25cec017..d60813d8d261a 100644 --- a/patches/common/chromium/resource_file_conflict.patch +++ b/patches/common/chromium/resource_file_conflict.patch @@ -52,10 +52,10 @@ Some alternatives to this patch: None of these options seems like a substantial maintainability win over this patch to me (@nornagon). diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn -index 5c1f067f30ba552585e49c3e761248dfc04b62e7..1f767346e6876f86c79b3d6eea26078a56fe6a75 100644 +index 2503eb797188cbb22be0ad703a35d30c16dfad9f..f0c614e9e174a2fa362242559026c8c30dee56bf 100644 --- a/chrome/BUILD.gn +++ b/chrome/BUILD.gn -@@ -1653,7 +1653,7 @@ if (is_chrome_branded && !is_android) { +@@ -1685,7 +1685,7 @@ if (is_chrome_branded && !is_android) { } } @@ -64,7 +64,7 @@ index 5c1f067f30ba552585e49c3e761248dfc04b62e7..1f767346e6876f86c79b3d6eea26078a chrome_paks("packed_resources") { if (is_mac) { output_dir = "$root_gen_dir/repack" -@@ -1677,6 +1677,12 @@ if (!is_android) { +@@ -1709,6 +1709,12 @@ if (!is_android) { } } diff --git a/patches/common/chromium/webview_cross_drag.patch b/patches/common/chromium/webview_cross_drag.patch index 985d3642d817e..38bbe0a64ed7f 100644 --- a/patches/common/chromium/webview_cross_drag.patch +++ b/patches/common/chromium/webview_cross_drag.patch @@ -5,10 +5,10 @@ Subject: webview_cross_drag.patch diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc -index 73f03a6f736fc939d0dcac08ae31090b44511420..55886e16575b9d6a0e434a1cc5a9af183f973968 100644 +index ee5760ecbe0f836d0e49f53527252a48f4344b03..a413be0448816152f99d234a4e409bf0e9816be7 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc -@@ -754,6 +754,7 @@ gfx::NativeView WebContentsViewAura::GetRenderWidgetHostViewParent() const { +@@ -775,6 +775,7 @@ gfx::NativeView WebContentsViewAura::GetRenderWidgetHostViewParent() const { bool WebContentsViewAura::IsValidDragTarget( RenderWidgetHostImpl* target_rwh) const { diff --git a/patches/common/chromium/worker_context_will_destroy.patch b/patches/common/chromium/worker_context_will_destroy.patch index d4dc57373010a..67bd79ec5af1b 100644 --- a/patches/common/chromium/worker_context_will_destroy.patch +++ b/patches/common/chromium/worker_context_will_destroy.patch @@ -5,10 +5,10 @@ Subject: worker_context_will_destroy.patch diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h -index 16308aadc75efa0a0c8ebc33f72b552eba22194c..02173df5189e895204dc10fdd2c160be3d72d555 100644 +index fa2e153443329bcb5a48fe5c577db74a1aec26ca..6bad6c2e34e73d990d49fca4ad953cfbf8deba83 100644 --- a/content/public/renderer/content_renderer_client.h +++ b/content/public/renderer/content_renderer_client.h -@@ -383,6 +383,11 @@ class CONTENT_EXPORT ContentRendererClient { +@@ -384,6 +384,11 @@ class CONTENT_EXPORT ContentRendererClient { virtual void DidInitializeWorkerContextOnWorkerThread( v8::Local context) {} @@ -21,10 +21,10 @@ index 16308aadc75efa0a0c8ebc33f72b552eba22194c..02173df5189e895204dc10fdd2c160be // An empty URL is returned if the URL is not overriden. virtual GURL OverrideFlashEmbedWithHTML(const GURL& url); diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc -index 812c9b48c817cf01837e6513336c9dc76f1fda60..440339726d0bd5359f98dda971dbc4fd806c4094 100644 +index 67f40c54f2e9cfec538576dc9e9da6f495ba62aa..61bbe9cb061d83cbcc01999877d6082020ad76ba 100644 --- a/content/renderer/renderer_blink_platform_impl.cc +++ b/content/renderer/renderer_blink_platform_impl.cc -@@ -1086,6 +1086,12 @@ void RendererBlinkPlatformImpl::WillStopWorkerThread() { +@@ -1044,6 +1044,12 @@ void RendererBlinkPlatformImpl::WillStopWorkerThread() { WorkerThreadRegistry::Instance()->WillStopCurrentWorkerThread(); } @@ -38,10 +38,10 @@ index 812c9b48c817cf01837e6513336c9dc76f1fda60..440339726d0bd5359f98dda971dbc4fd const v8::Local& worker) { GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( diff --git a/content/renderer/renderer_blink_platform_impl.h b/content/renderer/renderer_blink_platform_impl.h -index 752d0929185111f4b8ad8bdb0ba5d54e4c9de294..924d3182acccf3e2f8030a3f7a7b1f62f5f29fc3 100644 +index 7b550279f319d673ce8e4b6f4ad6e9451685bd5b..81e20536edee59ca31f2f674592e31dafb21d22c 100644 --- a/content/renderer/renderer_blink_platform_impl.h +++ b/content/renderer/renderer_blink_platform_impl.h -@@ -212,6 +212,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { +@@ -199,6 +199,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { void DidStartWorkerThread() override; void WillStopWorkerThread() override; void WorkerContextCreated(const v8::Local& worker) override; @@ -50,10 +50,10 @@ index 752d0929185111f4b8ad8bdb0ba5d54e4c9de294..924d3182acccf3e2f8030a3f7a7b1f62 void RecordMetricsForBackgroundedRendererPurge() override; diff --git a/third_party/blink/public/platform/platform.h b/third_party/blink/public/platform/platform.h -index 89475620b73b66b336842cee144cee53242a1403..b0e110e04329b0e55b42e9f57aa0d28499049222 100644 +index 23173b3891d046f96e97f786898c33e67a067c67..ea040ee90e7d544fcca371945e08267d61c7ebe9 100644 --- a/third_party/blink/public/platform/platform.h +++ b/third_party/blink/public/platform/platform.h -@@ -676,6 +676,7 @@ class BLINK_PLATFORM_EXPORT Platform { +@@ -655,6 +655,7 @@ class BLINK_PLATFORM_EXPORT Platform { virtual void DidStartWorkerThread() {} virtual void WillStopWorkerThread() {} virtual void WorkerContextCreated(const v8::Local& worker) {} @@ -62,11 +62,11 @@ index 89475620b73b66b336842cee144cee53242a1403..b0e110e04329b0e55b42e9f57aa0d284 const WebSecurityOrigin& script_origin) { return false; diff --git a/third_party/blink/renderer/core/workers/worker_thread.cc b/third_party/blink/renderer/core/workers/worker_thread.cc -index 3b579edbe368f1974d352123729a748b7acf0583..9a0554c7cdd61ce73133a42ab10ba21e08430f07 100644 +index 512c3335456016c6d9afebe607999cff3e9f4709..7c90cb0cd86f528895f6ffebfcde854acb7cd124 100644 --- a/third_party/blink/renderer/core/workers/worker_thread.cc +++ b/third_party/blink/renderer/core/workers/worker_thread.cc -@@ -569,6 +569,12 @@ void WorkerThread::PrepareForShutdownOnWorkerThread() { - SetExitCode(ExitCode::kGracefullyTerminated); +@@ -637,6 +637,12 @@ void WorkerThread::PrepareForShutdownOnWorkerThread() { + nested_runner_->QuitNow(); } + { diff --git a/spec-main/api-app-spec.ts b/spec-main/api-app-spec.ts index 3a903fb59cf92..6444e67e9a69a 100644 --- a/spec-main/api-app-spec.ts +++ b/spec-main/api-app-spec.ts @@ -1332,6 +1332,26 @@ describe('default behavior', () => { expect(app.userAgentFallback).to.equal(initialValue) }) }) + + describe('app.allowRendererProcessReuse', () => { + it('should default to false', () => { + expect(app.allowRendererProcessReuse).to.equal(false) + }) + + it('should cause renderer processes to get new PIDs when false', async () => { + const output = await runTestApp('site-instance-overrides', 'false') + expect(output[0]).to.be.a('number').that.is.greaterThan(0) + expect(output[1]).to.be.a('number').that.is.greaterThan(0) + expect(output[0]).to.not.equal(output[1]) + }) + + it('should cause renderer processes to keep the same PID when true', async () => { + const output = await runTestApp('site-instance-overrides', 'true') + expect(output[0]).to.be.a('number').that.is.greaterThan(0) + expect(output[1]).to.be.a('number').that.is.greaterThan(0) + expect(output[0]).to.equal(output[1]) + }) + }) }) async function runTestApp (name: string, ...args: any[]) { diff --git a/spec/fixtures/api/site-instance-overrides/index.html b/spec/fixtures/api/site-instance-overrides/index.html new file mode 100644 index 0000000000000..6c70bcfe4d48d --- /dev/null +++ b/spec/fixtures/api/site-instance-overrides/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/spec/fixtures/api/site-instance-overrides/main.js b/spec/fixtures/api/site-instance-overrides/main.js new file mode 100644 index 0000000000000..20d10b8ff54c9 --- /dev/null +++ b/spec/fixtures/api/site-instance-overrides/main.js @@ -0,0 +1,33 @@ +const { app, BrowserWindow, ipcMain } = require('electron') +const path = require('path') + +process.on('uncaughtException', (e) => { + console.error(e) + process.exit(1) +}) + +app.allowRendererProcessReuse = JSON.parse(process.argv[2]) + +const pids = [] +let win + +ipcMain.on('pid', (event, pid) => { + pids.push(pid) + if (pids.length === 2) { + console.log(JSON.stringify(pids)) + if (win) win.close() + app.quit() + } else { + if (win) win.reload() + } +}) + +app.whenReady().then(() => { + win = new BrowserWindow({ + show: false, + webPreferences: { + preload: path.resolve(__dirname, 'preload.js') + } + }) + win.loadFile('index.html') +}) diff --git a/spec/fixtures/api/site-instance-overrides/package.json b/spec/fixtures/api/site-instance-overrides/package.json new file mode 100644 index 0000000000000..511d3a3c573e9 --- /dev/null +++ b/spec/fixtures/api/site-instance-overrides/package.json @@ -0,0 +1,4 @@ +{ + "name": "site-instance-overrides", + "main": "main.js" +} diff --git a/spec/fixtures/api/site-instance-overrides/preload.js b/spec/fixtures/api/site-instance-overrides/preload.js new file mode 100644 index 0000000000000..721369deb3449 --- /dev/null +++ b/spec/fixtures/api/site-instance-overrides/preload.js @@ -0,0 +1,3 @@ +const { ipcRenderer } = require('electron') + +ipcRenderer.send('pid', process.pid)