Skip to content

perf(viewer): render video via QML VideoOutput in a QQuickWidget - #2975

Merged
vpetersson merged 2 commits into
masterfrom
perf-qquick-video-sink
Jun 2, 2026
Merged

perf(viewer): render video via QML VideoOutput in a QQuickWidget#2975
vpetersson merged 2 commits into
masterfrom
perf-qquick-video-sink

Conversation

@vpetersson

Copy link
Copy Markdown
Contributor

Issues Fixed

Description

HW decode was never the problem on the Qt6 boards — presentation was. The QGraphicsVideoItem-on-raster-QGraphicsView substrate ran every frame through QVideoFrame::toImage() (an RHI offscreen render plus GPU→CPU readback), then a smooth-scaled CPU blit into the backing store, capping presentation at 8.3 fps on Pi 4 / 10–12 fps on Pi 5 while the sink-side stats read "dropped≈0".

This PR renders through a QML VideoOutput hosted in a QQuickWidget: frames stay on the GPU as scene-graph textures with shader YUV→RGB, composited via the same QQuickRenderControl FBO machinery QWebEngineView already uses — so it satisfies eglfs's single-native-window constraint (a QVideoWidget would not: it wraps a second native QVideoWindow).

Measured on the testbeds (1080p30, DRM vblank tracepoints):

Pi 4 (eglfs) Pi 5 (cage/wayland)
Presented fps 8.3 → 30.0 11.7 → 26.6 (30 Hz output)
Total viewer CPU ~115% → 64% ~155% → 13% (HEVC HW) / 175% → 35% (H.264 SW)

Also:

  • playback-stats.log now logs frames-rendered (scene-graph renders, the presentation-side rate) next to frames-delivered — the missing counter that let this regression ship unnoticed. Fields are key=value; positional parsers of SAMPLE/END_FILE/STOP lines break on this revision.
  • QML-scene-unavailable is now a qFatal (supervised crash-respawn) instead of silently decoding video to nowhere.
  • Rotation re-validated on-device: QT_QPA_EGLFS_ROTATION=90 rotates the Quick-composited window (viewport probe 1080x1920) with video still at full rate.
  • Qt6 viewer images gain qt6-declarative-dev + qml6-module-qtquick + qml6-module-qtmultimedia; multimediawidgets is dropped.

Checklist

  • I have performed a self-review of my own code.
  • New and existing unit tests pass locally and on CI with my changes.
  • I have done an end-to-end test for Raspberry Pi devices.
  • I have tested my changes for x86 devices.
  • I added a documentation for the changes I have made (when necessary).

x86/arm64 share the validated Pi 5 path (cage/wayland + Quick scene graph) but have not been live-tested; the x86 testbed has failing storage. Worth a check on real x86 hardware before release.

🤖 Generated with Claude Code

- replace the QGraphicsVideoItem-on-raster-QGraphicsView substrate:
  QVideoFrame::toImage did an RHI offscreen render + GPU->CPU
  readback per frame, capping presentation at 8.3 fps (Pi 4) /
  10-12 fps (Pi 5) with a saturated GUI thread while HW decode ran
  fine (issue 2967). Validated on both testbeds: Pi 4 30.0 fps
  presented at 64% total CPU, Pi 5 26.6 fps at 13-35%
- VideoOutput keeps frames on the GPU: scene-graph textures with
  shader YUV->RGB, composited through the same QQuickRenderControl
  FBO machinery QWebEngineView already uses (eglfs-safe, inherits
  whole-screen rotation -- re-validated under QT_QPA_EGLFS_ROTATION)
- log frames-rendered (QQuickWindow::afterRendering) next to
  frames-delivered in playback-stats so presentation-side drops are
  visible -- the sink-only counter is how the 8 fps regression
  shipped unnoticed; connection is retried from play() so the
  counter can't silently stay dead
