Skip to content

Commit

Permalink
chore: remove app.allowRendererProcessReuse
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Dec 7, 2020
1 parent 3db4e61 commit 5eb9685
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 320 deletions.
13 changes: 0 additions & 13 deletions docs/api/app.md
Expand Up @@ -1477,19 +1477,6 @@ This is the user agent that will be used when no user agent is set at the
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 `true`.

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).

### `app.runningUnderRosettaTranslation` _macOS_ _Readonly_

A `Boolean` which when `true` indicates that the app is currently running
Expand Down
7 changes: 0 additions & 7 deletions docs/api/browser-window.md
Expand Up @@ -284,13 +284,6 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
same `partition`. If there is no `persist:` prefix, the page will use an
in-memory session. By assigning the same `partition`, multiple pages can share
the same session. Default is the default session.
* `affinity` String (optional) - When specified, web pages with the same
`affinity` will run in the same renderer process. Note that due to reusing
the renderer process, certain `webPreferences` options will also be shared
between the web pages even when you specified different values for them,
including but not limited to `preload`, `sandbox` and `nodeIntegration`.
So it is suggested to use exact same `webPreferences` for web pages with
the same `affinity`. _Deprecated_
* `zoomFactor` Number (optional) - The default zoom factor of the page, `3.0` represents
`300%`. Default is `1.0`.
* `javascript` Boolean (optional) - Enables JavaScript support. Default is `true`.
Expand Down
6 changes: 1 addition & 5 deletions lib/browser/api/app.ts
@@ -1,7 +1,7 @@
import * as fs from 'fs';
import * as path from 'path';

import { deprecate, Menu } from 'electron/main';
import { Menu } from 'electron/main';

const bindings = process._linkedBinding('electron_browser_app');
const commandLine = process._linkedBinding('electron_common_command_line');
Expand Down Expand Up @@ -129,7 +129,3 @@ for (const name of events) {
webContents.emit(name, event, ...args);
});
}

// Deprecate allowRendererProcessReuse but only if they set it to false, no need to log if
// they are setting it to true
deprecate.removeProperty({ __proto__: app } as any, 'allowRendererProcessReuse', [false]);
12 changes: 1 addition & 11 deletions shell/browser/api/electron_api_app.cc
Expand Up @@ -1457,13 +1457,6 @@ std::string App::GetUserAgentFallback() {
return ElectronBrowserClient::Get()->GetUserAgent();
}

void App::SetBrowserClientCanUseCustomSiteInstance(bool should_disable) {
ElectronBrowserClient::Get()->SetCanUseCustomSiteInstance(should_disable);
}
bool App::CanBrowserClientUseCustomSiteInstance() {
return ElectronBrowserClient::Get()->CanUseCustomSiteInstance();
}

#if defined(OS_MAC)
bool App::MoveToApplicationsFolder(gin_helper::ErrorThrower thrower,
gin::Arguments* args) {
Expand Down Expand Up @@ -1663,10 +1656,7 @@ gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) {
#endif
.SetProperty("userAgentFallback", &App::GetUserAgentFallback,
&App::SetUserAgentFallback)
.SetMethod("enableSandbox", &App::EnableSandbox)
.SetProperty("allowRendererProcessReuse",
&App::CanBrowserClientUseCustomSiteInstance,
&App::SetBrowserClientCanUseCustomSiteInstance);
.SetMethod("enableSandbox", &App::EnableSandbox);
}

const char* App::GetTypeName() {
Expand Down
2 changes: 0 additions & 2 deletions shell/browser/api/electron_api_app.h
Expand Up @@ -213,8 +213,6 @@ class App : public ElectronBrowserClient::Delegate,
void EnableSandbox(gin_helper::ErrorThrower thrower);
void SetUserAgentFallback(const std::string& user_agent);
std::string GetUserAgentFallback();
void SetBrowserClientCanUseCustomSiteInstance(bool should_disable);
bool CanBrowserClientUseCustomSiteInstance();

#if defined(OS_MAC)
void SetActivationPolicy(gin_helper::ErrorThrower thrower,
Expand Down
9 changes: 0 additions & 9 deletions shell/browser/api/electron_api_web_contents.cc
Expand Up @@ -2043,23 +2043,14 @@ void WebContents::Stop() {
}

void WebContents::GoBack() {
if (!ElectronBrowserClient::Get()->CanUseCustomSiteInstance()) {
electron::ElectronBrowserClient::SuppressRendererProcessRestartForOnce();
}
web_contents()->GetController().GoBack();
}

void WebContents::GoForward() {
if (!ElectronBrowserClient::Get()->CanUseCustomSiteInstance()) {
electron::ElectronBrowserClient::SuppressRendererProcessRestartForOnce();
}
web_contents()->GetController().GoForward();
}

void WebContents::GoToOffset(int offset) {
if (!ElectronBrowserClient::Get()->CanUseCustomSiteInstance()) {
electron::ElectronBrowserClient::SuppressRendererProcessRestartForOnce();
}
web_contents()->GetController().GoToOffset(offset);
}

Expand Down
11 changes: 1 addition & 10 deletions shell/browser/electron_browser_client.cc
Expand Up @@ -609,8 +609,7 @@ void ElectronBrowserClient::OverrideWebkitPrefs(
SessionPreferences::GetValidPreloads(web_contents->GetBrowserContext());
if (!preloads.empty())
prefs->preloads = preloads;
if (CanUseCustomSiteInstance())
prefs->disable_electron_site_instance_overrides = true;
prefs->disable_electron_site_instance_overrides = true;

SetFontDefaults(prefs);

Expand All @@ -621,14 +620,6 @@ void ElectronBrowserClient::OverrideWebkitPrefs(
}
}

void ElectronBrowserClient::SetCanUseCustomSiteInstance(bool should_disable) {
disable_process_restart_tricks_ = should_disable;
}

bool ElectronBrowserClient::CanUseCustomSiteInstance() {
return disable_process_restart_tricks_;
}

content::ContentBrowserClient::SiteInstanceForNavigationType
ElectronBrowserClient::ShouldOverrideSiteInstanceForNavigation(
content::RenderFrameHost* current_rfh,
Expand Down
4 changes: 0 additions & 4 deletions shell/browser/electron_browser_client.h
Expand Up @@ -82,8 +82,6 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
std::string GetUserAgent() override;
void SetUserAgent(const std::string& user_agent);

void SetCanUseCustomSiteInstance(bool should_disable);
bool CanUseCustomSiteInstance() override;
content::SerialDelegate* GetSerialDelegate() override;

protected:
Expand Down Expand Up @@ -329,8 +327,6 @@ class ElectronBrowserClient : public content::ContentBrowserClient,

std::string user_agent_override_ = "";

bool disable_process_restart_tricks_ = true;

// Simple shared ID generator, used by ProxyingURLLoaderFactory and
// ProxyingWebSocket classes.
uint64_t next_id_ = 0;
Expand Down
20 changes: 0 additions & 20 deletions spec-main/api-app-spec.ts
Expand Up @@ -1746,26 +1746,6 @@ describe('default behavior', () => {
});
});

describe('app.allowRendererProcessReuse', () => {
it('should default to true', () => {
expect(app.allowRendererProcessReuse).to.equal(true);
});

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]);
});
});

describe('login event', () => {
afterEach(closeAllWindows);
let server: http.Server;
Expand Down
175 changes: 0 additions & 175 deletions spec-main/api-browser-window-affinity-spec.ts

This file was deleted.

0 comments on commit 5eb9685

Please sign in to comment.