Skip to content

fix(viewer): respawn the webview on a video-play D-Bus death, not log+stop - #3031

Merged
vpetersson merged 1 commit into
masterfrom
fix/media-player-respawn
Jun 8, 2026
Merged

fix(viewer): respawn the webview on a video-play D-Bus death, not log+stop#3031
vpetersson merged 1 commit into
masterfrom
fix/media-player-respawn

Conversation

@vpetersson

Copy link
Copy Markdown
Contributor

Issues Fixed

Fixes #3027 / Sentry ANTHIAS-1AMPVMediaPlayer.play failed: GDBus.Error NoReply: Message recipient disconnected.

Description

media_player.py's play()/stop() called bus.playVideo/bus.stopVideo directly and, on any exception, logged at ERROR and returned. When the webview died mid-call this is the exact webview-gone NoReply that _send_to_webview (#3012) already self-heals for view_image/view_webpage — but the media-player path was never routed through it, so a transient webview crash during playback (1) fired a Sentry event for a self-healing condition and (2) left video dead until the next asset rotation respawned the webview.

  • Route play/stop through the injected _send_to_webview wrapper: reap + respawn + retry once on a webview-gone D-Bus error
  • Injected via set_send_to_webview() in setup(), right next to the existing set_browser_bus() — keeps the respawn logic (and its global state) in __init__.py and avoids a circular import (__init__ already imports media_player)
  • Non-webview-gone errors still propagate to play/stop's existing log-and-clear-_playing handling; with no wrapper injected (standalone/tests) calls run directly, so prior behaviour is preserved

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).

🤖 Generated with Claude Code

…+stop

- MPVMediaPlayer.play/stop called playVideo/stopVideo directly and, on
  a webview-gone D-Bus error (NoReply — the webview crashed mid-call),
  logged ERROR and gave up: a Sentry event for a self-healing
  condition, and the video stayed dead until the next rotation
  respawned the webview (Sentry ANTHIAS-1A)
- Route both through the same _send_to_webview wrapper the image/page
  paths use (#3012): reap + respawn + retry once on webview death,
  injected via set_send_to_webview() in setup() alongside the bus
- Genuinely unexpected errors still propagate to play/stop's existing
  log+clear-state handling; with no wrapper injected (tests/standalone)
  calls run directly, preserving prior behaviour
- Add tests for the routing, respawn-recovery, re-raise, and the
  no-injection fallback

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

sonarqubecloud Bot commented Jun 7, 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

This PR updates the viewer’s media playback path (MPVMediaPlayer.play() / stop()) to use the same “webview-gone” D-Bus self-healing wrapper already used by the image/webpage viewing paths, so transient webview crashes during video playback respawn the webview and retry once instead of logging an ERROR and leaving playback broken until the next rotation.

Changes:

  • Inject anthias_viewer.__init__._send_to_webview into anthias_viewer.media_player during setup() to share the respawn+retry-once behavior for webview-gone D-Bus errors.
  • Route MPVMediaPlayer.play() / stop() D-Bus calls through an optional _call_webview() wrapper (direct call fallback when not injected).
  • Add unit tests asserting wrapper routing, successful retry behavior, failure propagation handling, and the no-injection fallback behavior.

Reviewed changes

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

File Description
tests/test_media_player.py Adds tests covering that play()/stop() route through the injected wrapper and preserve fallback behavior without injection.
src/anthias_viewer/media_player.py Introduces injectable _send_to_webview support and routes playVideo/stopVideo through _call_webview().
src/anthias_viewer/__init__.py Injects _send_to_webview into the media player module during viewer setup() to enable respawn+retry for video calls.

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

@vpetersson
vpetersson merged commit 056f539 into master Jun 8, 2026
10 checks passed
@vpetersson vpetersson mentioned this pull request Jun 9, 2026
5 tasks
vpetersson added a commit that referenced this pull request Jun 9, 2026
- CalVer (YYYY.0M.MICRO); still June 2026, micro 2 -> 3
- Gives Sentry a real release boundary: every build since 2026.6.2
  reported the same base version (only the +git-hash differed), so
  resolved-in-next-release never stuck and fixed issues kept
  reopening on the next event. A version bump lets the deployed
  fixes actually clear from the board.
- Ships the crash/noise fixes merged since 2026.6.2: SQLite WAL +
  busy timeout (#3015), celery migration-gate (#3016) and
  asset-probe soft limits (#3017), transient-redis/CancelledError
  Sentry filtering + redis healthcheck (#3018/#3028), GitHub
  update-check log level (#3019), webview respawn on D-Bus death at
  setup and mid-play (#3020/#3031), resilient static-file scan
  (#3026), Wayland-socket wait (#3030), and Sentry release/board
  triage tags (#3021/#3025)

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.

MPVMediaPlayer.play/stop should respawn on webview death, not log at ERROR (Sentry ANTHIAS-1A)

2 participants