From e055500476d2df9a4493fdcfad2d751f6e02671d Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Tue, 5 Apr 2022 15:23:22 -0500 Subject: [PATCH] Drop Playwright, run Firefox Marionette Running Voonex (Python), Playwight (Node.js), and Firefox simultaneously takes way too much memory. Using the NBD swap prevents hard lockups and crashes in OOM situations, but it makes the machine *incredibly* slow. To avoid needing to push anything into the network swap, I want to try and reduce the memory footprint as much as possible. To that end, we will go back to running just Firefox. To control it, we will use the Marionette protocol. Firefox only allows control via Marionette over the loopback interface. This is hard-coded in the Marionette server, and cannot be changed at runtime. To allow a remote machine (running Voonex) to control it, we need to expose the socket to the network. Fortunately, *systemd* includes a tool for exactly this purpose: `systemd-socket-proxyd`. --- mkrootfs.sh | 16 +--------------- overlay/etc/systemd/user/basementhud.service | 7 ------- .../etc/systemd/user/firefox-marionette.service | 7 +++++++ .../etc/systemd/user/firefox-marionette.socket | 5 +++++ overlay/etc/systemd/user/firefox.service | 10 ++++++++++ overlay/home/user/.xinitrc | 2 +- 6 files changed, 24 insertions(+), 23 deletions(-) delete mode 100644 overlay/etc/systemd/user/basementhud.service create mode 100644 overlay/etc/systemd/user/firefox-marionette.service create mode 100644 overlay/etc/systemd/user/firefox-marionette.socket create mode 100644 overlay/etc/systemd/user/firefox.service diff --git a/mkrootfs.sh b/mkrootfs.sh index 8e42e46..f0ed05d 100644 --- a/mkrootfs.sh +++ b/mkrootfs.sh @@ -19,6 +19,7 @@ echo install_weak_deps=False >> "${destdir}"/etc/dnf/dnf.conf dnf --installroot "${destdir}" install -y \ bcm2711-firmware \ dracut-network \ + firefox \ hostname \ kmod \ mesa-dri-drivers \ @@ -62,21 +63,6 @@ chroot "${destdir}" systemctl enable \ systemd-timesyncd \ xinit@user -if ! [ -f "${destdir}"/usr/local/bin/playwright ]; then - python3 -m pip \ - install \ - --prefix "${destdir}"/usr/local \ - playwright -fi -if ! [ -d "${destdir}"/usr/local/ms-playwright ]; then - py_site_dir=$( - "${destdir}"/usr/bin/python3 -c 'import site;print(site.getsitepackages()[0])' - ) - PLAYWRIGHT_BROWSERS_PATH="${destdir}"/usr/local/ms-playwright \ - PYTHONPATH="${destdir}${py_site_dir}" \ - python3 -m playwright install firefox -fi - umask 0022 mksquashfs "${destdir}" "${destdir}/boot/${dest}" \ -comp lz4 \ diff --git a/overlay/etc/systemd/user/basementhud.service b/overlay/etc/systemd/user/basementhud.service deleted file mode 100644 index 4af7fb8..0000000 --- a/overlay/etc/systemd/user/basementhud.service +++ /dev/null @@ -1,7 +0,0 @@ -[Unit] -Description=Basement HUD - -[Service] -Type=simple -Environment=PLAYWRIGHT_BROWSERS_PATH=/usr/local/ms-playwright -ExecStart=/usr/local/bin/basementhud diff --git a/overlay/etc/systemd/user/firefox-marionette.service b/overlay/etc/systemd/user/firefox-marionette.service new file mode 100644 index 0000000..f83ac13 --- /dev/null +++ b/overlay/etc/systemd/user/firefox-marionette.service @@ -0,0 +1,7 @@ +[Unit] +Description=Firefox marionette reverse proxy +Requires=firefox-marionette.socket +Requires=firefox.service + +[Service] +ExecStart=/usr/lib/systemd/systemd-socket-proxyd 127.0.0.1:2828 diff --git a/overlay/etc/systemd/user/firefox-marionette.socket b/overlay/etc/systemd/user/firefox-marionette.socket new file mode 100644 index 0000000..ad61a1f --- /dev/null +++ b/overlay/etc/systemd/user/firefox-marionette.socket @@ -0,0 +1,5 @@ +[Unit] +Description=Firefox Marionette socket + +[Socket] +ListenStream=[::]:2829 diff --git a/overlay/etc/systemd/user/firefox.service b/overlay/etc/systemd/user/firefox.service new file mode 100644 index 0000000..c4a2b5f --- /dev/null +++ b/overlay/etc/systemd/user/firefox.service @@ -0,0 +1,10 @@ +[Unit] +Description=Firefox web browser +Wants=firefox-marionette.socket + +[Service] +Type=simple +ExecStart=/usr/bin/firefox -marionette +Restart=always +StandardInput=null +StandardOutput=journal diff --git a/overlay/home/user/.xinitrc b/overlay/home/user/.xinitrc index 2f3a150..f5ba62b 100644 --- a/overlay/home/user/.xinitrc +++ b/overlay/home/user/.xinitrc @@ -3,5 +3,5 @@ xset s off xset -dpms systemctl --user import-environment DISPLAY -systemctl --user start basementhud.service +systemctl --user start firefox-marionette.socket exec openbox