GRI-1854: playback from the cache, offline — grimoirix-signage-client #89

Merged
vivy merged 2 commits from feature/GRI-1854-offline-playback into dev 2026-11-09 20:40:25 +00:00
Member

Signage #21 (GRI-1854): the client plays from its cache, full screen, with or without a server.

Stacked on #86, which is stacked on #84. Merge in the order #84 → #86 → this PR. This diff then shrinks to the six files in the last commit.

What is added

  • player.rs (pure, 8 tests): the merged cursor plus the cache gives the next Step.
    • A web page plays at once.
    • An image or PDF page plays once its verified file is in the cache, and is skipped until then. A video works the same way.
    • If items are due but none can be shown, the result is CannotLoad. If nothing is valid, it is NothingScheduled. These are kept apart, as offline-first.md asks.
    • Only http and https URLs reach the web view, so file:// and javascript: are refused (tested).
    • The same playlist arriving again (because a file arrived) keeps the current place. A changed playlist restarts from the top.
  • playback.rs: Cursor::resume and Cursor::position, so the player can own the playlist. Nothing in the existing behaviour changes.
  • renderer/image.rs: show_fitted, which scales to the window and keeps the aspect ratio. A PDF page arrives at the server's render size, not the screen's.
  • grimoirix-signage-client, a new binary behind gtk-renderer:
    • the sync runs on its own thread with a current-thread tokio runtime;
    • GTK runs on the main thread;
    • two watch channels connect them: the playlist goes one way, the item on screen goes back as the heartbeat's playing_item;
    • the playlist is checked every second, so a panel change shows within about 1 s;
    • after a render error it waits 1 s, so it cannot spin;
    • on fallback it retries every 5 s;
    • it goes full screen unless GRIMOIRIX_RENDERER_WINDOWED is set, the same variable as #81.

#21 "done when" (pull the network cable: the playlist keeps playing), run on this host under Xvfb at 1280×720. The server address pointed at a closed port, and the data dir held a stored identity and playlist:

  • A 1600×900 "PDF page" from the cache was shown scaled to fill the screen. Then a web page. Then the page again. An image item whose file was missing was skipped. The sync kept retrying with backoff the whole time.
  • A video-only playlist played the cached mp4.
  • I looked at the screenshots, windowed and in full screen.

One bug the live run caught, and this PR fixes it: a tokio::watch receiver counts its first value as already seen. So the playlist loaded from disk never reached the player, and an offline start showed a blank fallback. The player is now seeded from the receiver at start-up.

