Files
marfrit-packages/arch/firefox-fourier/PKGBUILD
T
claude-noether d63d1cef72 firefox-fourier: move vendor-prefs to defaults/preferences/ (the path Firefox actually scans)
Empirical follow-up to #9. After packaging 150.0.1-4 and installing on
fresnel, MOZ_LOG showed the failure pattern was still present:

  D/FFmpegVideo FFMPEG: Using preferred software codec h264

No VAAPI_VLD engagement, no dmabuf surface locking — Gecko bailed
before reaching the patched VAAPI path. Same symptom as issue #8
pre-fix, despite the prefs file being on disk at the expected path.

Root cause: /usr/lib/firefox-fourier/browser/defaults/preferences/ is
NOT a vendor-prefs scan location in Firefox 150. Mozilla's canonical
scan dir is /usr/lib/<app>/defaults/preferences/ — without the
'browser/' prefix.

Verified by hand-copying the same file to /usr/lib/firefox-fourier/
defaults/preferences/ and re-running the H.264 playback test:

  D/FFmpegVideo FFMPEG: Requesting pixel format VAAPI_VLD
  D/Dmabuf VideoFrameSurface: VAAPI locking dmabuf surface UID 26267
    FFMPEG ID 0x4000000 mAVHWFrameContext ...
  D/Dmabuf VideoFrameSurface: VAAPI locking dmabuf surface UID 26268
    FFMPEG ID 0x4000001 ...
  (15+ surface locks)

End-to-end zero-copy DMABUF path engaged, hantro/rkvdec dekodes the
H.264 stream via libva-v4l2-request-fourier iter38b.

pkgrel 4 -> 5. No other PKGBUILD changes.
2026-05-15 14:18:09 +00:00

184 lines
6.5 KiB
Bash

