Add a setting for Chromium's low-end device mode

See #4039
See #2377
This commit is contained in:
Florian Bruhin 2018-09-17 17:07:02 +02:00
parent 574d7c6a11
commit 6fe09c12da
5 changed files with 69 additions and 0 deletions

View File

@ -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
~~~~~~~

View File

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

View File

@ -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.
default: auto
backend: QtWebEngine
restart: true
desc: >-
Use Chromium's low-end device mode.
This improves the RAM usage of renderer processes, at the expense of
performance.
qt.highdpi:
type: Bool
default: false

View File

@ -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

View File

@ -492,6 +492,26 @@ class TestQtArgs:
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