Skip to content

Commit

Permalink
Add a setting for Chromium's low-end device mode
Browse files Browse the repository at this point in the history
See #4039
See #2377
  • Loading branch information
The-Compiler committed Sep 17, 2018
1 parent 574d7c6 commit 6fe09c1
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/changelog.asciidoc
Expand Up @@ -34,6 +34,8 @@ Added
* Opening PDFs on https:// sites now works properly.
- New `qt.process_model` setting which can be used to change Chromium's process
model.
- New `qt.low_end_device_mode` setting which turns on Chromium's low-end device
mode. This mode uses less RAM, but the expense of performance.
Changed
~~~~~~~
Expand Down
19 changes: 19 additions & 0 deletions doc/help/settings.asciidoc
Expand Up @@ -229,6 +229,7 @@
|<<qt.force_platform,qt.force_platform>>|Force a Qt platform to use.
|<<qt.force_software_rendering,qt.force_software_rendering>>|Force software rendering for QtWebEngine.
|<<qt.highdpi,qt.highdpi>>|Turn on Qt HighDPI scaling.
|<<qt.low_end_device_mode,qt.low_end_device_mode>>|Use Chromium's low-end device mode.
|<<qt.process_model,qt.process_model>>|Which Chromium process model to use.
|<<scrolling.bar,scrolling.bar>>|Show a scrollbar.
|<<scrolling.smooth,scrolling.smooth>>|Enable smooth scrolling for web pages.
Expand Down Expand Up @@ -2758,6 +2759,24 @@ Type: <<types,Bool>>

Default: +pass:[false]+

[[qt.low_end_device_mode]]
=== qt.low_end_device_mode
Use Chromium's low-end device mode.
This improves the RAM usage of renderer processes, at the expense of performance.
This setting requires a restart.

Type: <<types,String>>

Valid values:

* +force-on+: Always use low-end device mode.
* +auto+: Decide automatically (uses low-end mode with < 1 GB available RAM).
* +force-off+: Never use low-end device mode.

Default: +pass:[auto]+

This setting is only available with the QtWebEngine backend.

[[qt.process_model]]
=== qt.process_model
Which Chromium process model to use.
Expand Down
17 changes: 17 additions & 0 deletions qutebrowser/config/configdata.yml
Expand Up @@ -210,6 +210,23 @@ qt.process_model:
- https://www.chromium.org/developers/design-documents/process-models
- https://doc.qt.io/qt-5/qtwebengine-features.html#process-models
qt.low_end_device_mode:
type:
name: String
valid_values:
- force-on: Always use low-end device mode.
- auto: Decide automatically (uses low-end mode with < 1 GB available
RAM).
- force-off: Never use low-end device mode.

This comment has been minimized.

Copy link
@mschilli87

mschilli87 Sep 18, 2018

Contributor

Why don't we call the options "always", "never", and "auto" (cf. content.headers.referer)?

This comment has been minimized.

Copy link
@The-Compiler

The-Compiler Sep 18, 2018

Author Member

Good idea! Did so in 46435bc.

default: auto
backend: QtWebEngine
restart: true
desc: >-
Use Chromium's low-end device mode.

This comment has been minimized.

Copy link
@mschilli87

mschilli87 Sep 18, 2018

Contributor

If we switch to "always" and "never", we could standardize this further by starting with "When to use..."

This improves the RAM usage of renderer processes, at the expense of
performance.
qt.highdpi:
type: Bool
default: false
Expand Down
11 changes: 11 additions & 0 deletions qutebrowser/config/configinit.py
Expand Up @@ -202,4 +202,15 @@ def qt_args(namespace):
raise utils.Unreachable("Unknown process model {}"
.format(process_model))

low_end_device_mode = config.val.qt.low_end_device_mode
if low_end_device_mode == 'auto':
pass
elif low_end_device_mode == 'force-on':
argv.append('--enable-low-end-device-mode')
elif low_end_device_mode == 'force-off':
argv.append('--disable-low-end-device-mode')
else:
raise utils.Unreachable("Unknown low-end device mode {}"
.format(low_end_device_mode))

return argv
20 changes: 20 additions & 0 deletions tests/unit/config/test_configinit.py
Expand Up @@ -492,6 +492,26 @@ def test_process_model(self, config_stub, monkeypatch, parser,
assert '--process-per-site-instance' not in args
assert '--process-per-tab' not in args

@pytest.mark.parametrize('low_end_device_mode, arg', [
('auto', None),
('force-on', '--enable-low-end-device-mode'),
('force-off', '--disable-low-end-device-mode'),
])
def test_low_end_device_mode(self, config_stub, monkeypatch, parser,
low_end_device_mode, arg):
monkeypatch.setattr(configinit.objects, 'backend',
usertypes.Backend.QtWebEngine)

config_stub.val.qt.low_end_device_mode = low_end_device_mode
parsed = parser.parse_args([])
args = configinit.qt_args(parsed)

if arg is None:
assert '--enable-low-end-device-mode' not in args
assert '--disable-low-end-device-mode' not in args
else:
assert arg in args


@pytest.mark.parametrize('arg, confval, used', [
# overridden by commandline arg
Expand Down

1 comment on commit 6fe09c1

@The-Compiler
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mschilli87 I should probably have opened a PR, but mind looking at the configdata.yml changes here? (2/4)

Please sign in to comment.