You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The viewer currently runs as two processes on the same framebuffer:
AnthiasWebview (C++/Qt6, holds the framebuffer for web + image rendering)
mpv (subprocess.Popen'd by MPVMediaPlayer, takes --vo=drm and does its own DRM-master juggling for video assets)
When the operator's board has a 4K-EDID-reporting display, the contention between these two processes for /dev/fb0 / DRM master drops frames during video playback even when the HW decode path is engaged. Measured on a real Pi 4 with the BBB test bed during PR #2885 validation: 600-2800 vo drops per 60 s clip on H.264 (v4l2m2m-copy) and HEVC (drm-copy) variants.
The same mpv flags, on the same hardware, with no Qt webview competing for the framebuffer, get 0 drops. The drops are infrastructure contention, not a mpv configuration issue.
Proposed fix (Option A from the PR review)
Embed libmpv directly inside AnthiasWebview so a single Qt process owns the framebuffer and renders both web pages and video into the same Qt window.
Concrete changes
src/anthias_webview/ — C++ side:
Add libmpv-dev + libqt6openglwidgets6-dev build deps (apt — see the Conan discussion below).
New VideoView : QOpenGLWidget class wrapping an mpv_render_context (reference: mpv-examples/libmpv/qt_opengl/). ~200 LOC.
Add playVideo(QString uri) + stopVideo() D-Bus slots on MainWindow.
View switches its central widget between QWebEngineView (web), QLabel (image), and VideoView (video) based on which slot was invoked.
mpv properties (hwdec, video-sync, audio-device, drm-mode, etc.) set via mpv_set_property_string, replicating today's per-codec dispatch logic.
docker/Dockerfile.viewer.j2 — Pi 4 specifically:
Change QT_QPA_PLATFORM=linuxfb to eglfs so Qt has the OpenGL context libmpv needs to render into.
Pi 5 / x86 / arm64 stay on cage+wayland (already have GL inside cage).
src/anthias_viewer/media_player.py — Python side:
MPVMediaPlayer replaces subprocess.Popen with a QDBusConnection call to the anthias.webview service's playVideo slot.
Per-codec hwdec probe (_pi_hwdec_for_uri) sends its result alongside the URI or via a prior setPlaybackOptions slot.
stop() calls stopVideo() D-Bus.
Startup ordering — Python already waits for Anthias service start on the webview stdout (current D-Bus readiness signal). Same pattern works for video readiness.
Package management note
The right libmpv build per board comes from each board's apt repo:
Pi 4 / Pi 5 / Rock Pi 4 → archive.raspberrypi.com (+rpt1) ships libmpv with --enable-v4l2-request for the HW decoders the viewer mpv binary already uses.
x86 → Debian apt ships libmpv with --enable-vaapi.
Each board's per-board viewer image already does apt install from the correct source, so linking against libmpv-dev from the same apt run gets the byte-identical backend as the system mpv binary. Conan was considered but adds machinery to pin a single libmpv version across boards, when we genuinely want per-board variance (v4l2_request on arm, vaapi on x86). qmake → CMake migration is worth doing eventually but is a separate scope.
Background
The viewer currently runs as two processes on the same framebuffer:
AnthiasWebview(C++/Qt6, holds the framebuffer for web + image rendering)mpv(subprocess.Popen'd byMPVMediaPlayer, takes--vo=drmand does its own DRM-master juggling for video assets)When the operator's board has a 4K-EDID-reporting display, the contention between these two processes for
/dev/fb0/ DRM master drops frames during video playback even when the HW decode path is engaged. Measured on a real Pi 4 with the BBB test bed during PR #2885 validation: 600-2800 vo drops per 60 s clip on H.264 (v4l2m2m-copy) and HEVC (drm-copy) variants.The same mpv flags, on the same hardware, with no Qt webview competing for the framebuffer, get 0 drops. The drops are infrastructure contention, not a mpv configuration issue.
Proposed fix (Option A from the PR review)
Embed libmpv directly inside
AnthiasWebviewso a single Qt process owns the framebuffer and renders both web pages and video into the same Qt window.Concrete changes
src/anthias_webview/— C++ side:libmpv-dev+libqt6openglwidgets6-devbuild deps (apt — see the Conan discussion below).VideoView : QOpenGLWidgetclass wrapping anmpv_render_context(reference:mpv-examples/libmpv/qt_opengl/). ~200 LOC.playVideo(QString uri)+stopVideo()D-Bus slots onMainWindow.Viewswitches its central widget betweenQWebEngineView(web),QLabel(image), andVideoView(video) based on which slot was invoked.hwdec,video-sync,audio-device,drm-mode, etc.) set viampv_set_property_string, replicating today's per-codec dispatch logic.docker/Dockerfile.viewer.j2— Pi 4 specifically:QT_QPA_PLATFORM=linuxfbtoeglfsso Qt has the OpenGL context libmpv needs to render into.src/anthias_viewer/media_player.py— Python side:MPVMediaPlayerreplacessubprocess.Popenwith aQDBusConnectioncall to theanthias.webviewservice'splayVideoslot._pi_hwdec_for_uri) sends its result alongside the URI or via a priorsetPlaybackOptionsslot.stop()callsstopVideo()D-Bus.Startup ordering — Python already waits for
Anthias service starton the webview stdout (current D-Bus readiness signal). Same pattern works for video readiness.Package management note
The right libmpv build per board comes from each board's apt repo:
archive.raspberrypi.com(+rpt1) ships libmpv with--enable-v4l2-requestfor the HW decoders the viewer mpv binary already uses.--enable-vaapi.Each board's per-board viewer image already does
apt installfrom the correct source, so linking againstlibmpv-devfrom the same apt run gets the byte-identical backend as the systemmpvbinary. Conan was considered but adds machinery to pin a single libmpv version across boards, when we genuinely want per-board variance (v4l2_request on arm, vaapi on x86). qmake → CMake migration is worth doing eventually but is a separate scope.Why this isn't fixed in PR #2885
src/anthias_webview/— distinct scope from the codec gate work in feat(viewer,server): per-board HW decode dispatch + codec gate on upload #2885.QT_QPA_PLATFORM(linuxfb→eglfs), which needs its own perf retest across boards.Acceptance criteria
AnthiasWebviewbuilds with libmpv linked; image stays per-board.v4l2m2m-copy/drm-copy/vaapi-copyper board+codec).QT_QPA_PLATFORM=eglfsconfirmed working with V3D 6.0; no regression in image / web-page rendering.Estimated effort
~2-4 days including per-board perf retest. C++ work is ~300-500 LOC; the rest is build wiring and Python D-Bus glue.
Related