Skip to content

fix(viewer): rotate Pi 4 (eglfs) display via QT_QPA_EGLFS_ROTATION - #2971

Merged
vpetersson merged 1 commit into
masterfrom
fix/pi4-eglfs-screen-rotation
Jun 2, 2026
Merged

fix(viewer): rotate Pi 4 (eglfs) display via QT_QPA_EGLFS_ROTATION#2971
vpetersson merged 1 commit into
masterfrom
fix/pi4-eglfs-screen-rotation

Conversation

@vpetersson

Copy link
Copy Markdown
Contributor

Issues Fixed

Forum #6699 — "Anthias 2026.06.0 screen rotation menu doesn't work" on Raspberry Pi 4.

Description

The 2026.06.0 screen-rotation dropdown is a no-op on Pi 4. The rotation feature appends the linuxfb :rotation=N plugin option to QT_QPA_PLATFORM, but Pi 4 moved to eglfs (for HW video), and eglfs silently ignores that option. Only video rotated (via the per-item video-rotate hack); webpages and images — i.e. most signage — never did.

QT_QPA_EGLFS_ROTATION is the right primitive: AnthiasViewer is a QWidget app, so eglfs's QOpenGLCompositor applies the transform to every top-level window (web, image, video) uniformly.

  • _build_webview_env: set QT_QPA_EGLFS_ROTATION=<deg> on the eglfs board and leave QT_QPA_PLATFORM bare. linuxfb (Pi 2/3) :rotation=N and x86 wlr-randr paths unchanged.
  • Drop the video-rotate option on pi4-64 — the whole eglfs screen now rotates and the QGraphicsVideoItem inherits it, so per-item rotation would double-rotate. C++ parse kept as a defensive no-op.
  • Tests updated to assert the eglfs env and that video-rotate is no longer emitted.

Pure Python + env change — no C++/image rebuild required.

Validated on a Pi 4 testbed through the real v2/device_settings API (probe page reporting window.innerWidth/Height via the server access log):

screen_rotation Env produced Webview layout
90° eglfs + QT_QPA_EGLFS_ROTATION=90 1080×1920 (portrait)
eglfs (no rotation var) 1920×1080 (landscape)

Known follow-ups (out of scope here):

  • A rotation change crashes the viewer mid-transition (stale browser_bus D-Bus proxy after the existing bounce terminates AnthiasViewer → GDBus NoReply), recovered by restart: always. End state is correct; this is pre-existing bounce machinery, unchanged here.
  • _is_wayland_board() only treats x86 as Wayland, but Pi 5 / arm64 also run cage/wayland — their rotation is likely broken the same way (wlr-randr never invoked).

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. (x86 Wayland path unchanged by this PR.)
  • I added a documentation for the changes I have made (when necessary).

🤖 Generated with Claude Code

The 2026.06.0 screen-rotation menu was a no-op on Pi 4: #2882 appended
the linuxfb `:rotation=N` plugin option to QT_QPA_PLATFORM, but Pi 4
moved to eglfs (#2904) which silently ignores it. Only video rotated
(via the per-item video-rotate hack); webpages and images never did.

- `_build_webview_env`: set `QT_QPA_EGLFS_ROTATION` on the eglfs board
  and leave QT_QPA_PLATFORM bare; keep the linuxfb `:rotation=N` path
  for pi2/pi3 and the wlr-randr path for x86
- drop the `video-rotate` option on pi4-64 — the whole eglfs screen now
  rotates and the QGraphicsVideoItem inherits it, so per-item rotation
  would double-rotate; C++ parse kept as a defensive no-op
- update tests to assert the eglfs env and that video-rotate is no
  longer emitted

Validated on the Pi 4 testbed: 90° -> webview lays out 1080x1920,
0° -> 1920x1080, toggled through the v2 device_settings API.

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 05:16
@vpetersson vpetersson self-assigned this Jun 2, 2026
@vpetersson
vpetersson requested a review from Copilot June 2, 2026 05:16
@sonarqubecloud

sonarqubecloud Bot commented Jun 2, 2026

Copy link
Copy Markdown

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

Fixes the screen rotation feature on Raspberry Pi 4 (which uses the eglfs Qt platform plugin), where the previously-applied linuxfb:rotation=N option was silently ignored. The viewer now sets QT_QPA_EGLFS_ROTATION for eglfs boards so that webpages, images, and videos rotate uniformly through QOpenGLCompositor, and removes the now-redundant per-video video-rotate D-Bus option that would otherwise double-rotate frames.

Changes:

  • In _build_webview_env, branch on the QPA plugin: set QT_QPA_EGLFS_ROTATION for eglfs (clearing any stale value at 0°), keep the existing :rotation=N path for linuxfb, and leave Wayland untouched.
  • Stop emitting video-rotate from _build_video_options on all boards; keep the C++ parser as a defensive no-op for backward compatibility.
  • Update tests to assert eglfs env behavior and that video-rotate is never sent (including at 0°).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/anthias_viewer/init.py Adds the eglfs branch in _build_webview_env that sets/clears QT_QPA_EGLFS_ROTATION.
src/anthias_viewer/media_player.py Removes video-rotate emission and explains why every backend now relies on screen-level rotation.
src/anthias_webview/src/videoview.cpp Updates comment to reflect that no current board sends video-rotate; parse retained as a defensive no-op.
tests/test_viewer.py Adds eglfs-rotation env tests covering set, omit-at-zero, and clear-stale-on-zero paths.
tests/test_media_player.py Replaces "video-rotate emitted on Pi 4" tests with assertions that it is never emitted (including 0°).

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

@vpetersson
vpetersson merged commit a220f7d into master Jun 2, 2026
10 checks passed
vpetersson added a commit that referenced this pull request Jun 2, 2026
…'t stretched (#2973)

QT_QPA_EGLFS_ROTATION only accepts 180, 90 and -90. A literal 270 hits
the "Invalid rotation" default branch in QEglFSScreen::geometry(): the
QOpenGLCompositor still rotates the content, but the screen geometry
never swaps to portrait, so the window lays out landscape and renders
stretched (issue #2970 follow-up to #2971).

- map 270 -> -90 in _build_webview_env (same orientation mod 360)
- extend the eglfs rotation test to assert the -90 spelling

Validated on the Pi 4 testbed: at 270° the webview viewport went from
1920x1080 (stretched) to 1080x1920 with the fix.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
@vpetersson vpetersson mentioned this pull request Jun 2, 2026
5 tasks
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.

2 participants