- fail hard (qFatal) when the QML scene is unavailable instead of
  decoding video to nowhere: crash-respawn is supervised and loud,
  a silent black-screen kiosk is not
- video-rotate maps to VideoOutput.orientation (still a defensive
  no-op; every platform rotates the whole screen)
- ship qt6-declarative-dev + qml6-module-qtquick/-qtmultimedia in
  the Qt6 viewer images; drop the now-unused multimediawidgets
- run the C++ tests with QT_QUICK_BACKEND=software so the QML scene
  loads under the offscreen platform

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@vpetersson
vpetersson requested a review from a team as a code owner June 2, 2026 14:56
@vpetersson vpetersson self-assigned this Jun 2, 2026
@vpetersson
vpetersson requested a review from Copilot June 2, 2026 14:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves Qt6 viewer video presentation performance on embedded targets by moving rendering from a raster QGraphicsVideoItem pipeline to a QML VideoOutput scene hosted in QQuickWidget, keeping frames on the GPU via the Qt Quick scene graph and avoiding per-frame QVideoFrame::toImage() readback.

Changes:

  • Reworked VideoView to render via QQuickWidget + QML VideoOutput, including a new videoview.qml scene and .qrc resource wiring.
  • Extended playback-stats.log instrumentation to log frames-rendered (scene-graph renders) alongside frames-delivered (sink deliveries).
  • Updated build/runtime dependencies and C++ unit tests to cover QML scene loading and VideoOutput sink wiring.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/image_builder/utils.py Adds Qt6 runtime deps for QML/Quick VideoOutput-based rendering; drops multimediawidgets.
src/anthias_webview/tests/tests.pro Updates test link modules for Quick/QuickWidgets and includes the QML resource.
src/anthias_webview/tests/test_videoview.cpp Updates unit tests to assert QML scene load, sink wiring, and rotation via orientation.
src/anthias_webview/src/view.h Updates comments to reflect the new VideoOutput-based render path.
src/anthias_webview/src/view.cpp Updates comments to reflect the new VideoOutput-based render path.
src/anthias_webview/src/videoview.qrc New resource file embedding videoview.qml.
src/anthias_webview/src/videoview.qml New QML scene containing VideoOutput on a black Rectangle.
src/anthias_webview/src/videoview.h Updates documentation and adds counters/methods for rendered-frame tracking.
src/anthias_webview/src/videoview.cpp Implements QQuickWidget/QML VideoOutput pipeline, sink wiring, and render counter hookup.
src/anthias_webview/AnthiasViewer.pro Links Qt QuickWidgets and includes the new QRC resource for Qt6 builds.
docs/board-enablement.md Updates board documentation for the new rendering substrate and performance rationale.
docker/Dockerfile.viewer.j2 Adds qt6-declarative-dev to the Qt6 builder stage to support QuickWidgets.
bin/test_webview_cpp.sh Runs tests with QT_QUICK_BACKEND=software to allow offscreen QQuickWidget init.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/image_builder/utils.py Outdated
@sonarqubecloud

sonarqubecloud Bot commented Jun 2, 2026

Copy link
Copy Markdown

@vpetersson
vpetersson merged commit 1f438d2 into master Jun 2, 2026
10 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.

vpetersson added a commit that referenced this pull request Jun 2, 2026
- CalVer (YYYY.0M.MICRO); still June 2026, micro 0 -> 1
- Ships the QML VideoOutput presentation path (#2975), the pi2/pi3
  GStreamer HW video pipeline (#2972), and the x86 WLR_DRM_NO_ATOMIC
  display-freeze fix (#2978)
- Also picks up Pi 4 eglfs rotation (#2971, #2973), the armv7 viewer
  spawn retry (#2969), the Writeback-connector headless guard (#2968),
  and viewer log cleanups (#2977, #2979)

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] The Latest v2026.6.0 Release Causes Hardware Decoding to Fail on Raspberry Pi 4 Model B Rev 1.5

2 participants