For packaging (#81, Forgemother): the .deb should install this binary as /usr/bin/grimoirix-signage-client, not renderer_spike. Build it with cargo build --release -p client --features gtk-renderer --bin grimoirix-signage-client. It reads /etc/grimoirix-signage/client.toml (server = "https://…") or GRIMOIRIX_SIGNAGE_SERVER.

Known limits, for later:

  • A video plays for the item's duration (default from the playlist), not for its own length.
  • An offline web page shows WebKit's own error page.
  • There is no cursor hiding and no screen blanking control yet.

Tests: 8 new unit tests in player. ./scripts/local-gates.sh --rust-only passes. cargo clippy -p client --features gtk-renderer --all-targets -D warnings is clean; CI does not build that feature.

Signage #21 (GRI-1854): the client plays from its cache, full screen, with or without a server. **Stacked on #86, which is stacked on #84.** Merge in the order #84 → #86 → this PR. This diff then shrinks to the six files in the last commit. **What is added** - `player.rs` (pure, 8 tests): the merged cursor plus the cache gives the next `Step`. - A **web page** plays at once. - An **image or PDF page** plays once its verified file is in the cache, and is skipped until then. A **video** works the same way. - If items are due but none can be shown, the result is `CannotLoad`. If nothing is valid, it is `NothingScheduled`. These are kept apart, as `offline-first.md` asks. - Only `http` and `https` URLs reach the web view, so `file://` and `javascript:` are refused (tested). - The same playlist arriving again (because a file arrived) keeps the current place. A changed playlist restarts from the top. - `playback.rs`: `Cursor::resume` and `Cursor::position`, so the player can own the playlist. Nothing in the existing behaviour changes. - `renderer/image.rs`: `show_fitted`, which scales to the window and keeps the aspect ratio. A PDF page arrives at the server's render size, not the screen's. - **`grimoirix-signage-client`**, a new binary behind `gtk-renderer`: - the sync runs on its own thread with a current-thread tokio runtime; - GTK runs on the main thread; - two `watch` channels connect them: the playlist goes one way, the item on screen goes back as the heartbeat's `playing_item`; - the playlist is checked every second, so a panel change shows within about 1 s; - after a render error it waits 1 s, so it cannot spin; - on fallback it retries every 5 s; - it goes full screen unless `GRIMOIRIX_RENDERER_WINDOWED` is set, the same variable as #81. **#21 "done when" (pull the network cable: the playlist keeps playing)**, run on this host under Xvfb at 1280×720. The server address pointed at a closed port, and the data dir held a stored identity and playlist: - A 1600×900 "PDF page" from the cache was shown scaled to fill the screen. Then a web page. Then the page again. An image item whose file was missing was skipped. The sync kept retrying with backoff the whole time. - A video-only playlist played the cached mp4. - I looked at the screenshots, windowed and in full screen. **One bug the live run caught, and this PR fixes it:** a `tokio::watch` receiver counts its first value as already seen. So the playlist loaded from disk never reached the player, and an offline start showed a blank fallback. The player is now seeded from the receiver at start-up. **For packaging (#81, Forgemother):** the `.deb` should install **this** binary as `/usr/bin/grimoirix-signage-client`, not `renderer_spike`. Build it with `cargo build --release -p client --features gtk-renderer --bin grimoirix-signage-client`. It reads `/etc/grimoirix-signage/client.toml` (`server = "https://…"`) or `GRIMOIRIX_SIGNAGE_SERVER`. **Known limits, for later:** - A video plays for the item's duration (default from the playlist), not for its own length. - An offline web page shows WebKit's own error page. - There is no cursor hiding and no screen blanking control yet. **Tests:** 8 new unit tests in `player`. `./scripts/local-gates.sh --rust-only` passes. `cargo clippy -p client --features gtk-renderer --all-targets -D warnings` is clean; CI does not build that feature.
GRI-1854: protocol envelope, registration and media transfer frames
Some checks failed
CI / the pre-push hook (pull_request) Successful in 4s
CI / cargo fmt (pull_request) Successful in 4s
CI / cargo deny (pull_request) Successful in 40s
CI / cargo deny advisories (pull_request) Failing after 41s
CI / repository boundary (pull_request) Successful in 5s
CI / cargo clippy (pull_request) Successful in 9m33s
CI / cargo test (pull_request) Successful in 9m37s
CI / frontend-web (pull_request) Successful in 9m51s
CI / CI (pull_request) Successful in 4s
CI / Notify gate failed (pull_request) Has been skipped
b5484cb073
ServerMessage/ServerControl/ClientMessage tag every frame after the
handshake, so PlaylistPush and MediaManifest can be told apart. Adds the
Registration report, the transfer offer/accept/complete messages, the
12-byte binary chunk header, the device WebSocket path and the heartbeat
interval. protocol.md describes the session in order.
GRI-1854: client sync over wss — enrolment, playlist, media cache, reconnect
Some checks failed
CI / the pre-push hook (pull_request) Has been cancelled
CI / cargo fmt (pull_request) Has been cancelled
CI / cargo clippy (pull_request) Has been cancelled
CI / cargo test (pull_request) Has been cancelled
CI / cargo deny (pull_request) Has been cancelled
CI / cargo deny advisories (pull_request) Has been cancelled
CI / frontend-web (pull_request) Has been cancelled
CI / repository boundary (pull_request) Has been cancelled
CI / CI (pull_request) Has been cancelled
CI / Notify gate failed (pull_request) Has been cancelled
a6bb13bf04
state.rs keeps the identity and the last playlist in state.json, written
by rename. cache.rs stores media by sha256, resumes from <sha>.part and
only renames a file into place once its hash is checked; a name that is
not a sha256 never becomes a path. session.rs is the protocol for one
connection with no network in it. sync.rs is the wss loop: hello
timeout, heartbeat and ping, dead-connection detection, backoff with
jitter, and a watch channel that playback reads, filled from disk before
the first connect. config.rs reads the server from the environment or
/etc/grimoirix-signage/client.toml. The integration test runs a fake
server, restarts it on the same port, and checks the client comes back
with its identity and picks up the changed playlist.
GRI-1854: state.json is readable by its owner only (it holds the token)
Some checks failed
CI / the pre-push hook (pull_request) Successful in 10s
CI / cargo fmt (pull_request) Successful in 7s
CI / cargo clippy (pull_request) Successful in 9m40s
CI / cargo deny (pull_request) Successful in 44s
CI / cargo deny advisories (pull_request) Failing after 38s
CI / cargo test (pull_request) Successful in 9m41s
CI / repository boundary (pull_request) Successful in 4s
CI / frontend-web (pull_request) Successful in 9m37s
CI / CI (pull_request) Has been cancelled
CI / Notify gate failed (pull_request) Has been cancelled
52110c7f35
GRI-1854: playback from the cache, offline — grimoirix-signage-client
Some checks failed
CI / the pre-push hook (pull_request) Successful in 9s
CI / cargo fmt (pull_request) Successful in 6s
CI / cargo deny (pull_request) Successful in 49s
CI / cargo deny advisories (pull_request) Failing after 43s
CI / repository boundary (pull_request) Successful in 6s
CI / cargo clippy (pull_request) Successful in 9m46s
CI / cargo test (pull_request) Successful in 9m48s
CI / frontend-web (pull_request) Successful in 9m38s
CI / CI (pull_request) Has been cancelled
CI / Notify gate failed (pull_request) Has been cancelled
8f7a43943d
player.rs turns the cursor plus the cache into the next step: a web
page plays at once, an image, PDF page or video plays once its verified
file is on disk and is skipped until then. Nothing playable is
CannotLoad, nothing valid is NothingScheduled. Only http(s) URLs reach
the web view. The grimoirix-signage-client binary runs the sync on its
own thread and the GTK window on the main thread, joined by two watch
channels. The playlist from disk is played before any connection.
Images are scaled to the window, so a PDF page fills the screen.
Merge remote-tracking branch 'origin/dev' into feature/GRI-1854-client-sync
Some checks failed
CI / the pre-push hook (pull_request) Successful in 6s
CI / cargo fmt (pull_request) Successful in 5s
CI / cargo deny (pull_request) Successful in 42s
CI / cargo deny advisories (pull_request) Failing after 44s
CI / repository boundary (pull_request) Successful in 5s
CI / cargo clippy (pull_request) Successful in 9m39s
CI / cargo test (pull_request) Successful in 9m49s
CI / frontend-web (pull_request) Successful in 9m37s
CI / CI (pull_request) Successful in 4s
CI / Notify gate failed (pull_request) Has been skipped
3cc319998f
# Conflicts:
#	Cargo.lock
Merge branch 'feature/GRI-1854-client-sync' into feature/GRI-1854-offline-playback
Some checks failed
CI / the pre-push hook (pull_request) Successful in 4s
CI / cargo fmt (pull_request) Successful in 4s
CI / cargo deny (pull_request) Successful in 42s
CI / cargo deny advisories (pull_request) Failing after 43s
CI / repository boundary (pull_request) Successful in 5s
CI / cargo clippy (pull_request) Successful in 9m42s
CI / cargo test (pull_request) Successful in 9m49s
CI / frontend-web (pull_request) Successful in 9m42s
CI / CI (pull_request) Successful in 6s
CI / Notify gate failed (pull_request) Has been skipped
68ebd4311a
vivy merged commit 2a5ab13b62 into dev 2026-11-09 20:40:25 +00:00
vivy deleted branch feature/GRI-1854-offline-playback 2026-11-09 20:40:25 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grimoirix/grimoire-of-digital-signage!89
No description provided.