Files
DroidDeck/tools/tests/test_desktop_firefox_software.py
T
JM LamboandJacob Lambert 0a27c8bb98 fix(desktop): Firefox renders in software on the system PowerVR driver (#2839)
* fix(desktop): Firefox draws on the system PowerVR driver

Under the nested KWin on the system PowerVR driver, Firefox's Wayland window
stops updating partway through drawing and repaints only where the pointer
moves. Through Xwayland it draws normally, so Desktop runs Firefox on X11 on
that path.

* fix(desktop): Firefox renders in software on the system PowerVR driver

The Xwayland workaround only worked because Firefox fell back to software
WebRender there. The breakage follows hardware WebRender on zink, not the
Wayland window: with MOZ_ACCELERATED=0 Firefox draws correctly on Wayland,
so it keeps native Wayland features such as fractional scaling.

---------

Co-authored-by: Jacob Lambert <183008808+JMLambo@users.noreply.github.com>
2026-11-24 16:16:55 -05:00

41 lines
2.0 KiB
Python

import os
from pathlib import Path
import subprocess
import unittest
DESKTOP = (Path(__file__).resolve().parents[1] / 'linuxfs/desktop/droiddeck-desktop').read_text()
START = 'if [ "$(cat /usr/share/droiddeck/kwin-compositor 2>/dev/null)" = opengl ]; then'
LINE = '\n [ "${DD_STEAM_GL_PRESENT:-}" = 1 ] && export MOZ_ACCELERATED=0\n'
class DesktopFirefoxSoftwareTest(unittest.TestCase):
def firefox_environment(self, gl_present):
head = DESKTOP[:DESKTOP.index('\n', DESKTOP.index('export MOZ_ENABLE_WAYLAND=1'))]
head = head[head.rindex('\n') + 1:]
block = DESKTOP[DESKTOP.index(START):]
block = block[block.index('\n') + 1:block.index('\n if [ -z "${KWIN_RENDER_NODES:-}" ]')]
environment = {key: value for key, value in os.environ.items()
if key not in ('DD_STEAM_GL_PRESENT', 'MOZ_ENABLE_WAYLAND', 'MOZ_ACCELERATED')}
if gl_present is not None:
environment['DD_STEAM_GL_PRESENT'] = gl_present
script = head + '\n' + block + '\nsh -c \'echo "wayland:${MOZ_ENABLE_WAYLAND:-unset} accelerated:${MOZ_ACCELERATED:-unset}"\''
result = subprocess.run(['bash', '-c', script], env=environment, capture_output=True,
text=True, timeout=5)
self.assertEqual(0, result.returncode, result.stderr)
return result.stdout.strip().splitlines()[-1]
def test_system_powervr_desktop_runs_firefox_on_wayland_with_software_rendering(self):
self.assertEqual('wayland:1 accelerated:0', self.firefox_environment('1'))
def test_other_drivers_keep_firefox_hardware_rendering(self):
self.assertEqual('wayland:1 accelerated:unset', self.firefox_environment(None))
self.assertEqual('wayland:1 accelerated:unset', self.firefox_environment('0'))
def test_override_is_set_before_plasma(self):
self.assertLess(DESKTOP.index(LINE), DESKTOP.index('dbus-run-session -- startplasma-wayland'))
if __name__ == '__main__':
unittest.main()