# Maintainer: Markus Fritsche <mfritsche@reauktion.de>
#
# Firefox with V4L2 stateless (request API) hardware video decode
# unlocked for mainline-Linux Rockchip (RK3399 rkvdec, RK3566/RK3588
# hantro multiplanar, RK3588 rkvdec2). Sibling to chromium-fourier;
# same niche. No vendor MPP, no Mali blob, no panfork, no 5.10 BSP.
#
# Patch series adds 4 thin shims around upstream firefox (~+169 lines,
# zero deletions). Architecture: stateless decode rides libavcodec's
# v4l2_request hwaccel (AV_HWDEVICE_TYPE_DRM); no separate Mozilla V4L2
# decoder gets written. See ../../arch/firefox-fourier/PLAN.md for
# the full diagnosis. Mozilla bug 1969297.
pkgname=firefox-fourier
pkgver=150.0.1
pkgrel=5
pkgdesc='Firefox with V4L2 stateless HW video decode unlocked for mainline Linux Rockchip'
arch=('aarch64' 'x86_64')
url='https://www.mozilla.org/firefox'
license=('MPL-2.0')
depends=(
alsa-lib
at-spi2-core
cairo
dbus
ffmpeg
fontconfig
freetype2
gcc-libs
gdk-pixbuf2
glib2
glibc
gtk3
hicolor-icon-theme
libdrm
libpulse
libva
libxcb
libxkbcommon
mesa
nspr
nss
pango
pciutils
ttf-liberation
v4l-utils
)
makedepends=(
cbindgen
clang
imagemagick
inetutils
lld
llvm
mesa
nasm
nodejs
python
rust
unzip
wasi-compiler-rt
wasi-libc
yasm
zip
)
optdepends=(
'hunspell-en_us: spell checking, American English'
'libnotify: send notifications when downloads complete'
'pulseaudio: audio support'
)
provides=(firefox)
conflicts=(firefox)
options=('!emptydirs' '!strip')
source=(
"https://archive.mozilla.org/pub/firefox/releases/${pkgver}/source/firefox-${pkgver}.source.tar.xz"
'mozconfig'
# Arch's official firefox patches — toolchain glue for clang 22 +
# glibc 2.43 + Rust 1.95+. Picked up verbatim because we hit the same
# walls. arch-0001 (install-under-remoting) skipped — our launcher
# ships under /usr/bin/firefox-fourier with our own wrapper.
# https://gitlab.archlinux.org/archlinux/packaging/packages/firefox
'arch-0002-Bug-2033279-Make-enable-rust-simd-work-with-Rust-1.9.patch'
'arch-0003-Patch-glsl-optimizer-to-build-with-glibc-2.43.patch'
'arch-0004-Bug-2023597-Use-wasm32-wasip1-target-for-clang-22.1-.patch'
# firefox-fourier patches — V4L2 stateless decode unlock.
'0001-gfxinfo-v4l2-stateless-fourccs.patch'
'0002-libwrapper-hwdevice-ctx-create.patch'
'0003-ffmpegvideo-v4l2-request-route.patch'
'0004-prefs-v4l2-request.patch'
'0005-rdd-sandbox-v4l2-media-ctl.patch'
# Vendor-default prefs that gate the patched VAAPI path on RK3399 —
# widget.dmabuf.force-enabled etc. See marfrit-packages#8 for evidence.
'rockchip-fourier-defaults.js'
)
sha256sums=('SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP')
prepare() {
cd "${srcdir}/firefox-${pkgver}"
# Toolchain glue (Arch upstream) — apply BEFORE the fourier patches.
patch -Np1 -i "${srcdir}/arch-0002-Bug-2033279-Make-enable-rust-simd-work-with-Rust-1.9.patch"
patch -Np1 -i "${srcdir}/arch-0003-Patch-glsl-optimizer-to-build-with-glibc-2.43.patch"
patch -Np1 -i "${srcdir}/arch-0004-Bug-2023597-Use-wasm32-wasip1-target-for-clang-22.1-.patch"
# Fourier patches — order matters; see ../PLAN.md for rationale.
patch -Np1 -i "${srcdir}/0001-gfxinfo-v4l2-stateless-fourccs.patch"
patch -Np1 -i "${srcdir}/0002-libwrapper-hwdevice-ctx-create.patch"
patch -Np1 -i "${srcdir}/0003-ffmpegvideo-v4l2-request-route.patch"
patch -Np1 -i "${srcdir}/0004-prefs-v4l2-request.patch"
patch -Np1 -i "${srcdir}/0005-rdd-sandbox-v4l2-media-ctl.patch"
cp "${srcdir}/mozconfig" .mozconfig
}
build() {
cd "${srcdir}/firefox-${pkgver}"
# Arch's makepkg.conf injects -fexceptions into CFLAGS/CXXFLAGS by
# default for hardening. Mozilla's STL wrappers refuse to compile
# with exceptions enabled (#error "STL code can only be used with
# -fno-exceptions"). Strip the offender before mach configure picks
# up the env. Same trick the upstream Arch firefox PKGBUILD uses.
CFLAGS="${CFLAGS//-fexceptions/}"
CXXFLAGS="${CXXFLAGS//-fexceptions/}"
export CFLAGS CXXFLAGS
export MOZ_NOSPAM=1
export MOZ_API_KEY_UNUSED=1
export MOZ_TELEMETRY_REPORTING=
export MOZ_REQUIRE_SIGNING=
export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system
export PYTHON=/usr/bin/python
./mach configure
./mach build
}
package() {
cd "${srcdir}/firefox-${pkgver}"
DESTDIR="${pkgdir}" ./mach install
# Move mach's default /usr/local/* layout to /usr/* so we conflict
# with `firefox` cleanly and `provides=firefox` actually works.
# `cp -r` preserves the bin symlink (target lives in /usr/local) —
# delete it before staging the launcher so `cat >` doesn't follow a
# dangling symlink and ENOENT.
if [ -d "${pkgdir}/usr/local" ]; then
cp -r "${pkgdir}/usr/local/." "${pkgdir}/usr/"
rm -rf "${pkgdir}/usr/local"
fi
rm -f "${pkgdir}/usr/bin/firefox-fourier"
# Launcher script. mach's install drops the binary at
# /usr/lib/firefox-fourier/firefox-fourier (a small bash launcher) plus
# firefox-fourier-bin alongside; we exec the launcher.
cat > "${pkgdir}/usr/bin/firefox-fourier" <<'LAUNCHER'
#!/bin/bash
# firefox-fourier launcher — V4L2 stateless HW decode path defaults.
# Patch 4/4 already defaults media.ffmpeg.v4l2-request.enabled=true on
# Linux; the env vars below cover the platform-detection bits firefox
# still consults at startup.
export MOZ_ENABLE_WAYLAND="${MOZ_ENABLE_WAYLAND:-1}"
export MOZ_X11_EGL="${MOZ_X11_EGL:-1}"
exec /usr/lib/firefox-fourier/firefox-fourier "$@"
LAUNCHER
chmod 0755 "${pkgdir}/usr/bin/firefox-fourier"
# Vendor-default prefs (RK3399 HW-decode unlock) — closes #8.
# Lower precedence than user prefs / about:config; loaded by Firefox
# at startup from the package install dir. The 0004 patch covers
# media.ffmpeg.v4l2-request.enabled; this file covers the three
# additional prefs that gate the path to the patched code.
# Vendor-prefs install path: /usr/lib/firefox-fourier/defaults/preferences/
# (Mozilla's canonical scan dir for third-party default-pref drops.) The
# browser/defaults/preferences/ alternative looked promising but is NOT a
# vendor-prefs scan location in Firefox 150 — empirically confirmed on
# fresnel: file shipped there, VAAPI never engaged. Same file under
# defaults/preferences/ → MOZ_LOG showed `Requesting pixel format
# VAAPI_VLD` + dmabuf surfaces locking end-to-end.
install -Dm644 "${srcdir}/rockchip-fourier-defaults.js" \
"${pkgdir}/usr/lib/firefox-fourier/defaults/preferences/rockchip-fourier-defaults.js"
}