Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d9ef9c6f8 | ||
|
|
e042d1f1ee | ||
|
|
2bb88b211b | ||
|
|
27694243f2 | ||
|
|
e6c00ec4b8 | ||
|
|
2480d203ec | ||
|
|
c4983b6e18 | ||
|
|
13736d2524 | ||
|
|
a069c79c73 | ||
|
|
9ee9355348 | ||
|
|
0a2dbc3140 | ||
|
|
f7108c0ca4 | ||
|
|
21d72e51ef | ||
|
|
222633e462 | ||
|
|
f64c93b338 | ||
|
|
429899d6fc | ||
|
|
f1486609ab | ||
|
|
e35170d4f9 | ||
|
|
80a5c0b6d6 | ||
|
|
63f0125954 | ||
|
|
5e7c07c98e | ||
|
|
00d2b3bf6b | ||
|
|
02c697c2f0 | ||
|
|
511051952c | ||
|
|
114b7cb4d6 | ||
|
|
a4d3ce5e00 | ||
|
|
b3095b110a | ||
|
|
dce2362cbb | ||
|
|
fb284b6fc4 | ||
|
|
c0df52b981 | ||
|
|
6782ace43d | ||
|
|
71447c932f | ||
|
|
a1b0a3f350 | ||
|
|
df864e9fed | ||
|
|
45bcc76436 | ||
|
|
6595a31048 | ||
|
|
1a6c3321a1 | ||
|
|
b21ef9ece6 | ||
|
|
9b3c3b330a | ||
|
|
46d8c5c379 | ||
|
|
f4bcb658e1 | ||
|
|
76542b53e5 | ||
|
|
088dac8fb6 | ||
|
|
4a511ca6e3 | ||
|
|
35da9c569a | ||
|
|
dec7b2a9ec | ||
|
|
ba1ed72a55 | ||
|
|
e4f70144e9 | ||
|
|
020334b37b | ||
|
|
24a98ab263 | ||
|
|
ba2ddef525 | ||
|
|
58563b99a5 | ||
|
|
9013a7d13c | ||
|
|
f36a17b46a | ||
|
|
7335ff2ce5 | ||
|
|
21c039f9b3 | ||
|
|
b20591540b | ||
|
|
f3dee5425e | ||
|
|
676b025c5b | ||
|
|
fac72d17c8 | ||
|
|
a2fa6021f5 | ||
|
|
c492e662cb | ||
|
|
ce803340b0 | ||
|
|
3e8a480ea6 | ||
|
|
4be34d20ca | ||
|
|
ea2cd893b4 | ||
|
|
a90a8c27dc | ||
|
|
9d0d72c40a | ||
|
|
56d2ac117f | ||
|
|
cb8202d891 | ||
|
|
029b0674d1 | ||
|
|
c852473a43 | ||
|
|
a4e8e20fcd | ||
|
|
fc1bee2673 | ||
|
|
acf1ef1da2 | ||
|
|
5fe120e897 | ||
|
|
41624c8dbd | ||
|
|
e8ec39db86 | ||
|
|
936d4b188b | ||
|
|
e9ab1489cc | ||
|
|
1043eb1d1b | ||
|
|
0f444da595 | ||
|
|
fda644d036 | ||
|
|
fa0fbbd29a | ||
|
|
ad8847509b | ||
|
|
627c05bf98 | ||
|
|
b82b714165 | ||
|
|
3446999109 | ||
|
|
0bfdfbd0e8 | ||
|
|
19addc1570 | ||
|
|
1f35c77a69 | ||
|
|
5973b6c85c | ||
|
|
d74dc1aa61 | ||
|
|
7b14207f81 | ||
|
|
d6f87f79a6 | ||
|
|
24a1ef9f1d | ||
|
|
ae4904c7d9 | ||
|
|
b142f7c0ac | ||
|
|
934f356927 | ||
|
|
a61764960d | ||
|
|
55a376cdfd | ||
|
|
da7655ee25 | ||
|
|
0ae754fa5d | ||
|
|
ecfd2408cf | ||
|
|
44dfd43692 | ||
|
|
29876ec046 | ||
|
|
3667f504ec | ||
|
|
375b976dcd | ||
|
|
2a74e5ff64 | ||
|
|
0c623c2efc | ||
|
|
d49b3ae884 | ||
|
|
f811261507 | ||
|
|
ec701e6e56 | ||
|
|
360dc105e1 | ||
|
|
892c7c13bd | ||
|
|
3b6128a1b0 | ||
|
|
4c42a528bd | ||
|
|
0e7c5264a0 | ||
|
|
69a4fa6fa7 | ||
|
|
e6b9808beb | ||
|
|
b34330dc85 | ||
|
|
ae69fe3831 | ||
|
|
6d2dc95cc8 |
No files matched your search
@@ -159,6 +159,12 @@ jobs:
|
||||
merge-multiple: true
|
||||
- name: Wheel (CLI install via uv tool / pipx / pip, and its self-update)
|
||||
run: uv build --wheel -o out && ls out
|
||||
- name: Videos (docs/media, rendered by the showcase workflow; frameport-<name>.mp4 → FramePort-<name>.mp4)
|
||||
run: |
|
||||
for f in docs/media/frameport-*.mp4; do
|
||||
[ -f "$f" ] || continue
|
||||
n=$(basename "$f" .mp4); cp "$f" "out/FramePort-${n#frameport-}.mp4"
|
||||
done
|
||||
- name: Checksums
|
||||
run: cd out && sha256sum * > SHA256SUMS.txt && cat SHA256SUMS.txt
|
||||
- name: Publish release
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
name: showcase
|
||||
# Docs screenshots and the videos (the demo tour, the install tutorial, …), rendered from the demo library
|
||||
# (docs/showcase/, scripts/showcase/; see docs/SHOWCASE.md). Opens or updates one pull request (branch
|
||||
# showcase/update) when a picture really changed; the renders are also kept as a workflow artifact either way.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
videos:
|
||||
description: "Videos to record too: names from docs/showcase/videos (e.g. tour install), all, or empty"
|
||||
type: string
|
||||
default: ""
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "src/frameport/ui/**"
|
||||
- "src/frameport/locales/**"
|
||||
- "docs/showcase/**"
|
||||
- "scripts/showcase/**"
|
||||
|
||||
concurrency:
|
||||
group: showcase-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
render:
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 60
|
||||
env:
|
||||
PYTHONUTF8: "1"
|
||||
PYTHONIOENCODING: utf-8
|
||||
TZ: UTC
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0 # the push's changed files decide whether the video is recorded again
|
||||
- uses: astral-sh/setup-uv@v10.2.0
|
||||
- name: ffmpeg and fonts
|
||||
run: sudo apt-get update && sudo apt-get install -y ffmpeg fonts-roboto fonts-noto-color-emoji
|
||||
- run: uv sync --extra dev --python 3.12 # the Python the renders are made with locally
|
||||
- name: Chromium for Playwright
|
||||
run: uv run playwright install --with-deps chromium
|
||||
- name: Store art cache (fetched once from the stores the app uses)
|
||||
uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: ~/.cache/frameport-showcase
|
||||
key: showcase-art-${{ hashFiles('docs/showcase/demo-library.yaml') }}
|
||||
restore-keys: showcase-art-
|
||||
|
||||
- name: Docs screenshots
|
||||
run: uv run python scripts/showcase/render_docs.py --keep showcase-out/screenshots
|
||||
|
||||
- name: Videos
|
||||
# a push records the videos whose storyboard (docs/showcase/videos/<name>.yaml) changed, or all of them when
|
||||
# the recorder changed (UI tweaks alone don't re-record ~10 MB files); Run workflow records what it's asked
|
||||
env:
|
||||
INPUT_VIDEOS: ${{ inputs.videos }}
|
||||
BEFORE: ${{ github.event.before }}
|
||||
run: |
|
||||
if [ "$GITHUB_EVENT_NAME" = workflow_dispatch ]; then
|
||||
read -ra names <<< "$INPUT_VIDEOS"
|
||||
if [ ${#names[@]} -eq 0 ]; then echo "no videos asked for"; exit 0; fi
|
||||
[ "${names[0]}" = all ] && names=()
|
||||
uv run python scripts/showcase/record_video.py "${names[@]}" --work showcase-out/videos
|
||||
else
|
||||
uv run python scripts/showcase/record_video.py --changed-since "$BEFORE" --work showcase-out/videos
|
||||
fi
|
||||
|
||||
- name: Keep the renders
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: showcase
|
||||
path: |
|
||||
showcase-out/screenshots
|
||||
showcase-out/videos/*/video.json
|
||||
docs/media
|
||||
docs/images/tour-teaser.webp
|
||||
if-no-files-found: ignore
|
||||
retention-days: 14
|
||||
|
||||
- name: What changed
|
||||
id: diff
|
||||
run: |
|
||||
git status --short -- docs/images docs/media
|
||||
if [ -n "$(git status --porcelain -- docs/images docs/media)" ]; then
|
||||
echo "changed=true" >> "$GITHUB_OUTPUT"; fi
|
||||
- name: Pull request
|
||||
if: steps.diff.outputs.changed == 'true' && github.ref == 'refs/heads/main'
|
||||
uses: peter-evans/create-pull-request@v8.1.1
|
||||
with:
|
||||
branch: showcase/update
|
||||
delete-branch: true
|
||||
add-paths: |
|
||||
docs/images/*
|
||||
docs/media/*
|
||||
commit-message: "Docs: update screenshots and videos"
|
||||
title: "Update docs screenshots and videos"
|
||||
body: |
|
||||
Rendered by the `showcase` workflow from the demo library (docs/showcase/demo-library.yaml) with a
|
||||
pretend Frame: only pictures that visibly changed are included. Look them over before merging (the
|
||||
run's `showcase` artifact has every render).
|
||||
|
||||
Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
@@ -10,8 +10,20 @@ Read `docs/PLAYBOOK.md` (symptom → fix) before debugging a game, and `docs/FRA
|
||||
## Layout
|
||||
- `src/frameport/` — Python package. `pipeline.py` is the API the CLI (`cli.py`) and GUI (`ui/`, Flet 1.0) share.
|
||||
- `ui/` — `app.py` shell (sidebar with Frame connection + activity cards, routing, actions, 30 s connection poll),
|
||||
`theme.py` (dark design tokens; change colours/spacing only there), `components.py` (pill, card, callout,
|
||||
status_row, art_fill, confirm, `update()` = safe update: in Flet 1.0 reading `.page` of an unmounted control
|
||||
`theme.py` (design tokens; change colours/spacing only there. Dark-only colour themes (owner: no light mode):
|
||||
built-ins `portal` (default), `portal_oled` (true black) and `original` (the old violet; alias `classic`). Portal =
|
||||
the logo's dichotomy: orange ACCENT = main action + selection, blue SECONDARY = secondary (outlined) buttons,
|
||||
progress, switch tracks, PC; `dual` themes add the blue→orange sidebar edge, two-colour wordmark (`C.wordmark`) and
|
||||
selected-tab fade (`C.portal_gradient`). Installable theme files `<data>/themes/*.json` (docs/THEMES.md: name,
|
||||
base, dual, any subset of `T.TOKENS`; refused if light/unreadable, `T.ThemeError`), Settings → Appearance: cards
|
||||
switch live via `app.restyle()` (rebuilds the shell, drops cached views; setting `ui.theme`), "Install theme
|
||||
file…", "Copy this theme as a file", bin icon removes. Read tokens as `T.NAME` when building — never as a default argument or module-level constant (they
|
||||
keep the import-time theme; module maps refill through `T.on_change`, `tests/test_theme.py` checks defaults)),
|
||||
`glyphs.py` + `icons/` (the logo `logo.svg`/`logo-solid.svg` = a monitor that comes out of a tilted portal as the
|
||||
Frame, and 24 px line glyphs `fp:frame|port|patch|container|test|pc|sync|live|shot|keys|recipe|link`, copied into
|
||||
the assets dir and shown as tinted `ft.Image`s: pass `G.FRAME` … wherever an icon goes, `C.as_icon` / the button
|
||||
helpers handle both kinds; `src/assets/icon.png` = the bundles' app icon), `components.py` (pill, card, callout,
|
||||
checklist, art_fill, confirm, `update()` = safe update: in Flet 1.0 reading `.page` of an unmounted control
|
||||
raises), `jobs.py` (background FIFO job queue, one at a time, cancel via Reporter; no Flet), `views/`
|
||||
(library: search/filters/tags/sort as pure tested helpers; game: hero + one-click install, patches under
|
||||
"Customize"; frame: device + readiness + installed, or connect wizard; files: the Frame's file manager (persistent
|
||||
@@ -26,15 +38,27 @@ Read `docs/PLAYBOOK.md` (symptom → fix) before debugging a game, and `docs/FRA
|
||||
launch.sh logs `start/end <unix>` to `<anchor>/plays.log` (upgrade_launchers adds it; Proton launchers exec → start
|
||||
only) and shots are matched by time; thumbnails cached in `<data>/screenshots-cache/<frame>/`, shown by asset URL;
|
||||
delete leaves screenshots.vdf alone (Steam rewrites it at exit); game menu → "Screenshots" = `go("screenshots",
|
||||
pkg)`); live view (`views/live.py` + `install/livestream.py`: the Frame's built-in SteamVR "headset view" webcam
|
||||
pkg)`; Copy image (card hover button, right-click, viewer) = `core/clipboard.copy_image` (Windows/WSL: PowerShell
|
||||
bitmap + file via %TEMP%, macOS osascript PNG, Linux wl-copy/xclip; Flet's set_image only in web mode)); live view (`views/live.py` + `install/livestream.py`: the Frame's built-in SteamVR "headset view" webcam
|
||||
(`steamvr-v4l2cam.service` → v4l2loopback "SteamVR" /dev/video99, see docs/FRAME_RUNTIME.md) + the default
|
||||
output's pulse monitor (sound) → ffmpeg/x264 + AAC (qualities scale down only; "full" = SteamVR's size) →
|
||||
fragmented MP4 on an SSH exec channel's stdout (the script stops ffmpeg on stdin EOF) → relay on 127.0.0.1 (keeps
|
||||
init + fragments since the last keyframe of the *video* track for late viewers) → player page
|
||||
output's pulse monitor (sound) → `fp_venc` (`native/venc`, own clean-room V4L2 driver of the Frame's iris
|
||||
hardware encoder: RGB24→NV12 box downscale with NEON, H.264 CBR, one frame per slot of an even fraction of the
|
||||
panel rate read from DRM, e.g. 96 Hz → 32 fps; stdin `k` = keyframe, EOF = stop; `--probe` / `--selftest`;
|
||||
artifact `linux-arm64-bin/`, synced to `~/.local/share/frameport/bin` by sha256 at stream start, no agent change)
|
||||
piped into ffmpeg (`-c:v copy` + AAC), else the old ffmpeg/x264 30 fps path (qualities scale down only; "full" =
|
||||
SteamVR's size; stderr `live: encoder=… fps=…` → status line) →
|
||||
fragmented MP4 on an SSH exec channel's stdout (stdin EOF stops it) → relay on 127.0.0.1 (a new viewer asks
|
||||
the hardware encoder for a keyframe and waits for it, else gets init + fragments since the last keyframe of the
|
||||
*video* track) → player page
|
||||
`install/live_player.py` (MSE; starts muted as browsers require, "Sound on" button; 0.3 s cushion, catches up at
|
||||
1.1x, seeks only when >2 s behind: seeking to the very edge starved it) opened
|
||||
in the user's default browser: Flet can't show video outside `flet build` bundles; the stream outlives the tab and
|
||||
stops on disconnect/window close); settings; welcome; activity panel). Files, Screenshots and the Library share right-click menus
|
||||
stops on disconnect/window close); monitor (`views/monitor.py` + `frame/monitor.py` + agent v62 `_monitor`: one
|
||||
JSON sample per tick over an SSH exec channel while the tab is shown (stopped in go/disconnect/on_close, the
|
||||
agent ends at EOF); sources and costs in docs/FRAME_RUNTIME.md "Monitoring sources"; game card (fps from
|
||||
FrameBridge pacing; End game = Steam's Exit game, then cmd_stop), tiles with `C.Sparkline` (Flet canvas, no charts
|
||||
extension), details, a pooled process table (Game / Steam & SteamVR / All; right-click: end / force kill / end
|
||||
game; MON_CRITICAL needs force, MON_NEVER is refused)); settings; welcome; activity panel). Files, Screenshots and the Library share right-click menus
|
||||
(one `ft.ContextMenu` per view, filled on right-click; on one of several selected items they act on the whole
|
||||
selection, `C.menu_targets`) and click-and-drag multi-select (`C.DragSelect`: pan start/end on the area + item
|
||||
hover events, which Flutter also sends with the button held; Flet can't report item positions, so no rubber band).
|
||||
@@ -42,7 +66,36 @@ Read `docs/PLAYBOOK.md` (symptom → fix) before debugging a game, and `docs/FRA
|
||||
await a FilePicker) must be coroutine functions or go through `page.run_task`: Flet doesn't await a lambda's
|
||||
coroutine (the Files row Download button silently did nothing). `ui_smoke.py --fake-frame --gestures` drives real
|
||||
mouse drags/right-clicks.
|
||||
Live Frame data comes from one app-owned `app.monitor_hub` (`frame/monitor_hub.py`): subscribers name modules +
|
||||
interval, the hub runs one agent `_monitor` stream (union of modules, fastest interval; per-module collection
|
||||
needs agent v65), reconnects after a lost stream and stops it when nobody subscribes; `_poll` retries an "error".
|
||||
Subscribers: "monitor" (the Monitor tab, everything, only while shown) and "card" = the sidebar's live Frame card
|
||||
(`ui/frame_card.py` helpers: battery ring, "now playing" row with fps + 2-min sparkline → click opens Monitor;
|
||||
games + battery every 5 s, paused while a job's stage is "Upload…", only while connected and setting
|
||||
`ui.live_frame_card` (Settings → Appearance, default on) is on; else the battery comes from the 30 s poll).
|
||||
ui_smoke injects `FakeMonitorSession` as the hub's `session_factory`.
|
||||
User tags live in library entries (`tags`), filters in library setting `ui.library`.
|
||||
Easter eggs (`ui/easter.py`, owner's wish; never mentioned in the UI or docs): seven quick clicks on the sidebar
|
||||
logo (the *wordmark's* portal glows + rings, a cover is tossed out of it and falls across the window on a random
|
||||
arc: `toss_path`, `page.overlay` at the computed window position `_wordmark_portal`; the logo's portal in
|
||||
themes without one), the Monitor's fps number has a mood tooltip (above the number, clear of the pointer) and
|
||||
2.5 minutes within 0.5 fps of target (`PERFECT_SECONDS`) make the game card glow and pulse blue/orange for 5 s,
|
||||
the number grow in the portal gradient and the sparkline take it; the "Perfect pacing" pill + line stay until the
|
||||
rate slips (`PerfectPacing.done`, `_show_perfect`, `Sparkline.portal`), holiday badges on the logo that dance on
|
||||
hover and shower the window on click (`HOLIDAY_MOTION`; `SHOWERS`/`shower_plan`: New Year confetti, winter snow,
|
||||
Valentine hearts, Pi digits, clovers, hopping eggs, bouncing pumpkins; `holiday`: Valentine's
|
||||
heart, Pi Day, St Patrick's clover, Easter Sat-Mon egg (computus), April 1 = the logo upside down until hovered,
|
||||
Halloween pumpkin, Dec 31-Jan 1 party popper, else Dec 20-Jan 2 snowflake; on those days the logo's box grows to
|
||||
hold the badge: Flutter only hit-tests inside a control's bounds; `FRAMEPORT_TODAY` pretends a date),
|
||||
Library search "frameport" (logo spins, "That's me!"), Type on Frame "hello" (keys still go to the Frame; a
|
||||
headset peeks up from the window's corner and waves), the battery ring (only the ring, with a glow behind
|
||||
it; not the percentage) empties at once and spins while its bar refills, then pulses, on reaching 100 % plugged (`charged_now`, `ring_pulse`, `ring_glow`), a long upload (>2.5 min, `HOP_AFTER`) makes the transit cover hop, the Live view
|
||||
tab shows a blinking ON AIR sign while streaming
|
||||
(`app.sync_on_air`), install milestones (confetti +
|
||||
message at the 1st/10th/100th *different* game: settings `fun.installed` = game ids, `fun.milestones` = shown;
|
||||
each milestone shows once ever, recorded before it's shown; updates/reinstalls never count; the first use seeds
|
||||
from games already on a Frame and marks passed milestones shown). Setting `ui.easter_eggs` (no UI) turns them
|
||||
off; the showcase demo library has them off (steps hook `easter_eggs` for egg demos). Reduce motion: no animation.
|
||||
**Performance rules** (the app froze before): never put image bytes in controls — artwork is served by URL from the
|
||||
GUI assets dir (= user data dir; `ft.run(assets_dir=…)`), as thumbnails (`artwork/thumbs.py`, Pillow); the
|
||||
library view is persistent, streams cards in batches from a background thread and filters by toggling visibility;
|
||||
@@ -50,16 +103,45 @@ Read `docs/PLAYBOOK.md` (symptom → fix) before debugging a game, and `docs/FRA
|
||||
**Never recreate clickable controls on progress ticks** (sidebar, activity tiles): update their properties —
|
||||
replacing them 5×/s swallowed clicks (couldn't leave the Library during an upload).
|
||||
Labelled switches: `C.switch(label, …)` (Material's default label colour is dark on our dark theme).
|
||||
Cover cards (Library grid + shelf): `library.card_hover`/`hover_motion` (lift, art zoom inside the clipped frame,
|
||||
radial `scrim`, accent-tinted shadow) and `C.CoverButton` (frosted round button, accent under the pointer; Play =
|
||||
blue then orange ring ripple + "Starting on Frame…" pill for STARTING_S; its `.status` layer must sit *below*
|
||||
the button in the Stack, else it takes the clicks); the game page's Play turns into "Starting on …" with a spinner
|
||||
(`GameView._starting`). Reduce motion: no lift/zoom/rings. Filled buttons use a glyph's `-solid` variant
|
||||
(`glyphs.solid`, e.g. `frame-solid.svg`: the outline glyph faded into the orange).
|
||||
Empty states (`C.empty_state(..., features=[(icon, heading, sentence)])`): with features the portal is bigger, a
|
||||
soft portal light (`C.portal_glow`) fills the screen and `C.feature_row` says what the screen will show (the
|
||||
not-connected Files/Screenshots/Live/Type/Monitor tabs and the empty Library); the idle Live view is a framed
|
||||
"screen" with its own Start button + `live_features()`, Type on Frame shows `keyboard_tips()` under the box.
|
||||
Setup checklists (Frame → Ready to play, Settings → Tools / This PC) = `C.checklist([C.Check(ok, title, detail,
|
||||
help, fix=(label, icon, handler), extra=control)])`: ok True/False/"warn"/None (= spinner); the fix button shows
|
||||
inline only while an item isn't ready — wire existing actions only. Motion: `app.body` holds an
|
||||
`ft.AnimatedSwitcher` (`app._show_view`): a new route gets a new wrapper (150 ms fade), a same-route redraw swaps
|
||||
the wrapper's content (no animation; persistent views just remount); the wordmark's portal (`wordmark().data`)
|
||||
pulses once when frame_state turns "connected"; both off with setting `ui.reduce_motion` (Settings → Appearance
|
||||
"Reduce motion", `app.reduce_motion`). Settings has a fixed index column (`settings.SECTIONS` order, Appearance
|
||||
first, Remove FramePort last): entries scroll the section column via `scroll_to(scroll_key=…)` (sections wrapped
|
||||
in Containers with `ft.ScrollKey`), the header stays; `app.settings_view.show_section(key)` (ui_smoke
|
||||
`settings-index`).
|
||||
Help hints: wording for non-obvious terms lives in `ui/help.py` (`HELP`); show it with `C.help_icon(key)` or the
|
||||
`help=` argument of `section`/`status_row`/`kv`, tooltips via `C.tip()` (wraps). Game actions for the Library
|
||||
right-click menu (one `ft.ContextMenu` around the grid, filled on right-click) and the game page's "…" menu come
|
||||
from `app.game_actions()`. Picking art (`sources.apply_choice`) downloads into a staging dir and keeps the old
|
||||
`help=` argument of `section`/`kv` (`C.Check` help key), tooltips via `C.tip()` (wraps). Game actions for the Library
|
||||
right-click menu (one `ft.ContextMenu` around the grid, filled on right-click; short: `menus.quick_menu`, key actions
|
||||
+ "More actions…" = the game page with its full "…" menu opened from code, `app.open_game_menu`) and the game
|
||||
page's "…" menu (`menus.menu_sections` quick=False, sectioned) come from `app.game_actions()`. Picking art (`sources.apply_choice`) downloads into a staging dir and keeps the old
|
||||
art if nothing came back; "Update Steam art on Frame" re-sends the art set to the game's anchor (agent ≥ 12).
|
||||
Patch descriptions/reasons describe the general case, naming games only as "e.g. …".
|
||||
- Installs: queued/cancelled/failed ones are remembered (library setting `ui.installs`) → Library "Resume" bar;
|
||||
uploads are interruptible (Cancel checked per MiB) and resumable (big files via SFTP `.part` append, small files
|
||||
streamed in tar batches; the agent counts files already in `incoming/`). Multi-select in the Library queues
|
||||
installs after asking every needed question up front. Failures end in one pop-up (Resume / Uninstall / log).
|
||||
- Other drives (GitHub #90, agent v63): anchors stay in ~/Applications/quest-frame, a game's files may live in
|
||||
`<mount>/FramePort/<pkg>` (`deployment.json` base). Agent `drives` (/proc/mounts, /run/media + Steam library
|
||||
drives; vfat/exfat/ntfs/read-only refused), prepare*/finalize_linux `dest` (unmounted = error, never a fallback;
|
||||
installed games keep their base), `move` (detached systemd-run + `move_status`; cp -a under podman unshare,
|
||||
count+bytes check, symlink retarget, launch.sh: Quest app_dir line / Linux+PC VR rewritten from the record's
|
||||
`launcher` field, else text swap), list_installed `drive`/`drive_missing` (install_state keeps such games
|
||||
"installed"). PC: `install/drives.py`, library setting `install.drive` (Frame page → Storage), game menu
|
||||
"Move to…" (job kind tool-frame), CLI `frame drives`/`frame move`/`install --dest`. Untested on the device.
|
||||
- **PC VR repacks are pre-patched to run directly** (proven: Rick and Morty, Vader Immortal run when the exe is
|
||||
launched directly; Revive breaks them). So Rift games default to `as_is` = install the copy unchanged and launch
|
||||
the exe directly (`pcvr.xr_timefix` for the Frame OpenXR-1.1→1.0 fix, `pcvr.no_crash_reporter` for Unreal).
|
||||
@@ -111,11 +193,20 @@ Rick and Morty runs on the Frame via its catalog recipe (OpenVR, no Revive),
|
||||
set: the name on a colour from the title hash + the APK icon, `steam_set_for`; 2D Android apps get no store lookups) and tags: how it runs, the original platform
|
||||
(Meta Quest / Oculus Rift), genres, user tags — merged with tags set in Steam (non-Steam shortcuts can't hold a
|
||||
description).
|
||||
- Linux apps (GitHub #31, library kind `linux`, `linux.<slug>`): GUI = Add games → "Add a Linux app (arm64)…" /
|
||||
- Linux apps (GitHub #31, library kind `linux`, `linux.<slug>`; x86_64 builds run through FEX (app 3127680, no SLR:
|
||||
RootFS /usr/share/guestos/fex-mesa from the OS image; needs `STEAM_COMPAT_DATA_PATH`, see docs/FRAME_RUNTIME.md):
|
||||
agent v61 `linux_x86_tools`/`pick_tool`, `install_proton`/`proton_status` `kind: linux_x86`, `finalize_linux
|
||||
x86_64`, `installer.ensure_proton(kind=)`; an arm64 program wins over an x86_64 one): GUI = Add
|
||||
games → "Add a Linux app…" /
|
||||
"…folder…" (`app.add_linux` job → `pipeline.add_linux_app`); game page `linux_summary` (program + Change…, AppImage,
|
||||
OpenXR, source) instead of recipe/patches, `C.missing_libraries` callout (Frame deployment, else last install);
|
||||
no Analyze/Rebuild/recipe/share/Game settings actions, Frame only; platform "Linux" badge + library filter; Steam
|
||||
tags "Linux app on Frame"/"Linux"; `_follow_catalog` skips them; local files of a lone AppImage = the file only.
|
||||
Desktop Mode entries (GitHub #84, agent v63): finalize_linux writes `frameport-<slug>.desktop` to
|
||||
~/.local/share/applications (+ ~/Desktop if it exists; `X-FramePort-Package` marks ours), launch.sh with
|
||||
`FRAMEPORT_DESKTOP=1` skips the Steam-parent watchdog and Steam's display; ensure_host_fixes refreshes entries
|
||||
(older installs, stale ones removed), uninstall/purge remove them. Per app: library entry field `desktop_entry`
|
||||
(default on; patches don't apply to Linux apps) → game page switch → agent `desktop_entry`. Untested on device.
|
||||
- Quest/Rift twins stay separate entries, shown and named in Steam "Title (Quest)"/"(Rift)" (`core/titles.py`).
|
||||
- `Recipe.as_is` = install unchanged (pre-patched libraries): `pipeline.prepare_as_is`; auto for APKs that already
|
||||
contain FrameBridge (`frame_patched`). For Rift it changes nothing (the dump is never modified; the Frame copy
|
||||
@@ -131,6 +222,10 @@ Rick and Morty runs on the Frame via its catalog recipe (OpenVR, no Revive),
|
||||
- `patches/` — **the unit of modularity**. `base.py` (Patch interface, registry), `overport.py` (overport CLI patch ids,
|
||||
discovered dynamically via `overport patches`), `frame/*.py` (one module per Frame fix), `settings.py` (FrameBridge
|
||||
adapter keys + device files as patches). Add a patch = add a module that calls `register(...)`.
|
||||
`upstream.py`: upstream fixes that replace a workaround per build (a probe finds the fix in OVRPort's output →
|
||||
the build leaves the workaround out, `build.superseded`; recipes unchanged). Registered: `ovrport.haptic_envelope`
|
||||
(→ `adapter.haptic_fix`, `frame/haptic_envelope.py`) and `ovrport.microphone_stream` (→ `frame.ovr_microphone`),
|
||||
both fixed in OVRPort runtime 3.4.3-aa54c3f (ovrport/app#73; haptics owner-verified with Lucky's Tale 2026-10-07).
|
||||
- `analysis/` — APK/ELF inspection (`detect.py`), `elf.py` (pyelftools reads; own DT_NEEDED writer), `stubgen.py`
|
||||
(generates the ovr_* stub .so without a compiler).
|
||||
- `apk/` — `axml.py` (binary manifest editor), `workspace.py` (staged zip edits), `sign.py` (apksigner; it aligns too).
|
||||
@@ -165,9 +260,15 @@ Rick and Morty runs on the Frame via its catalog recipe (OpenVR, no Revive),
|
||||
signed, `ready.json`); `apply()` writes + starts detached `apply.ps1`/`apply.sh` (wait for pid → Windows: copy over,
|
||||
replaced files kept in `updates/<ver>/previous` because the zip has no top folder; macOS/Linux: mv to `.old` + swap,
|
||||
rollback, `xattr -dr` quarantine → relaunch; `<data>/logs/update.log`). `ui/updater.py`: background check (10 s,
|
||||
then 6 h), sidebar card (hidden control, toggled), Library bar (`library_bar`), notes dialog (`ft.Markdown`), job
|
||||
then 6 h), sidebar card (hidden control, toggled), Library bar (`library_bar`), changelog dialog, job
|
||||
`app-update` that restarts only when no other job is active, `apply_pending_at_start()` in `main()` for
|
||||
"Install updates automatically"; Settings → Updates. CLI: `--version`, `frameport update [--check (exit 10)]
|
||||
"Install updates automatically"; Settings → Updates. Changelog: `updates.fetch_changelog` (releases list,
|
||||
`app-releases.json`, same 6 h cache, offline → cached / []) → `ChangelogEntry` (`whats_new()` keeps only the tag
|
||||
message's "What's new" part: CI's intro, update hint and release-footer.md stripped); `between`/`changelog_for`
|
||||
(installed < v ≤ offered, dev entry only when on/choosing dev, skipped versions included), `recent_history`;
|
||||
the update/dev dialogs show one collapsible section per version (`_changes_column`, newest open); after an update
|
||||
`pending_news` (setting `update.last_seen_version`; first start only records it; offline → retried next start)
|
||||
→ Library "was updated" bar → "See what's new…"; Settings → Updates "What's new…" = recent history. CLI: `--version`, `frameport update [--check (exit 10)]
|
||||
[--yes]`, once-a-day stderr hint read from the cache only (`refresh_cache()` in a daemon thread writes no
|
||||
settings, to avoid read-modify-write races). `scripts/update_smoke.py <archive>` runs the real extract + swap script
|
||||
(no relaunch) — CI runs it on all three OS with the archive it just built.
|
||||
@@ -201,11 +302,19 @@ Repo is on an NTFS drive (`core.fileMode=false`); line endings are LF (`.gitattr
|
||||
artwork, frames.json, the app's SSH key which the dev Frame authorizes).
|
||||
- Device checks: `frameport test <pkg>` / `frameport parity-device --results <parity.json> --baseline <launch.txt>
|
||||
[--test-only]`; the pre-FramePort baseline is `PATCHED/_known-good-2026-09-28/_frame-state/baseline-launch.txt`.
|
||||
- Docs screenshots (`docs/images/`): `python scripts/scrub_library.py ~/.local/share/frameport <dir> --status works,issues` (copies
|
||||
library + artwork only; titles replace folder names, local paths → `D:/Games/...`, sort by size) then
|
||||
`FRAMEPORT_HOME=<dir> python scripts/ui_smoke.py --out <shots> --docs --fake-frame --game <pkg>` (set
|
||||
FRAMEPORT_JAVA/_OVERPORT_JAR/_APKSIGNER_JAR so no tool download toast appears; `--viewport 1280x2600` + crop for the
|
||||
patch list). Check every PNG for paths, IPs, user names and repack/scene names before committing.
|
||||
- Docs screenshots + videos (docs/SHOWCASE.md): never by hand. `uv run python scripts/showcase/render_docs.py`
|
||||
renders `docs/showcase/shots.yaml` into `docs/images/` (every shot twice, kept when both agree; only visibly changed
|
||||
files are rewritten; `--check` for CI) and `scripts/showcase/record_video.py [names] [--draft]` records the
|
||||
storyboards `docs/showcase/videos/<name>.yaml` (tour = FramePort in use + README teaser; install = the install
|
||||
tutorial: instruction cards for the download / the command on the Frame, the rest filmed from a first start) into
|
||||
`docs/media/frameport-<name>.mp4`. Both build the demo library first (`demo_home.py`, profile `demo` or `fresh`:
|
||||
catalog games from `demo-library.yaml` + `demo-analyses.json`, art/details cached in ~/.cache/frameport-showcase, a
|
||||
pretend Frame from `showcase-frame.json`) in a temp FRAMEPORT_HOME: no personal data, refuses the real data dir
|
||||
and placeholder art; discovery is off and the setup command shows placeholders for the address and code. Steps find elements
|
||||
by name through Flutter's semantics tree (`scripts/showcase/web.py`: text, tooltip; the innermost match wins) —
|
||||
give new icon-only controls a tooltip. The `showcase` workflow renders on UI pushes to main (+ the videos whose
|
||||
storyboard changed, or the ones named on dispatch) and opens PR `showcase/update`; releases attach every video as
|
||||
`FramePort-<name>.mp4`. `scripts/scrub_library.py` (the owner's own library) is only for private screenshots now.
|
||||
README rules (owner): states the project is a proof of concept, provides no piracy tools, credits the wrapped
|
||||
projects (most functionality is theirs); neutral technical wording; no Quest2Frame mentions anywhere.
|
||||
- GUI smoke test: `uv pip install flet-web playwright && playwright install chromium`, then
|
||||
@@ -271,7 +380,10 @@ The Frame runs firewalld (22 and 32000 open). PC side: the setup server needs in
|
||||
firewall blocks it silently (`DefaultInboundAction Block`): `pairing.ensure_reachable` adds a temporary rule via one
|
||||
UAC prompt, removed when the server stops (flag file in %TEMP%, max 35 min); hints per OS after 45 s without a request
|
||||
(`pairing.firewall_hint`). Flet 1.0 patches aren't thread-safe → `app.serialize_flet_updates()` (a dialog shown while a
|
||||
scan redraw ran never closed: "dropped a patch for unknown control").
|
||||
scan redraw ran never closed: "dropped a patch for unknown control"); it also makes property writes (Flet's
|
||||
`Prop.__set__`) take the same `app.FLET_LOCK`: a property set on a background thread while the loop packed a patch
|
||||
changed the control's `_values` mid-iteration ("dictionary changed size during iteration", a sidebar click's page
|
||||
change died while the live Frame card took a sample). Anything that serves the app (ui_smoke, showcase) calls it too.
|
||||
**Lepton:** needs an activity with category **LAUNCHER** (Quest apps often only have INFO → "APP_ACTIVITY is empty").
|
||||
**2D apps:** Lepton runs every app headless (`lepton.headless=true`, only OpenXR output reaches the headset) unless the app folder (`<base>/lepton-app/`) has a `lepton-show-flatscreen` file (liblepton/app_metadata.sh) → Waydroid window on gamescope; agent v28 `set_flatscreen` at finalize for `vr_kind == "none"`. Android 11's navbar covered the
|
||||
app's controls → patch `device.hide_navbar` (default on for vr_kind none, migration `flat_hide_navbar`) exports
|
||||
@@ -505,7 +617,7 @@ recipe keeps it on). I Am Cat works with issues (judder; scale 0.8 no help). Rob
|
||||
libroblox, also with the Vulkan shim). Installs skip the Steam restart when the shortcut is unchanged and wait while a
|
||||
game runs (agent v37). New default fixes in FramePort's code reach games already in a library: after every app update
|
||||
`library._follow_catalog` re-derives each non-user recipe once (setting `recipes.app_version`; tests switch it off via
|
||||
`library.REFRESH_ON_UPDATE`); analysis fields added later still need a re-analysis. Troubleshooting techniques: docs/PLAYBOOK.md "Debugging techniques". Unity `boot.config` "vulkan" substring mislabels GLES games as Vulkan
|
||||
`library.REFRESH_ON_UPDATE`). Analysis fields added later: **bump `analysis/detect.ANALYSIS_VERSION`** (stored as `analysis.extra.analysis_version`); older entries whose APK is still there are analysed again at the GUI's start (background thread, not a job: ~8 s per 900 MB APK) and before a build (`pipeline.refresh_analyses`, GitHub #104); only `analysis`/`suggested` change, user recipes stay; an unreadable APK gets `analysis_failed` = the version (not retried until the next bump). Troubleshooting techniques: docs/PLAYBOOK.md "Debugging techniques". Unity `boot.config` "vulkan" substring mislabels GLES games as Vulkan
|
||||
(I Am Cat ran GLES); OVRPlugin's "Unavailable OpenXR extension: XR_FB_scene" is routine (no longer triaged).
|
||||
**Round 4 (2026-10-04):** XR_KHR_android_surface_swapchain is listed by the Frame's runtime but returns
|
||||
FUNCTION_UNSUPPORTED → adapter `surface_emul` (default on, `native/adapter/surface_swapchain.c`): an ordinary runtime
|
||||
@@ -613,6 +725,40 @@ head-pose deadline ends VR mode without a worn headset (not a game bug).
|
||||
layers, depth, pacing ruled out. Sniper Elite VR (DEVICE LOST), Espire 1 (Mesa GL upload crash), HITMAN 3 (freedreno
|
||||
crash): use PC versions.
|
||||
|
||||
**Install links / FrameDrop button protocol (2026-10-07, not yet clicked end to end from a browser):** FrameDrop
|
||||
(framedropvr.com, a closed-source Windows sideloader) defines "Install with FrameDrop" buttons:
|
||||
`https://framedropvr.com/install?manifest=<url>|url=<file>` → that page opens `framedrop://install?…` (1.6 s, else its
|
||||
home page); manifest `{"schema":"framedrop.install/v1","name","files":[{"url","sha256"}]}` (name = Steam title; .apk
|
||||
or Linux .zip). `deeplink.py` (no Flet) parses framedrop://, frameport:// and the pasted https link, enforces its
|
||||
rules (https; http only on loopback; no credentials; no LAN/loopback/link-local IPs, also after DNS and redirects; URL
|
||||
ends in a file name), caps manifests at 256 KiB, ignores non-hex sha256 (FrameDrop's own example has a placeholder),
|
||||
downloads into `<data>/downloads/<slug>-<hash>/` (OBBs → `obb/` next to the APK, `.part` removed on cancel/mismatch);
|
||||
`pipeline.add_from_link` routes APK / Linux / exe and sets `title` + `title_locked` + `link` (a bare file link keeps
|
||||
FramePort's title). GUI: `views/link_dialog.py` (always asks first), Add games → "Install from a link…", CLI
|
||||
`frameport open-link [--yes --no-install --gui]`. **A `flet build` bundle can't take a URL argument** (the Flutter
|
||||
host treats any argv as a developer page URL), so `urlhandler.py` registers a script, not FramePort.exe: Windows
|
||||
HKCU `Software\Classes\{framedrop,frameport}` → hidden PowerShell `frameport-link-handler.ps1`; WSL (source runs)
|
||||
the same keys → `wsl.exe -d <distro> -e sh frameport-link-handler.sh`; Linux `frameport-links.desktop` +
|
||||
`xdg-mime`; macOS unsupported (Apple Events, paste instead). The script drops the link into `<data>/links/*.link`
|
||||
and starts FramePort unless `<data>/gui.alive` is < 10 s old (`gui.starting` stops double starts); the GUI's
|
||||
`_watch_links` thread touches the heartbeat and opens links (newest window session). Settings → Install links: one
|
||||
switch per scheme (`links.framedrop`, `links.frameport`, default on); a scheme another program owns (FrameDrop) is
|
||||
only taken with "Use FramePort for these links" (`register([s], force=True)`); off removes only FramePort's own
|
||||
registration (`MARK` in the command). Never registered with FRAMEPORT_HOME/FRAMEPORT_NO_LINK_HANDLER (tests,
|
||||
screenshots). Same round: files dropped on the Library (`ui/dropped.py`, bundles only like the Files tab), "Add a
|
||||
Windows program (.exe)…" (`pipeline.add_windows_exe`: exe in Downloads/home/drive root copied alone into
|
||||
`<data>/windows-apps/<slug>/`), patch `device.display_mode` (Automatic / VR / Flat window → `InstallContext.display`,
|
||||
`installer.show_window`). FramePort-only manifest extension `"frameport": {"description", "icon"}` (bad values ignored; icon: same URL rules,
|
||||
≤2 MiB, Pillow-checked, ≥32 px, saved as PNG in `<data>/downloads/icons/`, shown in the question by asset URL, then
|
||||
`sources.apply_custom(pkg, "icon")` unless `.picked` exists; description fills `details.description` only when
|
||||
empty). Bare file links get a title guessed from the file name (`title_from_filename`: version/arch dropped, package
|
||||
names → last part). Windows test of 0.12.1.dev191 (2026-10-07): a button click opened the dialog; but a click right
|
||||
after closing FramePort did nothing (the closed window's heartbeat was < 10 s old) → the handler scripts now wait
|
||||
up to 4 s for the link file to be taken before trusting the heartbeat, the window's CLOSE event / atexit delete
|
||||
`gui.alive`, and the Windows command runs under `conhost.exe --headless` (plain `-WindowStyle Hidden` flashed a
|
||||
console). Screens: `scripts/ui_smoke.py --links --fake-frame --game <pkg>` (tall pages: `--viewport
|
||||
1280x7000`; Flutter's popup menu ignores Escape).
|
||||
|
||||
## Releases, CI, GitHub
|
||||
Maintainer-only notes (accounts, credentials, key locations) live in the git-ignored `CLAUDE.local.md`.
|
||||
Public repo `github.com/spoopyghosty0/frameport` (branch `main`). Push a `v*` tag → CI (`.github/workflows/build.yml`)
|
||||
@@ -626,6 +772,7 @@ Installed apps find the release themselves (self-update), so the notes are what
|
||||
replace the rolling `dev` pre-release (`dev-release` job; same assets + SHA256SUMS). Automatic update checks ignore
|
||||
pre-releases; testers use Settings → Updates → "Install the latest dev build…" (`updates.check_dev`,
|
||||
`Updater.install_dev`). `parse_version` sorts 0.9.0 < 0.9.1.devN < 0.9.1, so testers get the next release normally.
|
||||
- **Upstream trackers:** issues labelled `upstream` (#73 microphone, #74 haptics, #75 VrApi bridge) list our workarounds for OVRPort bugs and how to drop them; check them against OVRPort's latest release before each release.
|
||||
- **Release checklist:** bump `src/frameport/_version.py` (the only version; `scripts/package.py` fails a tag build
|
||||
whose tag ≠ `v<_version>`), commit, `git tag -a vX.Y.Z -m "FramePort X.Y.Z" -m "<What's new, Markdown bullets>"`,
|
||||
push the commit and the tag. Never publish a release without its `SHA256SUMS.txt` (the updater refuses it) and keep
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
|
||||
Install games that target the Meta Quest, Android, or general PCVR onto your **Valve Steam Frame**. FramePort handles everything from uploading game files, setting up your Frame, injecting compatibility patches, and adding shortcuts to your Steam library. FramePort aims to be as simple as possible by taking advantage of the fact that the Steam Frame runs on Linux.
|
||||
|
||||

|
||||
[](docs/media/frameport-tour.mp4)
|
||||
|
||||
▶ [Watch the full tour](docs/media/frameport-tour.mp4) · New to FramePort? [Watch the install tutorial](docs/media/frameport-install.mp4)
|
||||
(about 90 seconds each, MP4; also attached to every release)
|
||||
|
||||
> **Notice:** FramePort explicitly does NOT download, share, or unlock games. You must provide legally obtained game
|
||||
> executables. Core features of FramePort simply download and wrap other published tools (see [Built on](#built-on))
|
||||
@@ -18,6 +21,8 @@ Install games that target the Meta Quest, Android, or general PCVR onto your **V
|
||||
|
||||
## Features
|
||||
|
||||

|
||||
|
||||
- **Painless setup:** one short command on the Frame. No root, no `sudo`, no password.
|
||||
[What it changes](docs/FRAME_SETUP.md).
|
||||
- **Type on Frame:** use your computer's keyboard on the Frame: in VR apps, Android apps, Steam and the desktop.
|
||||
@@ -28,11 +33,15 @@ Install games that target the Meta Quest, Android, or general PCVR onto your **V
|
||||
curved and 360° layers); game settings as simple switches.
|
||||
- **Beyond Quest:** Android apps as windows, PC VR via Proton or Revive, Windows (non-VR) games via Proton, a Files
|
||||
tab with drag and drop.
|
||||
- **Linux apps:** install arm64 Linux apps (AppImage, a folder, or a zip/tar archive) on the Frame with a Steam
|
||||
shortcut; they run natively on SteamOS.
|
||||
- **Linux apps:** install Linux apps (AppImage, a folder, or a zip/tar archive) on the Frame with a Steam
|
||||
shortcut; arm64 builds run natively on SteamOS, x86_64 builds through Valve's FEX translator.
|
||||
- **Install links:** "Install with FrameDrop" buttons on web pages (the one-click protocol of the FrameDrop
|
||||
sideloader) and pasted links open in FramePort, which asks, downloads, adds and installs the build.
|
||||
- **Screenshots tab:** the screenshots you took in the headset, sorted by game (matched by play time) and day;
|
||||
view them and download them to your computer.
|
||||
- **Live view tab:** watch what the headset shows, with sound, in a browser window on your computer.
|
||||
- **Monitor tab:** the running game's frame rate, the Frame's load, temperatures, power and battery live, and its
|
||||
processes, which you can end. [More](#monitor).
|
||||
- **Self-updating** releases, redacted diagnostics, one-click problem reports and working-config sharing.
|
||||
|
||||
## Quick start
|
||||
@@ -59,9 +68,9 @@ with OBB files): [docs/FAQ.md](docs/FAQ.md).
|
||||
## Type on Frame
|
||||
|
||||
Typing in VR is painful, so FramePort turns your computer's keyboard into a keyboard for the Frame. Open **Type on
|
||||
Frame** (keyboard icon on the sidebar's Frame card, the Steam Frame page, or a game's menu), select a text field in
|
||||
the headset and type: searches, logins, chat, in any app, in Steam or on the desktop. Paste longer text to type it in
|
||||
one go. Nothing to install: FramePort adds a virtual keyboard on the Frame while the window is open, without root.
|
||||
Frame** (its own tab in the sidebar), select a text field in the headset and type: searches, logins, chat, in any
|
||||
app, in Steam or on the desktop. Paste longer text to type it in one go. Nothing to install: FramePort adds a virtual
|
||||
keyboard on the Frame while the tab is open, without root.
|
||||
|
||||

|
||||
|
||||
@@ -87,6 +96,17 @@ videos muted). Pick 360p to 1080p, or the headset view's full size. The picture
|
||||
view on the Frame and is encoded there while you watch (about one CPU core), so stop it when you're done. It's black
|
||||
while the headset sleeps.
|
||||
|
||||
## Monitor
|
||||
|
||||
The **Monitor** tab shows what the Frame is doing while it's open: the running game with its frame rate against the
|
||||
display's refresh rate, CPU, graphics chip, memory, the hottest temperature with the fan speed, power draw and battery
|
||||
time left, each with a 2-minute chart. **Show details** adds every CPU core, all temperature sensors, where the power
|
||||
goes and the network. Below, the game's processes (or Steam's, or all of them) with their CPU, GPU and memory use:
|
||||
right-click one to end it, or end the whole game. Programs that Steam, SteamVR or the desktop need are marked and ask
|
||||
again. The Frame sends the numbers itself (about 1 % of one CPU core) and stops when you leave the tab.
|
||||
|
||||

|
||||
|
||||
## Compatibility
|
||||
|
||||
If a game has already been tested with FramePort, it will automatically use the optimal game config. Otherwise, FramePort
|
||||
@@ -94,7 +114,7 @@ will attempt to guess key patches. If you find a new config that works for an ap
|
||||
|
||||
**[List of tested games](docs/GAMES.md)**
|
||||
|
||||
**Tested something? Share it.** In FramePort open the game → **…** → **Share working config…** (it fills in the
|
||||
**Tested something? Share it.** In FramePort open the game → **…** → **Share working recipe…** (it fills in the
|
||||
recipe for you) or **Report a problem…** (attaches a diagnostics zip with personal data removed). Without the app:
|
||||
[share a working config](https://github.com/spoopyghosty0/frameport/issues/new?template=working-config.yml) · [report a problem](https://github.com/spoopyghosty0/frameport/issues/new?template=bug-report.yml). Shared configs become built-in recipes for everyone.
|
||||
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
e7554c6343ee2989b0a273ee6230e65c25bfe6499eefd00de19f5f0fee58754f ./arm64-v8a/libfp_langpack.so
|
||||
98a99cefe93079268d9158b23fa8ad5c7ade8e54c0d31526892635625eb3ef04 ./arm64-v8a/libfp_ovrp.so
|
||||
321da502e0f8f46f0880aad39fe6b84bdef88f925164568814cf704a1b31a577 ./arm64-v8a/libfp_ovrp.so
|
||||
40defdaddcda53bd2649eb48076fae1622bfc2bfc88e9e03c94fc8b45af2a4f2 ./arm64-v8a/libfp_ovrtrace.so
|
||||
7522a7cfb236e48d3442d418c4820cd37760a9627c6bdef80fb0df82df5fd826 ./arm64-v8a/libfp_vk.so
|
||||
383054f8b3b41dde76d062c71856cd3163655e50009c08454bc1793f393ead65 ./arm64-v8a/libfpg.so
|
||||
06c8a17b37cb1513fdfeba87ece457a02097bb22dd0a3a3a8719fb8fea16b52a ./arm64-v8a/libframe_xrshim.so
|
||||
9f5ba793d1804728394a8fe9e83028e13f1bc939b558892e7beb5c3662317259 ./arm64-v8a/libglshim.so
|
||||
d7709fe953a3170467ec0c53e6b715833014512fbd8d91803a9cb2aecf0961ad ./arm64-v8a/libopenxr_loader_generic.so
|
||||
8a8f6b1da8952cb3933a5b53558424a5fc56043b2527a16bb6dd62a00d2de01a ./arm64-v8a/libframe_xrshim.so
|
||||
fc559dbe0b87eecc3641256837293260cefb7c2ce7b21d808d10edd2a2dba9fc ./arm64-v8a/libglshim.so
|
||||
cc5b493cadefe76ad13fd096d3f8494a140ba593e0e1692db12d284bc548c1cf ./arm64-v8a/libopenxr_loader_generic.so
|
||||
1feaeafad467c4cafdf2b018a4d84b0bee200c3f711697b4ce97e66a3ba256ca ./arm64-v8a/libovrplatformcompat.so
|
||||
aa4dc0020c77e12d41ef6ce80b23ad90c9cb7e882338eddf2261efe8645cf38d ./arm64-v8a/libvrapi.so
|
||||
f994e6bc9ae32ab7ad17ffc992e10dce19289bed44d577b5ac08d7e99eb0174d ./armeabi-v7a/libopenxr_loader_generic.so
|
||||
c10412dd76a65a1d587b7ed226367d1a6f2bec238c733c97ee67eb8870c868e8 ./armeabi-v7a/libopenxr_loader_generic.so
|
||||
1871eae093432d277da4bc751bf5f3269dfcf11f9168260b0c3caadb0dedb19d ./dex/oculusos-stubs.dex
|
||||
1aa733117cf57ccff7cf23f0425dbfd73b0332a3ef1c905ceeca0ccd0449c4e0 ./linux-arm64/XR_APILAYER_FRAMEPORT_timefix.json
|
||||
28c2430a02bbd8902c5bfb9562c6fd0e318654f9e05c095bfeb94b0450ab1b07 ./linux-arm64/libxr_frameport_timefix.so
|
||||
b10b3a5c10c3339fc63fd9f6cb4d01ea29be11a863d0ebad1389ea69fd471940 ./linux-arm64-bin/fp_venc
|
||||
c2c70f4af1a5c3e6089dff1130161dd417f8044f99ec639eeecf1083930aab16 ./win-x64/fp_oculushmd.exe
|
||||
60ebc5fea05b8945082e2ca8b9f2eb74616012a26eb50133af273dff0fcddc42 ./win-x64/fp_vrsettings.exe
|
||||
@@ -0,0 +1,19 @@
|
||||
package: com.CortopiaStudios.Graves
|
||||
title: GORN2
|
||||
status: works
|
||||
tested_version: 1.10.1
|
||||
engine: Unity
|
||||
xr: OpenXR
|
||||
frame:
|
||||
- frame.unity_text_input
|
||||
device:
|
||||
- device.text_input_window
|
||||
adapter:
|
||||
haptic_fix: 1
|
||||
verified:
|
||||
date: '2026-10-07'
|
||||
known_good_sha256: d8a7949edc90c19902eb89f888ad6a350475387d630991767b3097667ad16d4c
|
||||
app: 0.12.0
|
||||
overport_cli: 1.2.5
|
||||
issue: 88
|
||||
source_hint: GORN 2
|
||||
@@ -0,0 +1,21 @@
|
||||
package: com.FourPlayersStudio.Retronika
|
||||
title: Retronika
|
||||
status: works
|
||||
tested_version: 3.2.601
|
||||
engine: Unity
|
||||
xr: OpenXR
|
||||
frame:
|
||||
- frame.unity_text_input
|
||||
device:
|
||||
- device.text_input_window
|
||||
adapter:
|
||||
haptic_fix: 1
|
||||
verified:
|
||||
date: '2026-10-07'
|
||||
known_good_sha256: 290bfda3969547d5f1ff621ab5a8be9dd322fc9eee6b243c863576d4ff5b4b81
|
||||
app: 0.12.0
|
||||
overport_cli: 1.2.5
|
||||
frame_build: '20261006.6173745'
|
||||
agent: 59
|
||||
issue: 97
|
||||
source_hint: Retronika
|
||||
@@ -4,14 +4,25 @@ tested_version: '1.03'
|
||||
source_hint: Sniper Elite VR
|
||||
engine: Unity
|
||||
xr: VrApi
|
||||
status: unsupported
|
||||
notes: 'GPU hang (zink: DEVICE LOST) even with MSAA off.'
|
||||
details: Legacy VrApi via OVRPlugin.
|
||||
status: works
|
||||
notes: Plays with controllers that follow the hands (owner's headset test, Quest 1 build 35713).
|
||||
details: 'Unity 2019.4 on its built-in Oculus VR (no Oculus XR Plugin). Its legacy frame loop never waited for frames
|
||||
(GPU hang, zink: DEVICE LOST) and Unity reported only Go controllers: frame.unity_oculus_check. Its frame wait then
|
||||
deadlocked at the Init scene (Unity skipped beginning a frame) and the physics-step pose update located the
|
||||
controllers in the past (hands lagged): both fixed in that patch (revision 5), switched on for this game by ovrp_begin_gate and ovrp_hold_physics. Grabbing an object in the tutorial
|
||||
vibrates the controller; OVRPort''s envelope conversion then allocated ~1 GB/s until the memory cap ended the game:
|
||||
haptic_fix. The Quest 1 build has no arraysources_assets.hd, which the game loads on the Frame (it detects a Quest
|
||||
2) and then skips the .sd bundle: textures are missing unless the .sd file is also present under the .hd name in the
|
||||
game''s obb folder.'
|
||||
frame:
|
||||
- frame.unity_no_msaa
|
||||
- frame.unity_oculus_check
|
||||
adapter:
|
||||
haptic_fix: 1
|
||||
ovrp_begin_gate: 1
|
||||
ovrp_hold_physics: 1
|
||||
pcvr_alternative: Sniper Elite VR (Steam PC VR). Winter Warrior (Quest) works on the Frame.
|
||||
verified:
|
||||
date: '2026-09-28'
|
||||
overport_cli: 1.2.3
|
||||
overport_runtime: 3.4.3-23204ea
|
||||
known_good_sha256: e80883eb6945e267a375edf0ffd789268686440819add9d4dee9fdbdf466cbe4
|
||||
date: '2026-10-07'
|
||||
updated: '2026-10-07'
|
||||
min_app: 0.12.1
|
||||
@@ -1,20 +1,25 @@
|
||||
package: com.StressLevelZero.BONELAB
|
||||
title: BONELAB
|
||||
status: issues
|
||||
notes: Build 1.2068 plays (head tracking and controls work with frame.unity_user_presence); the newer build
|
||||
1.2974 crashes at start (Vulkan), no fix yet.
|
||||
details: The game runs (72 fps), but its player body stayed frozen - no head tracking, the controllers stuck to the
|
||||
status: works
|
||||
notes: Builds 1.2068 and 1.2974 play (owner's headset tests). One recipe serves both builds - 1.2068 needs frame.unity_user_presence (head tracking and controls); 1.2974 also needs
|
||||
frame.slz_vulkan_hooks (72 fps after about 35 s of shader prewarming), which changes nothing on 1.2068.
|
||||
details: Both builds - the game runs (72 fps), but its player body stayed frozen - no head tracking, the controllers stuck to the
|
||||
model, no buttons - although OpenXR input and OVRPlugin's poses were fine. A few seconds after start (when Unity
|
||||
switches XR loaders) OVRPlugin reports the worn headset as not worn (ovrp_GetUserPresent2 -> 0), and BONELAB's
|
||||
Marrow rig only follows the player while Unity's HMD device reports UserPresence (OpenControllerRig checks
|
||||
XRHMD.IsUserPresent every frame). frame.unity_user_presence reports the headset as worn. Build 1.2974 crashed
|
||||
earlier in vkCreateInstance from the game's own Vulkan hooks (libSLZQuestNative.so); not retested.
|
||||
tested_version: 1.2068.34555
|
||||
XRHMD.IsUserPresent every frame). frame.unity_user_presence reports the headset as worn. Build 1.2974 only - it adds Stress
|
||||
Level Zero's graphics plugin (libSLZQuestNative.so), which hooks Unity's Vulkan start-up (vkCreateInstance/
|
||||
vkCreateDevice) and vkCreateSampler; on the Frame its vkCreateInstance wrapper calls an invalid pointer right after
|
||||
OVRPlugin's pre-init instance is destroyed (a jump to 0, into an unloaded library, or a hang). frame.slz_vulkan_hooks
|
||||
switches its two registrations off, so Unity starts Vulkan itself; the plugin's pipeline cache isn't used.
|
||||
tested_version: 1.2974.57485
|
||||
engine: Unity
|
||||
xr: OpenXR
|
||||
frame:
|
||||
- frame.unity_user_presence
|
||||
- frame.slz_vulkan_hooks
|
||||
verified:
|
||||
date: '2026-10-06'
|
||||
updated: '2026-10-06'
|
||||
date: '2026-10-08'
|
||||
updated: '2026-10-08'
|
||||
source_hint: BONELAB
|
||||
min_app: 0.12.1
|
||||
@@ -0,0 +1,22 @@
|
||||
package: com.ToastVR.RichiesPlankExperience
|
||||
title: Richie's Plank Experience
|
||||
status: works
|
||||
tested_version: 2.3.585
|
||||
engine: Unity
|
||||
xr: OpenXR
|
||||
frame:
|
||||
- frame.unity_text_input
|
||||
- frame.oculusos
|
||||
device:
|
||||
- device.text_input_window
|
||||
adapter:
|
||||
haptic_fix: 1
|
||||
verified:
|
||||
date: '2026-10-07'
|
||||
known_good_sha256: 7eb1366c2398e554624a5d66aefb0c731c64b1b6944bc1726d9187f123c37fb7
|
||||
app: 0.12.0
|
||||
overport_cli: 1.2.5
|
||||
frame_build: '20260922.6101926'
|
||||
agent: 59
|
||||
issue: 95
|
||||
source_hint: apks
|
||||
@@ -0,0 +1,23 @@
|
||||
package: com.VR_HOT.VR_HOT_Quest
|
||||
title: VR HOT Quest
|
||||
status: works
|
||||
tested_version: 0.8.8.1
|
||||
engine: Unity
|
||||
xr: OpenXR
|
||||
frame:
|
||||
- frame.unity_text_input
|
||||
- frame.oculusos
|
||||
device:
|
||||
- device.text_input_window
|
||||
adapter:
|
||||
controller_models: 1
|
||||
haptic_fix: 1
|
||||
verified:
|
||||
date: '2026-10-08'
|
||||
known_good_sha256: c321606c536eba1673572a9f44fd9e20d2cb5bd9609d536189e6ad7057b9cd67
|
||||
app: 0.12.0
|
||||
overport_cli: 1.2.5
|
||||
frame_build: '20260922.6101926'
|
||||
agent: 59
|
||||
issue: 98
|
||||
source_hint: VR-HOT-Quest-0.8.8.1
|
||||
@@ -0,0 +1,25 @@
|
||||
package: com.YourCompany.SWP_VR
|
||||
title: Star Wars Pinball VR
|
||||
tested_version: '1.4'
|
||||
source_hint: Star Wars Pinball VR
|
||||
engine: Unreal
|
||||
xr: VrApi
|
||||
status: works
|
||||
notes: Plays (owner's headset test); one short audio hiccup seen.
|
||||
details: 'Unreal 4.25 (GLES) built against OVRPlugin 1.44. Four Frame problems in a row: Zink crashed on Unreal''s
|
||||
multisampled render-to-texture (fault addr 0x10000 on the RHIThread): frame.unreal_gl_shim, which keeps Unreal''s
|
||||
multiview and draws those passes single-sampled; OVRPort''s OVRPlugin lacks ovrp_GetPTWNear, so Unreal''s Oculus
|
||||
module never started VR (then a null pointer in GetMultiViewSceneColor): frame.unreal_ovrp_entrypoints; the engine''s
|
||||
OpenSSL assembly has unpaired return-address checks the Frame''s CPU enforces (SIGILL on the HttpManager thread):
|
||||
frame.pac_hints. Needs its OBB (main.10765).'
|
||||
frame:
|
||||
- frame.unreal_gl_shim
|
||||
- frame.unreal_ovrp_entrypoints
|
||||
- frame.pac_hints
|
||||
adapter:
|
||||
haptic_fix: 1
|
||||
verified:
|
||||
date: '2026-10-08'
|
||||
issue: 83
|
||||
updated: '2026-10-08'
|
||||
min_app: 0.12.1
|
||||
@@ -0,0 +1,21 @@
|
||||
package: com.characterBank.ruinsmagus
|
||||
title: RUINSMAGUS
|
||||
status: works
|
||||
tested_version: 1.2.3
|
||||
engine: Unity
|
||||
xr: VrApi
|
||||
frame:
|
||||
- frame.unity_text_input
|
||||
device:
|
||||
- device.text_input_window
|
||||
adapter:
|
||||
haptic_fix: 1
|
||||
verified:
|
||||
date: '2026-10-07'
|
||||
known_good_sha256: 230e5625fbdfebb47c4d96aeb87f45270e4e6c79a33c08315c90626ab7465fe5
|
||||
app: 0.12.0
|
||||
overport_cli: 1.2.5
|
||||
frame_build: '20261006.6173745'
|
||||
agent: 59
|
||||
issue: 89
|
||||
source_hint: RUINSMAGUS
|
||||
@@ -0,0 +1,22 @@
|
||||
package: com.cloudheadgames.pistolwhip
|
||||
title: Pistol Whip
|
||||
status: works
|
||||
notes: 120 HZ
|
||||
tested_version: 1.6.0.2
|
||||
engine: Unity
|
||||
xr: OpenXR
|
||||
frame:
|
||||
- frame.unity_text_input
|
||||
device:
|
||||
- device.text_input_window
|
||||
adapter:
|
||||
haptic_fix: 1
|
||||
verified:
|
||||
date: '2026-10-08'
|
||||
known_good_sha256: ebd97af54c59d59d473c98492c1bb26ce6059b7e59f27a08acfc5ada23d0b774
|
||||
app: 0.12.0
|
||||
overport_cli: 1.2.5
|
||||
frame_build: '20261006.6173745'
|
||||
agent: 59
|
||||
issue: 100
|
||||
source_hint: Pistol Whip
|
||||
@@ -0,0 +1,25 @@
|
||||
package: com.coatsink.alone
|
||||
title: Jurassic World Aftermath Collection
|
||||
status: works
|
||||
notes: Plays (owner's headset test, 2026-10-06).
|
||||
tested_version: v3.16
|
||||
engine: Unity
|
||||
xr: VrApi
|
||||
frame:
|
||||
- frame.unity_no_msaa
|
||||
- frame.unity_oculus_check
|
||||
- frame.unity_text_input
|
||||
- frame.unity_runtime_msaa_off
|
||||
- frame.unity_gl_shim
|
||||
- frame.vrapi_stub
|
||||
device:
|
||||
- device.text_input_window
|
||||
adapter:
|
||||
haptic_fix: 1
|
||||
verified:
|
||||
date: '2026-10-06'
|
||||
known_good_sha256: 0566b39d96258fa15eb1b03f27a7ad4219eb5442b0355cd803ed1cf13313f1b3
|
||||
app: 0.12.0
|
||||
updated: '2026-10-06'
|
||||
min_app: 0.12.0
|
||||
source_hint: Jurassic World Aftermath Collection
|
||||
@@ -0,0 +1,22 @@
|
||||
package: com.curif.AgeOfJoy
|
||||
title: AgeOfJoy
|
||||
status: works
|
||||
tested_version: '1.0'
|
||||
engine: Unity
|
||||
xr: OpenXR
|
||||
frame:
|
||||
- frame.unity_text_input
|
||||
- frame.oculusos
|
||||
device:
|
||||
- device.text_input_window
|
||||
adapter:
|
||||
haptic_fix: 1
|
||||
verified:
|
||||
date: '2026-10-08'
|
||||
known_good_sha256: 9780e71e417b86290147c67c83755305801d8957909734c717a519034edefdf9
|
||||
app: 0.12.0
|
||||
overport_cli: 1.2.5
|
||||
frame_build: '20261006.6173745'
|
||||
agent: 59
|
||||
issue: 103
|
||||
source_hint: AgeOfJoy 05 rc30
|
||||
@@ -0,0 +1,14 @@
|
||||
package: com.drbeef.doom3quest
|
||||
title: Doom3Quest
|
||||
status: issues
|
||||
notes: PDA shows black screen.
|
||||
tested_version: 1.4.8
|
||||
engine: Other
|
||||
xr: OpenXR
|
||||
verified:
|
||||
date: '2026-10-06'
|
||||
known_good_sha256: 3c733f5cd08b6fa5d9e2775b1c1aee36b5943518b5d8451ba87e3c59a702afdf
|
||||
app: 0.12.0
|
||||
overport_cli: 1.2.3
|
||||
issue: 77
|
||||
source_hint: doom3quest148
|
||||
@@ -0,0 +1,17 @@
|
||||
package: com.drbeef.lambda1vr
|
||||
title: Lambda1VR
|
||||
status: works
|
||||
notes: 'Needs the game data: upload the release''s xash folder to the game''s storage (Files tab) and set --msaa
|
||||
1 in xash/commandline.txt. Owner''s headset test, 2026-10-06.'
|
||||
tested_version: 1.7.3
|
||||
engine: Other
|
||||
xr: OpenXR
|
||||
frame:
|
||||
- frame.tbxr_vendor
|
||||
verified:
|
||||
date: '2026-10-06'
|
||||
known_good_sha256: 10bbccceb8d9a84ff3bcc9a21fd59db52784ff7742998bbe5b30d938dd7b97d2
|
||||
app: 0.12.0
|
||||
updated: '2026-10-06'
|
||||
min_app: 0.12.0
|
||||
source_hint: Lambda1VR
|
||||
@@ -0,0 +1,21 @@
|
||||
package: io.ARVORE.TheBoysVR
|
||||
title: The Boys VR
|
||||
status: works
|
||||
notes: Plays with space warp off (owner's headset test, 2026-10-06; black screen reported before).
|
||||
tested_version: 1.1.0.345
|
||||
engine: Unity
|
||||
xr: OpenXR
|
||||
frame:
|
||||
- frame.unity_text_input
|
||||
device:
|
||||
- device.text_input_window
|
||||
adapter:
|
||||
haptic_fix: 1
|
||||
hide_space_warp: 1
|
||||
verified:
|
||||
date: '2026-10-06'
|
||||
known_good_sha256: 5df46b1771611c607229ee59298d983a4d78a57591d4864a02da2df5d2b6f97b
|
||||
app: 0.12.0
|
||||
updated: '2026-10-06'
|
||||
min_app: 0.12.0
|
||||
source_hint: The Boys
|
||||
@@ -0,0 +1,18 @@
|
||||
package: org.timecrisis.quest
|
||||
title: Time Crisis VR (Experimental)
|
||||
status: works
|
||||
notes: Fully playable at 120hz
|
||||
tested_version: 0.8.3
|
||||
engine: Other
|
||||
xr: OpenXR
|
||||
frame:
|
||||
- frame.sdl_clipboard
|
||||
verified:
|
||||
date: '2026-10-06'
|
||||
known_good_sha256: 4e67411a8e9c0b5fbb19ca7908c4222aa5ad1b2d47a8f4b5018b4fe9c2f5324e
|
||||
app: 0.12.0
|
||||
overport_cli: 1.2.3
|
||||
frame_build: '20261005.6135832'
|
||||
agent: 59
|
||||
issue: 80
|
||||
source_hint: TimeCrisisVR-v0.8.3-quest
|
||||
@@ -0,0 +1,18 @@
|
||||
package: ru.targem.blazerush
|
||||
title: BlazeRush
|
||||
status: unsupported
|
||||
notes: Starts and reaches the menu room, but the room shows no controllers and ignores all input (it all reaches
|
||||
the game); no fix yet.
|
||||
tested_version: 1.0.349
|
||||
engine: Other
|
||||
xr: VrApi
|
||||
frame:
|
||||
- frame.vrapi_bridge
|
||||
- frame.avatar_stub
|
||||
verified:
|
||||
date: '2026-10-06'
|
||||
known_good_sha256: 7cbd5d4252788ccd3c95b5c1841dcc798ea029d687938c024e33bd698ba17671
|
||||
app: 0.12.0
|
||||
updated: '2026-10-06'
|
||||
min_app: 0.12.0
|
||||
source_hint: BlazeRush
|
||||
@@ -8,16 +8,41 @@ signatures:
|
||||
severity: fatal
|
||||
diagnosis: Lepton found no activity with category LAUNCHER.
|
||||
suggest: [frame.launcher]
|
||||
- id: linux-x86-no-fex
|
||||
pattern: '(cannot execute binary file: Exec format error|exec format error)'
|
||||
severity: fatal
|
||||
diagnosis: An x86_64 Linux program was started directly; the Frame's arm64 CPU needs FEX (x86 translation) for it. Reinstall the app with FramePort 0.12 or newer, which installs FEX and starts the program through it.
|
||||
suggest: []
|
||||
- id: no-arm64
|
||||
pattern: 'INSTALL_FAILED_NO_MATCHING_ABIS'
|
||||
severity: fatal
|
||||
diagnosis: 32-bit-only APK. The Steam Frame has no AArch32; this cannot run. Use the PC (Rift) version via Revive.
|
||||
suggest: []
|
||||
- id: android-too-new
|
||||
pattern: '(NoClassDefFoundError|ClassNotFoundException|NoSuchMethodError)\b.*(Landroid/window/|android\.window\.|(storeStoreFence|loadLoadFence)\(\)V in class Ljava/lang/invoke/VarHandle)'
|
||||
severity: fatal
|
||||
diagnosis: The app calls Android 12/13+ classes (android.window.*, VarHandle fences) that the Frame's Android 11 (API 30) container doesn't have; it needs a newer Android (e.g. minSdk 34 apps). Nothing to patch - it can't run until Valve updates the Frame's Android.
|
||||
suggest: []
|
||||
- id: web-wrapper
|
||||
pattern: '(Creating TwaLauncher for com\.oculus\.browser|NameNotFoundException:? com\.oculus\.browser)'
|
||||
severity: fatal
|
||||
diagnosis: The app is a website in an Android wrapper (Trusted Web Activity) that opens Meta's browser (com.oculus.browser), which the Frame doesn't have, so nothing opens. There's no game to port - open the website (TWALauncherActivity's "Using URL" line) in a browser instead.
|
||||
suggest: []
|
||||
- id: unity-render-crash
|
||||
pattern: 'CRASH\s*:.*#\d+\s+pc [0-9a-f]+\s+\S*libgallium_dri\.so'
|
||||
severity: fatal
|
||||
diagnosis: Unity's render thread crashed inside the Frame's GL driver (Mesa/Zink); the picture freezes or stays grey. Known triggers - an OVROverlay copy (try "Unity - skip OVROverlay layers", e.g. The Room VR), MSAA switched on at runtime, a GPU hang (zink DEVICE LOST).
|
||||
suggest: [frame.unity_no_overlay_copy, frame.unity_runtime_msaa_off]
|
||||
- id: unreal-msrtt-crash
|
||||
pattern: 'fault addr 0x10000 in tid \d+ \((RHIThread|RenderThread)'
|
||||
severity: fatal
|
||||
diagnosis: The game's render thread jumped to address 0x10000 inside the Frame's GL driver (Mesa/Zink) a few seconds after start. Zink looks up a render-pass cache slot past its end when a game renders through multisampled render-to-texture (Unreal's mobile MSAA, e.g. Star Wars Pinball VR). Load the GL shim, which hides that extension.
|
||||
suggest: [frame.unreal_gl_shim, frame.unity_gl_shim]
|
||||
- id: pac-unpaired
|
||||
pattern: 'ILL_ILLOPN\), fault addr 0x[0-9a-f]+ \(\*pc=0xd50323bf\)'
|
||||
severity: fatal
|
||||
diagnosis: The game crashed on a return-address check (autiasp) its code never signed. The Quest's CPU ignores these checks, the Steam Frame's enforces them; some OpenSSL assembly in game engines has such unpaired checks (e.g. Star Wars Pinball VR on its first network connection, thread HttpManager).
|
||||
suggest: [frame.pac_hints]
|
||||
- id: swapchain-rect-invalid
|
||||
pattern: 'xrEndFrame failed -25\b'
|
||||
severity: fatal
|
||||
@@ -79,6 +104,12 @@ signatures:
|
||||
diagnosis: Unity didn't start its Oculus VR device (older Unity checks for Meta's system apps first), so the game
|
||||
runs as a hidden 2D app.
|
||||
suggest: [frame.unity_oculus_check]
|
||||
- id: unity-frame-not-begun
|
||||
pattern: 'frame loop shim: frame \d+: the last waited frame wasn.t begun'
|
||||
severity: info
|
||||
diagnosis: Unity skipped beginning a frame (typically while it activates a scene); FramePort's frame wait didn't
|
||||
wait for that frame instead of blocking the game. A few at each scene load are normal.
|
||||
suggest: []
|
||||
- id: sdl-no-clipboard
|
||||
pattern: 'ClipboardManager\.addPrimaryClipChangedListener|SDLClipboardHandler\.<init>'
|
||||
severity: fatal
|
||||
@@ -91,6 +122,12 @@ signatures:
|
||||
harmless (Meta's OVRPlugin suggests plain Touch too); a game that suggests only these gets them again as Touch
|
||||
(profile_remap, on by default; log "controller profile ... -> oculus/touch_controller").
|
||||
suggest: []
|
||||
- id: input-call-failed
|
||||
pattern: 'input_diag: unsupported: (xrStringToPath|xrCreateAction|xrAttachSessionActionSets|xrSyncActions) ->'
|
||||
severity: warning
|
||||
diagnosis: The runtime refused one of the game's controller-input calls (logged by input_diag; the line names the
|
||||
call, the result and the argument), so controls set up through it don't work.
|
||||
suggest: []
|
||||
- id: gl-shader-failed
|
||||
pattern: 'GLShim\s*: SHADER COMPILE FAILED|#extension directive is not allowed in the middle|could not implicitly convert operands'
|
||||
severity: error
|
||||
@@ -208,6 +245,12 @@ signatures:
|
||||
voice chat a few seconds after the logo).
|
||||
suggest: [frame.ovr_microphone]
|
||||
supersedes: [native-crash]
|
||||
- id: slz-vulkan-hook-crash
|
||||
pattern: 'SLZ Graphics plugin loading![\s\S]{0,20000}?E CRASH : .*pc 0000000000000000'
|
||||
severity: fatal
|
||||
diagnosis: Stress Level Zero's graphics plugin (libSLZQuestNative.so) hooks Unity's Vulkan start-up and calls an invalid function there on the Frame (e.g. BONELAB 1.2974); the game crashes or hangs before its first frame.
|
||||
suggest: [frame.slz_vulkan_hooks]
|
||||
supersedes: [java-crash, native-crash]
|
||||
- id: native-crash
|
||||
pattern: 'Fatal signal (\d+) \(SIG[A-Z]+\)'
|
||||
severity: fatal
|
||||
|
||||
@@ -35,6 +35,11 @@
|
||||
## Extending
|
||||
- **New fix**: `patches/frame/<name>.py` with a `Patch` subclass (`detect`, `apply`, optional `validate`), plus a
|
||||
signature in `catalog/triage.yaml` and a PLAYBOOK row. Stages: `overport` | `apk` | `install`.
|
||||
- **Upstream fixed a bug we work around**: register an `UpstreamFix` (`patches/upstream.py`) in the workaround's
|
||||
module: a probe that finds the fix in OVRPort's output (True / False / None = can't tell). Each build runs the probes
|
||||
on the converted APK and leaves out the workarounds whose fix is there (log "not needed: …", `build.superseded`,
|
||||
left out of settings.conf at install; game page and `frameport show` say so). The recipe keeps asking for the fix,
|
||||
so builds made with an older runtime keep the workaround. `FRAMEPORT_KEEP_WORKAROUNDS=1` turns it off.
|
||||
- **New heuristic**: put it in the patch's `detect()` (and `applies()` for visibility), with the evidence in the
|
||||
reason text; check `scripts/eval_heuristics.py` still reproduces the catalog and add a test in
|
||||
`tests/test_heuristics.py`.
|
||||
|
||||
@@ -6,7 +6,7 @@ Other games get suggested patches from detection rules; each suggestion states i
|
||||
switched on or off under **Customize**: described in plain words, with **Show technical details** for the exact
|
||||
effect of each patch.
|
||||
|
||||
Tried an untested game? Its page asks how it runs; **Share working config…** opens a prefilled GitHub issue so your
|
||||
Tried an untested game? Its page asks how it runs; **Share working recipe…** opens a prefilled GitHub issue so your
|
||||
recipe can join the built-in catalog for everyone.
|
||||
|
||||

|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Two ways users feed results back, both without a GitHub token:
|
||||
|
||||
- **Share working config** (game menu, `frameport share-recipe <pkg>`): saves the recipe as a user catalog entry and
|
||||
- **Share working recipe** (game menu, `frameport share-recipe <pkg>`): saves the recipe as a user catalog entry and
|
||||
opens a prefilled issue from `.github/ISSUE_TEMPLATE/working-config.yml`. A maintainer checks it and adds the label
|
||||
`catalog-accepted`. Then `.github/workflows/catalog-from-issue.yml` runs `scripts/catalog_from_issue.py`, which reads
|
||||
only the YAML block, validates it, and writes `catalog/games/<pkg>.yaml`, and the workflow opens a PR.
|
||||
|
||||
@@ -24,7 +24,7 @@ Games/ ← scan this folder (Add games → Scan
|
||||
as alternates.
|
||||
- **Scanning:** pick the folder that contains the game folders (`Games/` above) to add them all, or one game's folder
|
||||
to add just that game. FramePort looks up to 5 levels deep.
|
||||
- **A single game:** Add games → Add an APK file… works with a lone APK too. Its data is found when the data folder sits next
|
||||
- **A single game:** Add games → Add an APK… works with a lone APK too. Its data is found when the data folder sits next
|
||||
to the APK, named as above.
|
||||
|
||||
Not sure of the package name? Look at the OBB file names: `main.<version>.<package name>.obb`. Or add the APK
|
||||
|
||||
@@ -28,6 +28,23 @@
|
||||
work on Android 11: `policy_control` is gone, `cmd statusbar send-disable-flag home recents` has no `back` and
|
||||
moves the back button onto the app's controls, the `sysui_nav_bar` layout and disabling SystemUI had no effect.
|
||||
|
||||
## Where FramePort keeps games (internal storage, microSD)
|
||||
- Every game has an **anchor** on internal storage: `~/Applications/quest-frame/<pkg>/` with `launch.sh`,
|
||||
`deployment.json`, `artwork/` and `plays.log`. Steam's shortcut points at the anchor's `launch.sh`, so it never
|
||||
changes when the files move.
|
||||
- The game's files (`lepton-app/`, `lepton-data/` = saves, `lepton-shaders/`, `settings.conf`, `launch.log`; PC VR:
|
||||
`game/`, `revive/`, `compatdata/` = Proton prefix; Linux: `app/`) live in `deployment.json["base"]`: the anchor
|
||||
itself on internal storage, or `<mount>/FramePort/<pkg>` on another drive (GitHub #90, agent v63).
|
||||
- SteamOS mounts removable drives (microSD) under `/run/media/<user>/<label or uuid>`; the agent's `drives` reads
|
||||
`/proc/mounts` (plus the drives of Steam library folders) and refuses vfat/exfat/ntfs (Lepton's data and Proton
|
||||
prefixes need Unix owners, permissions and symlinks) and read-only mounts. A drive that isn't mounted is an error for
|
||||
new installs (never a silent fallback to internal storage); `list_installed` marks games on it `drive_missing` and
|
||||
their launchers stop with "storage not mounted?".
|
||||
- `move` copies with `cp -a` inside `podman unshare` (files Lepton's containers own belong to subordinate user ids),
|
||||
compares file count + bytes, retargets absolute symlinks into the old folder (the LibOVRRT → Revive redirect), points
|
||||
`launch.sh` at the new folder and only then deletes the old copy; on the same filesystem it renames instead.
|
||||
Moving a game whose Lepton data holds absolute paths, or a PC VR prefix, is not yet verified on the device.
|
||||
|
||||
## OpenXR runtime (as seen by games through overport's loader)
|
||||
- Instance extensions present include KHR_android_create_instance (must be enabled; the adapter adds it),
|
||||
KHR_vulkan_enable(2), KHR_opengl_es_enable, KHR_composition_layer_depth, FB_display_refresh_rate, EXT_hand_tracking
|
||||
@@ -69,6 +86,17 @@
|
||||
SteamLinuxRuntime_4). None are installed by default.
|
||||
- `steam -ifrunning steam://install/<appid>` only opens a confirmation dialog in the headset. The agent's unattended
|
||||
mode writes an appmanifest stub (StateFlags 1026, installdir from appinfo) and restarts Steam, which then downloads it.
|
||||
- **x86_64 Linux apps (agent v61; verified on the device 2026-10-07: an x86_64 glibc test program installed + launch test RUNNING, "machine=x86_64 glibc=2.41"):**
|
||||
FEX is Steam app 3127680 (`fex`, installs as `common/FEX-Emu`, ~6 MB, 21 s via the appmanifest-stub path:
|
||||
`install_proton` / `proton_status` with `kind: linux_x86`). Its toolmanifest commandline is
|
||||
`/fex-compat-tool %verb% --`, **no** require_tool_appid: it does not use the Steam Linux Runtime. fex-compat-tool
|
||||
(Python) runs `<FEX-Emu>/usr/bin/FEX` with RootFS `/usr/share/guestos/fex-mesa` (part of the SteamOS image: an
|
||||
x86 Arch-style root with glibc 2.41, Mesa, graphics_provider.json for x86_64 + i386), emulates x86_64 and i386
|
||||
(emulator.json), honours `STEAM_FEX_TSOENABLED`, `STEAM_FEX_MULTIBLOCK`, `STEAM_COMPAT_FEX_CONFIG`, sets
|
||||
`tu_override_uncached_as_cache_coherent=true` and logs to `/tmp/fex-compat-tool-<pid>.log`. It **exits 1 ("No compat
|
||||
data path?") without `STEAM_COMPAT_DATA_PATH`** (keeps Config.json/AppConfig/Server/Telemetry in `<it>/fex-emu/`):
|
||||
the Linux launcher exports `<base>/compatdata`. Version seen: FEX-2607-76-g37265b1. ldd can't read x86 programs,
|
||||
so the missing-library check is skipped for them; an x86_64 AppImage is extracted through the same chain.
|
||||
- The command Steam runs is built from each tool's `toolmanifest.vdf` (`commandline`, `require_tool_appid`):
|
||||
`<SLR4-arm64>/_v2-entry-point --verb=waitforexitandrun -- <Proton>/proton waitforexitandrun <exe>`.
|
||||
- Proton sets up VR (vrclient/wineopenxr registry) only when `SteamGameId` is set (steam_helper `setup_vr_registry`).
|
||||
@@ -109,6 +137,24 @@
|
||||
- Processes started from Steam (Konsole, SSH sessions?) share steam.service's cgroup: use `systemd-run --user`.
|
||||
- SSH: `sshd` must be enabled (`sudo systemctl enable --now sshd`), which needs a user password (`passwd`).
|
||||
- mDNS: avahi-daemon runs by default; hostname `frame` → `frame.local`.
|
||||
- Desktop Mode menu entries (GitHub #84, agent v63): Linux apps get `~/.local/share/applications/frameport-<slug>.desktop`
|
||||
(+ an executable copy in `~/Desktop` when that folder exists; Plasma starts executable `.desktop` files there
|
||||
without a trust prompt), `Exec=env FRAMEPORT_DESKTOP=1 "<anchor>/launch.sh"`, marked `X-FramePort-Package=<pkg>`.
|
||||
Plasma's launcher exits right after starting the program, so with `FRAMEPORT_DESKTOP=1` the Linux launcher skips
|
||||
its "Steam parent gone → end the app" watchdog and keeps the desktop's DISPLAY/WAYLAND_DISPLAY instead of taking
|
||||
gamescope's from Steam. Not yet tried from the Frame's Desktop Mode.
|
||||
- Linux apps' own icons (GitHub #99, agent v64): finalize_linux (and every refresh of the menu entries) copies the
|
||||
app's icon to `<anchor>/artwork/app-icon.{png,svg}`: an AppImage's `squashfs-root/.DirIcon` (usually a symlink),
|
||||
else the `Icon=` of its top-level `.desktop` file (a folder app: the first `.desktop` within 3 levels) looked up
|
||||
next to it, in `(usr/)share/icons/hicolor/*/apps/` and `(usr/)share/pixmaps/`; the biggest PNG ≥128 px, else an
|
||||
SVG, else the biggest PNG. Symlinks are resolved and must stay inside the app folder; absolute and `../` names
|
||||
are ignored. Precedence for the menu entry's `Icon=` and the Steam shortcut's icon: the user's chosen/store icon
|
||||
(`artwork/.icon-source` = `custom`, written by the PC with every art upload) > the app's own (Steam: PNG only) >
|
||||
FramePort's placeholder (`artwork/icon.*`). `StartupWMClass=` is copied from the app's `.desktop` file (Plasma's
|
||||
task bar matches the window to the entry). A PNG ≤1 MiB goes back to the PC (finalize result `app_icon.png`,
|
||||
base64) and becomes the library's icon when the game has none and nothing was picked (`.app-icon` marker = its
|
||||
sha256, no `.picked`); folder apps get it on the PC at add time (`analysis/linux.find_icon`). Not yet seen in
|
||||
Desktop Mode on the device.
|
||||
|
||||
## Video of the headset view (surveyed 2026-10-05; used by the Live view tab)
|
||||
- `steamvr-v4l2cam.service` (user unit, part of gamescope-session.target, `Restart=always`) runs SteamVR's
|
||||
@@ -131,7 +177,60 @@
|
||||
`h264_v4l2m2m` hangs, gst `v4l2h264enc` not-negotiated). ffmpeg + libx264 works: FramePort's live view
|
||||
(`install/livestream.py`: `fps=30` before the scale, ultrafast/zerolatency, 3 threads, nice 10, fragmented MP4 on
|
||||
stdout, + AAC 128k) measured 0.34 core at 720p / 0.56 at 1080p with a quiet picture (video only); expect ~1-1.4
|
||||
cores with a busy scene.
|
||||
cores with a busy scene. That is now only the fallback.
|
||||
- Hardware encoding (2026-10-07): the iris encoder works when driven directly through the V4L2 stateful encoder
|
||||
interface. That is FramePort's `fp_venc` (`native/venc`, spec + every measured value in `native/venc/SPEC.md`).
|
||||
Facts:
|
||||
- Device: `/dev/video23` (`/dev/video-enc0` links to it), driver `iris_driver`, M2M multiplanar.
|
||||
- Formats: input NV12/NV21/AB24(RGBA)/QC24/Q08C; output H264/HEVC; sizes 128..8192.
|
||||
- NV12 layout (S_FMT answers):
|
||||
- stride is a multiple of 128;
|
||||
- the returned height is padded to a multiple of 32;
|
||||
- CbCr starts at stride × padded height;
|
||||
- sizeimage is rounded up to 4 KiB;
|
||||
- the default crop is the requested size.
|
||||
- Controls: CBR, FORCE_KEY_FRAME, PREPEND_SPSPPS_TO_IDR, HEADER_MODE joined, FRAME_SKIP_MODE, H.264 profiles
|
||||
Baseline..Constrained High, levels up to 6.0.
|
||||
- The `steamos` user can open it (group video).
|
||||
- The panel's current refresh rate can be read without privileges through DRM: `/dev/dri/card0` is mode 0666, and
|
||||
GETCRTC reports e.g. `2*2160x2160_96` (clock 1402720 kHz / 4448 × 3285 = 96 Hz) even while the headset sleeps.
|
||||
The panel offers 72/80/90/96/108/120/144 Hz.
|
||||
- `/dev/video99` (v4l2loopback) has `max_buffers=2`: a reader asking for more gets 2.
|
||||
- Mid-stream keyframe requests (FORCE_KEY_FRAME) take effect on the next frame, and the GOP restarts from there.
|
||||
- Measured 2026-10-07 with the headset asleep (still picture):
|
||||
- `fp_venc` alone at 32/36 fps: 1% of a core at 1080p, 2.5% at 720p.
|
||||
- Live view end to end: `fp_venc` 2.6% + ffmpeg 8.4% (AAC encoding + muxing).
|
||||
- Conversion cost per new picture (self-test, NEON, 2026-10-07):
|
||||
- 1080p (no scaling): 0.6–1.0 ms.
|
||||
- 720p (exact 3:2 fast path): 1.3–1.65 ms, down from 5.6 ms with the generic box loop (~11 ms at idle clocks).
|
||||
- 360p (3:1 fast path): 0.7 ms.
|
||||
- 480p: 2.8 ms; its 852-px width doesn't repeat cleanly, so it uses the generic path.
|
||||
- At 36 fps with live content that is roughly 2–6% of a core.
|
||||
- ffmpeg with raw H.264 on a pipe:
|
||||
- `-framerate` is ignored.
|
||||
- `-fflags nobuffer` loses the first seconds of tiny frames.
|
||||
- Numbering frames from 0 (`setts`) with no input timestamps holds all output ~7 s next to pulse's audio.
|
||||
- Arrival stamps alone (`-use_wallclock_as_timestamps 1`) bunch frames that are read together: gaps of 0–10 ms
|
||||
and 45+ ms, seen in the headset test as dropped frames.
|
||||
- What works: `-probesize 32 -analyzeduration 0 -use_wallclock_as_timestamps 1` on the input (ffmpeg reads it in
|
||||
step with the audio), then `-bsf:v setts=ts=N*(1/fps)/TB` on the output (exactly even frames; audio still
|
||||
0–N s alongside), plus `frag_keyframe` so that a requested keyframe starts a fragment.
|
||||
- With sound, ffmpeg paces its inputs against each other and pulse's audio arrives later than the wall clock
|
||||
(more while something plays). The video input then counts as ahead, and ffmpeg stops reading it for up to
|
||||
0.7 s, so the writer blocks. That was the cause of 1080p dropping frames: busy 1080p replayed with sound took
|
||||
34–47 s for 20 s of video. Video alone was fine; `nice`, `-raw_packet_size` and the input queue size didn't
|
||||
matter. Shifting the video input back fixes it, but too far makes ffmpeg hold the video for interleaving and
|
||||
release it in clumps: -1 s gave output gaps of up to 550 ms, a longer and stuttering delay in the browser.
|
||||
-0.25 s is the measured sweet spot (no stalled writes at busy 1080p with sound, steady 50–150 ms output; -0.5 s
|
||||
already clumps). Output audio/video spans stay equal because setts sets the output times.
|
||||
- Browser delay (headless Chromium, 720p, 2026-10-07): muted about 0.2–0.35 s behind the newest data; with
|
||||
sound about 1 s. Chrome keeps about 0.6 s of audio ahead and stalls below that, whatever the player does:
|
||||
1.1× catch-up gave 8 stalls per 30 s, no speed-up 1–2, same average lag; 50 ms fragments didn't help. So the
|
||||
player doesn't speed up while sound is on.
|
||||
- Quality (owner's headset test, 2026-10-07): 3 Mbit/s CBR at 720p36 showed heavy compression artifacts. The
|
||||
hardware path now uses VBR with a 1.5× peak (the encoder accepts BITRATE_MODE VBR + BITRATE_PEAK) and higher
|
||||
targets: 360p 1.5, 480p 2.5, 720p 5, 1080p 8, Full 10 Mbit/s. The x264 fallback keeps its rates.
|
||||
- The default sink is SUSPENDED while nothing plays; its monitor still delivers (silent) audio.
|
||||
|
||||
## Text input
|
||||
|
||||
@@ -143,3 +242,26 @@
|
||||
one everywhere (FramePort's "Type on Frame", agent `_keyboard`).
|
||||
- Unity text fields close without a system keyboard; see `frame.unity_text_input` in PLAYBOOK.md.
|
||||
|
||||
|
||||
## Monitoring sources (probed 2026-10-07, SteamOS 0.4.3, kernel 6.18; used by the Monitor tab, agent `_monitor`)
|
||||
|
||||
All readable by the steamos user without root; the agent reads them directly (no programs started per sample).
|
||||
|
||||
| Metric | Source | Notes |
|
||||
|---|---|---|
|
||||
| CPU | `/proc/stat` deltas; `cpufreq/policy{0,2,5,7}` | 8 cores in 4 clusters: 0-1 / 2-4 / 5-6 / 7 (max 2.27 / 3.15 / 2.96 / 3.05 GHz) |
|
||||
| GPU busy | Sum of `drm-engine-gpu` (ns) deltas in `/proc/<pid>/fdinfo/<fd>` over every render-node fd (msm DRM) | Gives GPU % per process too. A process can hold several render fds: add them all. Lepton games see the node as `/dev/kgsl-3d0` (bind mount of `/dev/dri/renderD128`). `drm-total-memory` reads 0 |
|
||||
| GPU clock | `/sys/class/devfreq/3d00000.gpu/{cur,max}_freq` | 231–903 MHz in 12 steps |
|
||||
| Memory / pressure | `/proc/meminfo`; `/proc/pressure/{cpu,memory,io}` (`some avg10`) | 16 GB RAM, 8 GB swap |
|
||||
| Temperatures | `/sys/class/thermal/thermal_zone*/{type,temp}` | 48 zones: `cpu*`/`cpuss*`, `gpuss-*`, `ddr`, `nsph*` (NPU), `pm8550*`/`pm8010*` (power ICs), `modem*`, `camera*`, `video`, `max1720x_bat*` |
|
||||
| Fan | hwmon `slg4ax46073v` `fan1_input` | ~8200 rpm idle |
|
||||
| Power | hwmon `max34417_*` `power{1-4}_{label,input}` (µW) | `vph` = whole system (~3.6 W idle), `gfx` = GPU, `apc0/1/2` = CPU clusters, `nsp1/2` = NPU; each read is an I2C transfer (~0.7 ms wall), so only these are read |
|
||||
| Battery | `power_supply/max1720x_bat_7-36` | `current_now` (µA, negative = draining) × `voltage_now` (µV) = watts; `time_to_empty_now`/`time_to_full_now` (s), `cycle_count`, `health`, `temp` (0.1 °C) |
|
||||
| Game fps | `<base>/launch.log` lines `FrameBridge: pacing: N fps …` (every ~5 s) | Quest games only; SteamVR writes PC VR frame stats only as an end-of-session summary in `vrcompositor.txt` |
|
||||
| Game container | conmon `-n lepton-steamlaunch-<appid>`; its child's `/proc/<pid>/cgroup` → `cpu.stat`, `memory.current` | The container's ~90 Android processes show as uid 1000 on the host and can be signalled (4XVR, 2026-10-07); Android names them after the package's last 15 characters (`lus4xvrplayerov`), the full name is in `cmdline` |
|
||||
|
||||
Cost: a naive sample (fds of ~520 processes scanned) took 43 ms CPU. With kernel threads skipped after their first
|
||||
sighting, command lines checked once per process, render fds cached (rescanned every 60 s, every 4 s for busy young
|
||||
game processes without one), temperatures every 2 s, the CPU-cluster power rails every 5 s and the battery gauge every
|
||||
2-10 s, the stream measured ~10-13 ms CPU per 1 s tick on the device (idle clocks; idle or with 4XVR running) = about
|
||||
1 % of one core, ~0.15 % of the whole CPU. The I2C sensors (power monitors, battery gauge) are the slowest reads.
|
||||
@@ -1,6 +1,6 @@
|
||||
# Tested games
|
||||
|
||||
Games tested on the Steam Frame with FramePort's recipes. Games not listed here may work too: FramePort suggests patches for them, and a working config can be shared from the app (**Share working config…**).
|
||||
Games tested on the Steam Frame with FramePort's recipes. Games not listed here may work too: FramePort suggests patches for them, and a working recipe can be shared from the app (**Share working recipe…**).
|
||||
Tested a game? [Share a working config](https://github.com/spoopyghosty0/frameport/issues/new?template=working-config.yml) or [report a problem](https://github.com/spoopyghosty0/frameport/issues/new?template=bug-report.yml) (in the app: the game's **…** menu does both and fills in the details).
|
||||
Generated from [catalog/games](../catalog/games) by `scripts/compat_list.py`.
|
||||
|
||||
@@ -8,6 +8,7 @@ Generated from [catalog/games](../catalog/games) by `scripts/compat_list.py`.
|
||||
|---|---|---|---|
|
||||
| 4XVR Video Player | Quest | ✅ Works | |
|
||||
| Accounting+ | Quest | ✅ Works | |
|
||||
| AgeOfJoy | Quest | ✅ Works | |
|
||||
| AllInOneSports | Quest | ✅ Works | |
|
||||
| Asgard's Wrath 2 | Quest | ✅ Works | |
|
||||
| BAM | Quest | ✅ Works | |
|
||||
@@ -20,6 +21,7 @@ Generated from [catalog/games](../catalog/games) by `scripts/compat_list.py`.
|
||||
| Beat Saber (co-existence build) | Quest | ✅ Works | |
|
||||
| Blade & Sorcery: Nomad | Quest | ✅ Works | |
|
||||
| BodyCombat | Quest | ✅ Works | |
|
||||
| BONELAB | Quest | ✅ Works | |
|
||||
| Carve Snowboarding | Quest | ✅ Works | |
|
||||
| Cook-Out | Quest | ✅ Works | |
|
||||
| Creed | Quest | ✅ Works | |
|
||||
@@ -27,13 +29,16 @@ Generated from [catalog/games](../catalog/games) by `scripts/compat_list.py`.
|
||||
| Dinosaur Island | Quest | ✅ Works | |
|
||||
| Espire 2 | Quest | ✅ Works | |
|
||||
| Genotype | Quest | ✅ Works | |
|
||||
| GORN2 | Quest | ✅ Works | |
|
||||
| H.U.N.T | Quest | ✅ Works | |
|
||||
| I Am Cat | Quest | ✅ Works | |
|
||||
| I Am Monkey | Quest | ✅ Works | |
|
||||
| In Death: Unchained | Quest | ✅ Works | |
|
||||
| Into The Radius 2 | Quest | ✅ Works | |
|
||||
| Job Simulator | Quest | ✅ Works | |
|
||||
| Jurassic World Aftermath Collection | Quest | ✅ Works | |
|
||||
| Keep Talking and Nobody Explodes | Quest | ✅ Works | |
|
||||
| Lambda1VR | Quest | ✅ Works | |
|
||||
| LEGO® Bricktales | Quest | ✅ Works | |
|
||||
| Lucky's Tale | Quest | ✅ Works | |
|
||||
| Marvel's Deadpool VR | Quest | ✅ Works | |
|
||||
@@ -46,28 +51,37 @@ Generated from [catalog/games](../catalog/games) by `scripts/compat_list.py`.
|
||||
| NOPE CHALLENGE | Quest | ✅ Works | |
|
||||
| palazzo_santacruz | Quest | ✅ Works | |
|
||||
| Path of the Warrior | Quest | ✅ Works | |
|
||||
| Pistol Whip | Quest | ✅ Works | |
|
||||
| PowerWash Simulator VR | Quest | ✅ Works | |
|
||||
| QuestCraft | Quest | ✅ Works | |
|
||||
| Retronika | Quest | ✅ Works | |
|
||||
| Richie's Plank Experience | Quest | ✅ Works | |
|
||||
| Rick and Morty: Virtual Rick-ality | PC VR | ✅ Works | |
|
||||
| Riven | Quest | ✅ Works | |
|
||||
| Robo Recall | Quest | ✅ Works | |
|
||||
| RUINSMAGUS | Quest | ✅ Works | |
|
||||
| Sniper Elite VR | Quest | ✅ Works | |
|
||||
| Sniper Elite VR: Winter Warrior | Quest | ✅ Works | |
|
||||
| Space Pirate Trainer Quest | Quest | ✅ Works | |
|
||||
| Star Wars Pinball VR | Quest | ✅ Works | |
|
||||
| Stremio | Quest | ✅ Works | |
|
||||
| SUPERHOT VR | PC VR | ✅ Works | |
|
||||
| SUPERHOT VR | Quest | ✅ Works | |
|
||||
| TetrisEffect | Quest | ✅ Works | |
|
||||
| The Boys VR | Quest | ✅ Works | |
|
||||
| The Climb 2 | Quest | ✅ Works | |
|
||||
| The Room VR | Quest | ✅ Works | |
|
||||
| Time Crisis VR (Experimental) | Quest | ✅ Works | |
|
||||
| Toy Master | Quest | ✅ Works | |
|
||||
| Under Cover | Quest | ✅ Works | |
|
||||
| VR HOT Quest | Quest | ✅ Works | |
|
||||
| VR4 | Quest | ✅ Works | |
|
||||
| Wallace & Gromit in The Grand Getaway | Quest | ✅ Works | |
|
||||
| Waltz of the Wizard: Extended Edition | Quest | ✅ Works | |
|
||||
| Wander | Quest | ✅ Works | |
|
||||
| Arcsmith | Quest | ⚠️ Works with issues | Right eye distorts during movement (unresolved; swap, tracking, Valve layers, depth and pacing ruled out). |
|
||||
| Assassin's Creed Nexus | Quest | ⚠️ Works with issues | Some launch warning text is still upside down; the rest of the UI is fixed by flip emulation. |
|
||||
| BONELAB | Quest | ⚠️ Works with issues | Build 1.2068 plays (head tracking and controls work with frame.unity_user_presence); the newer build 1.2974 crashes at start (Vulkan), no fix yet. |
|
||||
| Doom3Quest | Quest | ⚠️ Works with issues | PDA shows black screen. |
|
||||
| Myst | Quest | ⚠️ Works with issues | Minor graphical glitches on some objects. |
|
||||
| Phantom: Covert Ops | Quest | ⚠️ Works with issues | DLC/store button crashes (no Meta store). |
|
||||
| Pinball FX VR | Quest | ⚠️ Works with issues | Plays; mixed reality mode not working yet. |
|
||||
@@ -75,10 +89,10 @@ Generated from [catalog/games](../catalog/games) by `scripts/compat_list.py`.
|
||||
| Time Stall | Quest | ⚠️ Works with issues | Both eyes distort during movement (unresolved). |
|
||||
| Vader Immortal: Episode I | Quest | ⚠️ Works with issues | Starts in VR and plays the intro, then stays on the loading card (Vader's portrait with a progress bar). |
|
||||
| WiiCompiled VR | Quest | ⚠️ Works with issues | To add a game: in FramePort's Files tab, upload your .wcgame file to this game's storage, folder Android/data/org.wiicompiled.quest/files/WiiCompiledOpenXRVR… |
|
||||
| BlazeRush | Quest | ❌ Doesn't run | Starts and reaches the menu room, but the room shows no controllers and ignores all input (it all reaches the game); no fix yet. |
|
||||
| Espire 1: VR Operative (Quest Edition) | Quest | ❌ Doesn't run | Mesa GL driver crash during texture upload. |
|
||||
| HITMAN 3 VR: Reloaded | Quest | ❌ Doesn't run | Vulkan driver crash (freedreno), even without Valve layers. |
|
||||
| Journey of the Gods | Quest | ❌ Doesn't run | 32-bit only; the Frame has no AArch32. |
|
||||
| Roblox | Quest | ❌ Doesn't run | Crashes on its first VR frame on the Frame. |
|
||||
| Shadow Point | Quest | ❌ Doesn't run | 32-bit only; the Frame has no AArch32. |
|
||||
| Sniper Elite VR | Quest | ❌ Doesn't run | GPU hang (zink: DEVICE LOST) even with MSAA off. |
|
||||
| Sports Scramble (Santa Cruz) | Quest | ❌ Doesn't run | 32-bit only; the Frame has no AArch32. |
|
||||
@@ -1,5 +1,10 @@
|
||||
# Installing FramePort
|
||||
|
||||
▶ **[Watch the install tutorial](media/frameport-install.mp4)** (about 90 seconds, MP4; also attached to every
|
||||
release as `FramePort-install.mp4`): from the download to the first game on the Frame.
|
||||
|
||||
[](media/frameport-install.mp4)
|
||||
|
||||
Download the archive for your computer from the [latest release](https://github.com/spoopyghosty0/frameport/releases/latest)
|
||||
and extract it anywhere. No installer or admin rights are needed. On first start FramePort downloads its Java
|
||||
runtime, the OVRPort CLI and apksigner into its data folder (Settings → Tools shows them).
|
||||
@@ -85,13 +90,51 @@ which would end Desktop Mode). This is new: please report anything odd with **Re
|
||||
- If the Frame goes to sleep, turns off or leaves the Wi-Fi, the queue **waits** and continues once it's back; uploads
|
||||
pick up where they stopped. While installs run, FramePort keeps the Frame from going to sleep. Before a large batch
|
||||
it checks the Frame has enough free space.
|
||||
- **microSD card / other drives:** the **Steam Frame** page's **Storage** section lists the Frame's drives and sets
|
||||
where new games go (**Install new games to**). Games go into a `FramePort` folder on the card. To move a game that's
|
||||
installed already, right-click it → **Move to…** (the game must be closed; saves, settings and the Steam entry stay).
|
||||
A game on the card only starts while the card is inserted (FramePort then says "SD Card not inserted"). Cards
|
||||
formatted as FAT, exFAT or NTFS can't hold games: format the card in SteamOS first.
|
||||
- Your own game files are never changed. The converted copy is temporary: it's removed once the game is on the Frame
|
||||
(Settings → Installing: keep them, or remove all now).
|
||||
- **Game settings…** (game menu or the Steam Frame page): sharpness, refresh rate, controllers, menus, 360° video and
|
||||
mixed-reality options in plain words, only those that matter for the game. Changes are kept with the game and,
|
||||
when it's installed, used the next time it starts.
|
||||
- Ordinary Android apps (no VR) are installed unchanged and shown as a flat window in the headset. Android's
|
||||
back/home/recents buttons are hidden by default (patch **Hide Android's navigation bar**).
|
||||
back/home/recents buttons are hidden by default (patch **Hide Android's navigation bar**). If FramePort guesses
|
||||
wrong (a phone app shows nothing in the headset, or a VR app opens as a flat window), choose **VR** or **Flat
|
||||
window** under **Show as VR or as a flat window** in the game's **Customize** section, then **Update on Frame**.
|
||||
- **Add games → Add a Windows program…** adds a single Windows program; the Frame runs it through Proton (as a
|
||||
window unless it is a VR game). A program sitting in Downloads, the home folder or a drive root is copied on its
|
||||
own first, so the install doesn't upload everything next to it.
|
||||
- In the packaged app you can also **drag files onto the Library**: APKs, Linux apps (AppImage, `.zip`/`.tar.gz`),
|
||||
Windows programs (`.exe`), folders, or a FrameDrop manifest (`.json`).
|
||||
|
||||
### Install links ("Install with FrameDrop" buttons)
|
||||
|
||||
Some developers put an **Install with FrameDrop** button on their site (the one-click protocol of the FrameDrop
|
||||
sideloader, documented at framedropvr.com/docs). FramePort understands the same links:
|
||||
|
||||
- **Clicking a button** opens FramePort (or the window that's already open) on Windows and Linux. FramePort shows
|
||||
the title, the files, their size and whether a checksum is given, and asks before it downloads anything. Then it
|
||||
downloads the build, adds it to your library and starts the usual install on the Frame. If no Frame is connected,
|
||||
the game is added now and installs once the Frame is back.
|
||||
- **Add games → Add from a link…** takes the button's address (right-click → Copy link), a `framedrop://` or
|
||||
`frameport://` link, a manifest (`.json`) or a direct link to an APK, a Linux build or a Windows program. Use it on
|
||||
macOS, where web pages can't hand links to FramePort yet.
|
||||
- **Settings → Install links** has one switch for `framedrop://` links (the buttons) and one for FramePort's own
|
||||
`frameport://` links. Both are on by default. If FrameDrop is installed too and already opens `framedrop://`
|
||||
links, FramePort leaves them to it; **Use FramePort for these links** takes them over (turn the switch off to give
|
||||
them back).
|
||||
- **For developers:** a FrameDrop manifest works as it is
|
||||
(`{"schema": "framedrop.install/v1", "name": "…", "files": [{"url": "https://…", "sha256": "…"}]}`). FramePort
|
||||
also reads an optional `"frameport": {"description": "…", "icon": "https://….png"}` object (FrameDrop ignores
|
||||
it): the install question then shows the icon and description, and they become the game's icon and "About this
|
||||
game" text when no store has them. For your page there's an "Install with FramePort" button:
|
||||
[INSTALL_BUTTON.md](INSTALL_BUTTON.md). Without a manifest (a bare file link) FramePort guesses the title from the
|
||||
file name and replaces it with the app's own name once it's downloaded.
|
||||
- Only `https://` links to public servers are used (plain `http://` only on this PC, for testing); links with a
|
||||
user name or password, or pointing into your local network, are refused. Only install from sites you trust.
|
||||
|
||||

|
||||
|
||||
@@ -102,10 +145,10 @@ reality), showing only what matters for that game. Changes are kept with the gam
|
||||
|
||||
## Typing on the Frame
|
||||
|
||||
- **Type on Frame** (Steam Frame page, a game's menu, or the keyboard icon on the sidebar's Frame card): while the
|
||||
window is open, this computer's keyboard works as a keyboard plugged into the Frame. Select a text field in the
|
||||
headset (in an app, Steam or the desktop) and type; Esc and shortcuts go to the Frame too. Paste longer text into
|
||||
the box to type it in one go (US keyboard layout). Click **Done** to disconnect.
|
||||
- **Type on Frame** (its own tab in the sidebar; also on the Steam Frame page): while the tab is
|
||||
open, this computer's keyboard works as a keyboard plugged into the Frame. Select a text field in the headset (in
|
||||
an app, Steam or the desktop) and type; Esc and shortcuts go to the Frame too. Paste longer text into the box to
|
||||
type it in one go (US keyboard layout). Opening another tab disconnects the keyboard.
|
||||
- **Steam's on-screen keyboard** opens for text fields of apps shown as a window (2D apps, and VR apps with
|
||||
**Show the app's Android window**). Steam lists that window as **Gamescope** (the Frame's display compositor);
|
||||
leave it open: it's what receives the typing, the VR view isn't affected.
|
||||
@@ -113,6 +156,19 @@ reality), showing only what matters for that game. Changes are kept with the gam
|
||||
**Make Unity text fields work** for them. The first time, it downloads Cpp2IL (a tool that finds the right spot in the
|
||||
game's code, ~17 MB). Games added before this version: open the game's menu → **Analyze again**, then reinstall.
|
||||
|
||||
## Watching the Frame (Monitor)
|
||||
|
||||
- **Monitor** (its own tab in the sidebar) shows live what the Frame is doing while the tab is open: the running game
|
||||
with its frame rate (Quest games), CPU, graphics chip, memory, the hottest temperature with the fan speed, power
|
||||
draw and battery time left, each with a 2-minute chart. **Show details** adds every CPU core, all temperature
|
||||
sensors, where the power goes and the network.
|
||||
- **Processes**: **Game** (default) lists the running game's processes, **Steam & SteamVR** and **All** show more.
|
||||
Right-click a process (or use **⋯**) to end it, force-kill it or end its whole game; **End game** on the game card
|
||||
closes the game the way Steam's Exit game does. A lock marks programs whose end would close Steam, SteamVR or the
|
||||
desktop: FramePort asks again before ending those.
|
||||
- The numbers come every second (or every 2/5 s) and cost the Frame about 1 % of one CPU core; nothing keeps
|
||||
running on the Frame after you leave the tab.
|
||||
|
||||
## Updating
|
||||
|
||||
**Game configs** (the tested recipes in the catalog) update by themselves: FramePort checks GitHub every 6 hours for
|
||||
@@ -140,7 +196,7 @@ Command line: `frameport update` (`--check` only checks, exit code 10 = update a
|
||||
## PC VR games
|
||||
|
||||
PC VR games are Windows VR games (OpenXR, SteamVR or Oculus). Scan a folder of them (one folder per game) or use
|
||||
**Add games → Add one game folder…**. FramePort finds the game's program and asks when there is more than one
|
||||
**Add games → Add a PC game folder…**. FramePort finds the game's program and asks when there is more than one
|
||||
candidate. **Already patched** on a game page installs a copy unchanged. Oculus-only games need Revive: FramePort uses
|
||||
an installed Revive, or downloads a portable copy.
|
||||
|
||||
@@ -151,23 +207,30 @@ an installed Revive, or downloads a portable copy.
|
||||
on the game page.
|
||||
- Games that use the Oculus Platform SDK check the licence through the Oculus app, so they run on the PC only.
|
||||
|
||||
**Windows games without VR:** **Add games → Add one game folder…** with the game's folder (pick the program that
|
||||
**Windows games without VR:** **Add games → Add a PC game folder…** with the game's folder (pick the program that
|
||||
starts it if asked). FramePort installs it on the Frame and Proton runs it as a window, like Steam's own Windows games;
|
||||
it shows up in the Frame's Steam library tagged "Windows game on Frame". Whether a game runs depends on Proton on ARM
|
||||
(x86 games run through emulation).
|
||||
|
||||
## Linux apps (arm64)
|
||||
## Linux apps
|
||||
|
||||
The Frame runs SteamOS on an arm64 CPU, so native Linux apps built for **aarch64/arm64** run on it directly (no
|
||||
Android container, no Proton). **Add games → Add a Linux app (arm64)…** takes an AppImage or a `.zip`/`.tar.gz`/
|
||||
Android container, no Proton). **Add games → Add a Linux app…** takes an AppImage or a `.zip`/`.tar.gz`/
|
||||
`.tar.xz` archive; **Add a Linux app folder…** takes an unpacked app. FramePort finds the program that starts it (the
|
||||
game page's **Change…** picks another one) and whether it's a VR (OpenXR) app. **Install on Frame** uploads it
|
||||
unchanged and adds it to the Frame's Steam library, tagged "Linux app on Frame"; Play, launch tests and Uninstall
|
||||
work like for other games.
|
||||
|
||||
- x86_64 builds can't run on the Frame: FramePort says so when you add one. Look for an aarch64/arm64 download.
|
||||
- The app must bring the libraries SteamOS doesn't have. If some are missing, the install reports them and the game
|
||||
- **x86_64 builds** run through **FEX**, Valve's x86 translator, with the x86 system libraries SteamOS ships for it
|
||||
(the way Steam on the Frame runs x86 Linux games). The first install of one installs FEX on the Frame (Steam
|
||||
restarts once and downloads it, a few MB). They run slower than arm64 builds: when an app offers both, FramePort picks the arm64 one. The game
|
||||
page shows which CPU a build is for.
|
||||
- The app must bring the libraries SteamOS doesn't have (checked for arm64 builds; x86_64 builds use FEX's x86
|
||||
system, which has glibc and Mesa, and aren't checked ahead). If some are missing, the install reports them and the game
|
||||
page lists them: look for a build that includes them.
|
||||
- **Desktop Mode:** Linux apps also appear in Desktop Mode's application menu and as an icon on its desktop. Some
|
||||
apps work better there, with a mouse and keyboard, than in Gaming Mode (where Steam Input turns the controllers into
|
||||
a gamepad). Switch it off per app on the game page (**Desktop Mode**).
|
||||
- From the command line: `frameport add-linux <AppImage, folder or archive> [--exe <program>]`.
|
||||
|
||||
## Files on the Frame (videos, documents, mods, saves)
|
||||
@@ -192,7 +255,7 @@ Command line: `frameport frame send <files> --dest videos` (`frameport frame sto
|
||||
|
||||
## Sharing a working game, reporting a problem
|
||||
|
||||
- **Share working config…** (game menu): opens a prefilled GitHub issue with the game's patches and settings. Accepted
|
||||
- **Share working recipe…** (game menu): opens a prefilled GitHub issue with the game's patches and settings. Accepted
|
||||
configs become built-in recipes. Untested games ask on their page once they've been installed or tested: **It
|
||||
works**, **It has issues** or **It doesn't run**.
|
||||
- **Report a problem…** (game menu, or Settings → Problems and feedback): saves a diagnostics zip to Documents (logs,
|
||||
@@ -207,12 +270,14 @@ and `frameport <command> --help` describe every option. The main ones:
|
||||
| Command | What it does |
|
||||
|---|---|
|
||||
| `scan <folder>` / `list` / `show <game>` | add games, list the library, show a game's analysis and patches |
|
||||
| `add-linux <path>` | add an arm64 Linux app (AppImage, folder or archive) |
|
||||
| `add-linux <path>` | add a Linux app, arm64 or x86_64 (AppImage, folder or archive) |
|
||||
| `recipe <game> --enable/--disable <patch>` | change a game's patches (`patches` lists them all) |
|
||||
| `build <game>` / `install <game>` / `test <game>` | build, install on the Frame (`--to pc` for PC VR on this PC), launch test |
|
||||
| `frame discover` / `frame connect` / `frame info` | find, pair with and describe the Frame |
|
||||
| `frame send` / `frame storage` / `frame cleanup` | copy files to the Frame, show where they go, free space |
|
||||
| `frame drives` / `frame move <game> --to <drive>` / `install --dest <drive>` | the Frame's drives (microSD), move a game, install to a drive |
|
||||
| `tools status` / `tools install` | the tools FramePort downloads |
|
||||
| `open-link "<link>"` | install from an "Install with FrameDrop" button's address or a manifest/APK/zip link (`--yes`, `--no-install`) |
|
||||
| `diag report <game>` / `share-recipe <game>` | report a problem / share a working recipe |
|
||||
| `update` | update FramePort |
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# "Install with FramePort" button
|
||||
|
||||
A button for web pages and READMEs that opens a game straight in FramePort. Clicking it hands FramePort an install
|
||||
link; FramePort shows what it would download and asks before it does anything (see
|
||||
[Install links](INSTALL.md#install-links-install-with-framedrop-buttons)).
|
||||
|
||||
<p>
|
||||
<img src="badges/install-with-frameport-animated.svg" alt="Install with FramePort" width="216" height="60">
|
||||
</p>
|
||||
|
||||
## Files
|
||||
|
||||
All files are in [`docs/badges/`](badges/). Each SVG is self-contained (no external fonts or images), 216 × 60.
|
||||
|
||||
| File | Use it for |
|
||||
|---|---|
|
||||
| [`install-with-frameport.svg`](badges/install-with-frameport.svg) | Everywhere. No motion. |
|
||||
| [`install-with-frameport-animated.svg`](badges/install-with-frameport-animated.svg) | GitHub READMEs and other pages that only allow images. The glow plays by itself every 6 seconds: blue swells from the left, the portal between "Frame" and "Port" flares, then orange swells on the right. |
|
||||
| [`install-with-frameport-hover.svg`](badges/install-with-frameport-hover.svg) | Websites where you can paste HTML. The glow brightens and the middle portal lights up while the pointer is on the button. It only reacts to the mouse when the SVG code is placed in the page itself (see below). |
|
||||
| [`install-with-frameport@2x.png`](badges/install-with-frameport@2x.png) | Places without SVG support (some forums, email). 432 × 120; show it at 216 × 60. |
|
||||
|
||||
Both animated versions stop moving for visitors who turn on reduced motion in their system settings.
|
||||
|
||||
## The link
|
||||
|
||||
The button links to an install link, which names either a manifest or one file:
|
||||
|
||||
```
|
||||
frameport://install?manifest=<URL-encoded https address of a manifest .json>
|
||||
frameport://install?url=<URL-encoded https address of an .apk, a Linux build (.zip, .tar.*, .AppImage) or a Windows .exe>
|
||||
```
|
||||
|
||||
The manifest is the FrameDrop format, which FramePort reads as it is:
|
||||
|
||||
```json
|
||||
{
|
||||
"schema": "framedrop.install/v1",
|
||||
"name": "My Game",
|
||||
"files": [{ "url": "https://example.com/my-game.apk", "sha256": "<64 hex digits>" }],
|
||||
"frameport": { "description": "One sentence about the game.", "icon": "https://example.com/icon.png" }
|
||||
}
|
||||
```
|
||||
|
||||
`name` becomes the game's title in Steam. `sha256` is optional but recommended: FramePort checks the download
|
||||
against it. The `frameport` object is optional and ignored by FrameDrop; its icon and description are shown in the
|
||||
install question. Only public `https://` addresses are accepted.
|
||||
|
||||
To build a link from Python: `frameport.deeplink.make_link(manifest_url="https://…/my-game.json")`.
|
||||
|
||||
## On a website
|
||||
|
||||
Image version (any page):
|
||||
|
||||
```html
|
||||
<a href="frameport://install?manifest=https%3A%2F%2Fexample.com%2Fmy-game.json">
|
||||
<img src="install-with-frameport.svg" alt="Install with FramePort" width="216" height="60">
|
||||
</a>
|
||||
```
|
||||
|
||||
Hover version: paste the contents of `install-with-frameport-hover.svg` inside the link instead of the `<img>`, and
|
||||
give the link an accessible name:
|
||||
|
||||
```html
|
||||
<a href="frameport://install?manifest=https%3A%2F%2Fexample.com%2Fmy-game.json" aria-label="Install with FramePort">
|
||||
<svg …>…</svg> <!-- the whole file -->
|
||||
</a>
|
||||
```
|
||||
|
||||
Host the files yourself, or load them from jsDelivr, which serves them with the right content type:
|
||||
`https://cdn.jsdelivr.net/gh/spoopyghosty0/frameport@main/docs/badges/install-with-frameport.svg` (replace `main`
|
||||
with a release tag such as `v0.12.0` to pin a version; jsDelivr caches `@main` for up to 12 hours).
|
||||
|
||||
## In a GitHub README
|
||||
|
||||
GitHub removes links that don't start with `https://` or `http://` from READMEs, so a `frameport://` link there is
|
||||
not clickable. Link the button to an `https://` page instead, for example your release page with instructions, or
|
||||
FrameDrop's install page, which opens `framedrop://` links (FramePort opens those too while Settings → Install links
|
||||
→ `framedrop://` is on):
|
||||
|
||||
```markdown
|
||||
[](https://framedropvr.com/install?manifest=https%3A%2F%2Fexample.com%2Fmy-game.json)
|
||||
```
|
||||
|
||||
Use the animated or still SVG; the hover version doesn't react inside a README, because GitHub shows SVGs as
|
||||
images.
|
||||
|
||||
## If a visitor doesn't have FramePort
|
||||
|
||||
A `frameport://` link does nothing visible (or shows the browser's "no app for this link" message) when FramePort
|
||||
isn't installed. Put a line next to the button such as "Needs [FramePort](https://github.com/spoopyghosty0/frameport)
|
||||
on Windows or Linux." On macOS, web pages can't hand links to FramePort yet: users paste the link into Add games →
|
||||
Add from a link….
|
||||
|
||||
## Usage rules
|
||||
|
||||
- Keep the alt text "Install with FramePort".
|
||||
- Don't recolor, stretch, crop or redraw the button, and don't show it smaller than 40 px tall.
|
||||
- Leave some space around it (at least 8 px) so it doesn't touch other buttons.
|
||||
- It works on light and dark pages as it is; there is no light version.
|
||||
@@ -13,6 +13,7 @@ version is `catalog/triage.yaml` (used by `frameport test` / the Job screen); ke
|
||||
## Startup failures (visible in launch.log)
|
||||
| Symptom | Cause | Fix |
|
||||
|---|---|---|
|
||||
| A launch test suggests a fix (e.g. triage `sdl-no-clipboard` → `frame.sdl_clipboard`) but the game page doesn't show it / lists it as not applicable; or a game added long ago lacks warnings newer ones get (Android version, web wrapper, missing OBB) (GitHub #104, Dramatic Shape) | the library entry was analysed by an older FramePort: the analysis field the patch reads (`sdl_java`, `min_sdk`, `web_wrapper`, `expects_obb`, …) is missing, so `applies()` is false | entries whose `analysis.extra.analysis_version` is below `detect.ANALYSIS_VERSION` are analysed again at the GUI's start (background) and before a build (`pipeline.refresh_analyses`); by hand: game menu → "Analyze again", then Update on Frame. An unreadable APK is marked `analysis_failed` (retried after the next version bump). Adding an analysis field: bump `ANALYSIS_VERSION` |
|
||||
| One eye (usually the right) shimmers or jitters in the 3D view while menus and panels look steady; pacing is clean (GitHub #69, e.g. RTCWQuest, Moss) | Valve's eye-tracked foveation layer (`VALVE_fdm_injection`) moves its low-density regions with each eye's gaze, and the right eye's gaze filter restarts often (`CEyePoseUKF R: Large dt … Bootstrapped` in `~/.local/share/Steam/logs/eyetracking.txt`) | Customize → "Eye-tracked foveation (Valve)" (`device.foveation`): **Fixed** (`FDM_DEBUG=disable_offsets`, keeps the GPU saving) or **Off** (`VK_INSTANCE_LAYERS=""`); catalog field `foveation:` |
|
||||
| A Unity OpenXR game closes right after the OpenXR instance is created: `F VrApiLoader: vrapi_SetPropertyInt was called before vrapi_Initialize()!`, SIGABRT on UnityMain (GitHub #62, Jurassic World Aftermath) | the APK still ships Meta's VrApi loader; OVRPlugin (1.89, on OpenXR) calls it without starting VrApi and Meta's loader aborts. The VrApi bridge can't replace it (39 of the loader's 114 functions: OVRPlugin wouldn't link) | `frame.vrapi_stub` (same exports, each returns 0); triage `vrapi-before-init` |
|
||||
| A VrApi game exits at once: `UnsatisfiedLinkError … dlopen failed: cannot locate symbol "vrapi_PollEvent"` (GitHub #57, BlazeRush) | the engine imports a VrApi function the VrApi bridge didn't implement | the bridge has `vrapi_PollEvent`, `RecenterPose`, `SetDisplayRefreshRate`, `GetSystemPropertyFloatArray` (rebuild the game); the static check "VrApi functions resolvable" names any other missing one; triage `vrapi-symbol-missing` |
|
||||
@@ -21,7 +22,11 @@ version is `catalog/triage.yaml` (used by `frameport test` / the Job screen); ke
|
||||
| `cannot locate symbol "ovrPeerConnectionState_ToString"` (or another `ovr<Enum>_ToString`) at start (BlazeRush, GitHub #57) | OVRPort's platform loader lacks several Platform SDK enum helpers | `frame.ovrstubs` now stubs them too; `*_ToString` stubs return "" (not NULL) |
|
||||
| Exits right after the OpenXR instance is created: `Failed to create XR session: -50` (`XR_ERROR_GRAPHICS_REQUIREMENTS_CALL_MISSING`, Lambda1VR) | the game skips `xrGet*GraphicsRequirementsKHR`; Meta's runtime tolerates it, SteamVR's doesn't. Lambda1VR's TBXR doesn't even enable `XR_KHR_opengl_es_enable` (only `XR_EXT_local_floor`) | FrameBridge adds `XR_KHR_opengl_es_enable` when an app enables no graphics API extension, asks for the requirements on the game's behalf and retries xrCreateSession once (logs `added XR_KHR_opengl_es_enable …`, `the app skipped …; asked for it`; every launch logs the final extension list `xrCreateInstance with N extension(s)`); triage `graphics-requirements-missing`. Verified headless: Lambda1VR runs at 72 fps |
|
||||
| Exits at start: `OVRAvatar-Loader: DisplayErrorAndExit: Failed to launch SystemActivities` after `ovrAvatar_Initialize: Failed to load AvatarSDK driver` (BlazeRush, GitHub #57) | Meta's avatar loader needs Horizon; it then tries Meta's error screen and aborts | `frame.avatar_stub` (same exports, do nothing); triage `avatar-driver-missing`. Games that ship the library but don't start avatars at launch (Lucky's Tale, BattleSisters, Arcsmith) don't need it |
|
||||
| Frame freezes or the game is killed (OOM) on the first controller vibration (e.g. Lucky's Tale's save slots, BattleSisters, Sniper Elite VR's tutorial grab: memory grows ~1 GB/s until the kill) | OVRPort runtimes up to 3.4.3-23204ea read the haptic envelope's duration (ns) as seconds and allocate gigabytes of samples (GitHub #9, ovrport/app#73); also reached from Unity's legacy `ovrp_SetControllerHaptics`; perf page faults all in `libopenxr_loader.so` `xrApplyHapticFeedback` | `adapter.haptic_fix` (envelope → one plain vibration in `native/xrshim`; PCM vibrations (`XrHapticPcmVibrationFB`) are converted the same way). Fixed in runtime 3.4.3-aa54c3f: builds made with it leave the workaround out by themselves (log "not needed: adapter.haptic_fix", `frameport show` "last build left out"); rebuild an older build to switch |
|
||||
| Controller vibrations much stronger than on a Quest (The Boys VR, Jurassic World, BONELAB, …) | OVRPlugin games send amplitude envelopes; `haptic_fix` turned each into one vibration at the envelope's *peak* for its whole duration (a short fading pulse became a long full-strength buzz) | `haptic_fix` now uses the envelope's RMS; Game settings → "Vibration strength" (`haptic_scale`, 0-1) scales every vibration in FrameBridge; launch.log shows the first requests (`haptic: …`). OVRPlugin stops a vibration with amplitude 0 (2 s duration): FrameBridge turns that into xrStopHapticFeedback (without it the last buzz ran its full 2 s) |
|
||||
| Play or a launch test fails at once: `Game files missing at <path> (storage not mounted?)` in launch.log, or "… files are on a drive that isn't inserted" (GitHub #90) | the game was installed or moved to a microSD card (`<mount>/FramePort/<pkg>`) that isn't inserted or mounted now | insert the card; or move the game back (game menu → Move to…, `frameport frame move <pkg> --to internal`) once the card is back. `frameport frame drives` shows what the agent sees (exFAT/NTFS cards are refused: format in SteamOS) |
|
||||
| A Linux app started from Desktop Mode's menu closes after ~2 s, or opens on the wrong display (GitHub #84) | its launcher predates agent v63: the "Steam parent gone" watchdog ended it when Plasma's launcher exited, and it took gamescope's DISPLAY from Steam | connect FramePort once (agent v63's `upgrade_launchers` adds the `FRAMEPORT_DESKTOP` checks; the menu entry runs `env FRAMEPORT_DESKTOP=1 <anchor>/launch.sh`). Game Mode controller problems in such apps are Steam Input's (a separate issue) |
|
||||
| A Linux app (AppImage) shows no/FramePort's placeholder icon in Desktop Mode or Steam (GitHub #99) | before agent v64 only FramePort's art set's icon was used, and a lone AppImage has no store art | connect FramePort once (agent v64 copies the app's `.DirIcon` / `.desktop` `Icon=` to `<anchor>/artwork/app-icon.*` and refreshes the menu entry); reinstall to also get it into the library + Steam shortcut. Still the placeholder: check `<base>/app/squashfs-root/.DirIcon` and the `.desktop` file's `Icon=` (an icon outside the app folder or only an XPM isn't used); a chosen icon (`artwork/.icon-source` = `custom`) always wins |
|
||||
| Every game suddenly fails to start: `crun: create keyring …: Disk quota exceeded`, `is not a running context` | rootless podman leaked a kernel keyring per launch; 200-key quota exhausted | `keyring = false` in `~/.config/containers/containers.conf` (FramePort agent does it), then reboot the Frame once |
|
||||
| A Unity app's text field shows a caret for a moment and loses focus; no keyboard appears (e.g. Stremio VR login) | Unity's TMP_InputField/InputField wait for Android's on-screen keyboard and close themselves without one (Lepton has none); headless VR apps also have no focused Android window, so no key press reaches them | `frame.unity_text_input` (Cpp2IL finds `TouchScreenKeyboardShouldBeUsed`/`isKeyboardUsingEvents`, rewritten to false/true) + `device.text_input_window` (lepton-show-flatscreen: Steam's keyboard and Type on Frame work) |
|
||||
| Play gives Steam's "Game configuration unavailable"; Steam's console_log: `GameAction [AppID <id>] … RequestingLicense → UpdatingAppInfo → LaunchApp failed with AppError_9` | this Frame's Steam never loaded FramePort's shortcuts.vdf entry (it treats the id as a store app); cause unknown (GitHub #21/#30) | automatic since agent v43: Play registers the game through Steam's devkit interface ("Devkit Game: …", `devkit_register`) and starts that; uninstall removes it. Agent v58: a devkit entry Steam forgot after a restart is added again live on Play (no NOT_IN_LIBRARY → no Steam restart), and installs/art updates of devkit games only copy art (no Steam restart, GitHub #41) |
|
||||
@@ -29,6 +34,7 @@ version is `catalog/triage.yaml` (used by `frameport test` / the Job screen); ke
|
||||
| Black screen at start while audio/ExoPlayer runs; log `xrEndFrame: dropped N unusable layer(s)`, a quad layer with swapchain 0x0 (e.g. I Am Monkey's intro video) | The game plays video into an Android-surface swapchain (XR_KHR_android_surface_swapchain); the Frame's runtime lists the extension but returns FUNCTION_UNSUPPORTED | adapter `surface_emul` (default on): FrameBridge gives the player a SurfaceTexture-backed Surface and copies each frame into an ordinary swapchain (log `surface_emul: …`) |
|
||||
| The game quits right after start: `Something failed to initialize. Quitting!` / `We don't have write permission to …/files/cloud/data` (e.g. SUPERHOT) | The game created a save folder with mode 1700; inside Lepton the app writes through the folder's group | launch.sh `fix_perms` adds owner + group write to every folder in the game's storage (agent 41); reinstall to get the new launcher |
|
||||
| The whole Frame slows to a halt, then the game is killed (`Out of memory: Killed process … anon-rss:10+ GB`), e.g. Lucky's Tale | The game's own memory grows ~1 GB/s on Unity's `Loading.PreloadManager` thread (perf page-fault profile); not the flat window, not the text-input patches | none yet: mark unsupported; profile with `perf record -p <pid> -e page-faults --call-graph fp` (works as steamos, `perf_event_paranoid` 2) |
|
||||
| A Linux app exits at once: `cannot execute binary file: Exec format error` in launch.log | an x86_64 program started directly (installed before FramePort ran x86 builds through FEX, or by hand) | reinstall it: x86_64 Linux apps install FEX on the Frame and start through it (agent v61, `kind: linux_x86`; FEX also needs `STEAM_COMPAT_DATA_PATH`: "No compat data path?" in launch.log = an agent v60 launcher, reinstall); triage `linux-x86-no-fex`. Prefer an arm64 build when the app offers one |
|
||||
| `APP_ACTIVITY is empty`, nothing starts | Manifest has category INFO only; Lepton needs LAUNCHER | `frame.launcher` (automatic) |
|
||||
| PC VR game on the Frame shows as a flat window / Revive: `Unable to load LibOVRRT DLL` / `LoaderInstance::CreateInstance chained CreateInstance call failed` | Frame SteamVR runtime rejects OpenXR apiVersion 1.1 (`XR_ERROR_API_VERSION_UNSUPPORTED`), which Proton 11's VR helper requests | `pcvr.xr_timefix` (Frame OpenXR layer, default on): retries xrCreateInstance as 1.0 |
|
||||
| Unreal PC VR game on the Frame runs as a flat window although OpenXR works (no `LogHMD` OVRPlugin lines; Unreal logs nothing when it skips the Oculus plugin) / launch.log: `FramePort oculushmd: could not create the OculusHMDConnected event` | UE's OculusHMD (and LibOVR's `ovr_Detect`) only start when the Windows event `OculusHMDConnected` exists and is signalled; on a PC the Oculus service creates it. Revive hooks `OpenEventW` for it, but that relies on Detours patching Wine's (ARM64EC) kernelbase | `pcvr.oculus_unreal` (default for Unreal Rift games; PC VR counterpart of overport's `patch_oculus_unreal`): launch.sh runs the injector through `fp_oculushmd.exe`, which provides the real event until the game exits |
|
||||
@@ -41,14 +47,19 @@ version is `catalog/triage.yaml` (used by `frameport test` / the Job screen); ke
|
||||
| Uploads to the Frame are slow (~15 MB/s) | PC and Frame both on Wi-Fi through the home router | Connect the PC to the Frame's own hotspot (or a USB cable): FramePort uses the direct link automatically (~80-100 MB/s); job log line "Transfer link" |
|
||||
| PC VR game exits right away: `Unhandled Exception: 0xc06d007e` (after `FOnlineSubsystemOculus::InitWithWindowsPlatform`) | Delay-loaded `LibOVRPlatform64_1.dll` (Oculus Platform SDK, installed with the Oculus app) is missing | None on the Frame (entitlement check; FramePort doesn't replace it). PC mode with the Oculus app |
|
||||
| Unreal PC VR game opens the crash reporter instead of closing | UE starts CrashReportClient.exe on a crash | `pcvr.no_crash_reporter` (default for Unreal Rift games): `-nocrashreports` + CrashReportClient.exe renamed `.disabled` in the Frame copy |
|
||||
| A backup's game was added without its data (library `data_dir` null, `data_bytes` 0) although the folder has .obb files | The OBBs sit in a layout the scan didn't know: `<game>/obb/<package>/`, `Android/obb/<package>/`, or SideQuest-style `<game>/apk/x.apk` + `<game>/obb/<package>/` | `sources/quest_dump.find_data_dir` finds a `<package>` folder with .obb files ≤3 levels below the APK's folder or ≤2 below its parent (skipping neighbouring folders with APKs: other games); an `apk`/`apks` folder counts as part of its game folder. Add the folder again (Analyze again doesn't look for data) |
|
||||
| Game hangs at start / never loads although its .obb files are right there: next to the APK, in an `obb` folder beside an `apk` folder inside a `<package>` folder, or a SideQuest backup (`<timestamp>_<versionCode>.apk`) (GitHub #85, #91) | No folder named after the package, so the folder-layout checks found nothing and no OBB was uploaded | `quest_dump.find_data` then looks for the files by name, `(main\|patch).<versionCode>.<package>.obb` (any case), in the APK's folder, its parent and up to 3 levels below each (folders with their own APKs are other games); prefers the folder and files of the APK's own versionCode, else the newest older, else any version. When that folder also holds other things (the APK itself, other games' OBBs), the library entry gets `data_files` and only those files are uploaded, counted and deleted with the game. Add the folder again |
|
||||
| Unreal game: `JNI_OnLoad` (OVRPlugin), then silence: no OpenXR instance, no crash, no frames (GitHub #85 TRIANGLE STRATEGY; launch-test finding `missing-obb`) | Installed without its OBB: the manifest says `com.epicgames.ue4.GameActivity.bHasOBBFiles` = true (UE5: `com.epicgames.unreal.…`) but the library has no data folder (`data_dir` null, `data_bytes` 0) | Put the .obb files in a `<package>` (or `obb/`) folder next to the APK, add the folder again, reinstall. Analysis `extra.expects_obb`; the game page, the install question and `frameport scan`/`install` warn; launch tests that sent no frames get the `missing-obb` finding from the library (the game logs nothing). Unity split-binary builds count too (`extra.unity_split`, `analysis/unity_split.py`): an XR-plugin build (Oculus XR Plugin / Unity OpenXR library) without `assets/bin/Data/UnitySubsystems/` in the APK, or BuildSettings listing more scenes than the APK has `levelN` files (globalgamemanagers loose or read from the head of data.unity3d); exact on the 48 Unity APKs of the dumps (13 split, 17 full games; OBBs of full builds are asset bundles or sound banks) |
|
||||
| `INSTALL_FAILED_NO_MATCHING_ABIS` | 32-bit-only APK; Frame has no AArch32 | None. PC/Rift version via Revive |
|
||||
| Crash at start: `NoClassDefFoundError: … Landroid/window/OnBackInvokedCallback;` or `NoSuchMethodError: No static method storeStoreFence()V in class Ljava/lang/invoke/VarHandle;` (GitHub #71/#72, triage `android-too-new`) | The APK needs Android 13+ (minSdk 33 or more; those were 34) and calls its classes at start; Lepton's Android is 11 (API 30). OVRPort lowers minSdk to 29, so it installs anyway. minSdk ≤ 32 (Quest's Android 12L) is fine: 16 working catalog games declare 32 | None (analysis `extra.min_sdk` > 32 → a warning on the game page/CLI and in the recipe notes; never unsupported from the manifest alone, the launch test's triage decides). Waits for Valve to update Lepton's Android |
|
||||
| Nothing opens; `TWALauncherActivity: Using URL from Manifest (https://…)`, `Creating TwaLauncher for com.oculus.browser`, `NameNotFoundException: com.oculus.browser` (GitHub #86 Mahjong Table VR, triage `web-wrapper`) | The APK is a Trusted Web Activity (Bubblewrap / Meta's PWA packaging): a website that opens in Meta's browser, which Lepton doesn't have | None: open the URL in a browser. Analysis `extra.web_wrapper` (manifest meta-data `android.support.customtabs.trusted.DEFAULT_URL`, resolved through resources.arsc, or androidbrowserhelper's LauncherActivity) → a warning with the URL (not unsupported: the manifest alone never decides) |
|
||||
| `UnsatisfiedLinkError` / `cannot locate symbol "ovr_…"` | overport's platform loader lacks Meta platform functions | `frame.ovrstubs` (automatic, generated stubs) |
|
||||
| missing `ovrMessageType_ToString` | same, but the game needs a real string | `frame.ovrplatformcompat` (automatic) |
|
||||
| The game stays in its built-in language or waits at start although its OBB / files hold language packs (`<tag>.lang`, e.g. `de.lang`) | overport's platform loader answers `ovr_LanguagePack_GetCurrent/SetCurrent` with request id 0, so the game never gets the pack's path | `frame.langpacks` (opt-in, experimental, shown for games whose data has `*.lang`; `native/langpack`, build it with `python native/build.py --only langpack`). Default pack: the one the game applies, else env `FRAMEPORT_LANGPACK=<tag>`, else the only pack; search path override `FRAMEPORT_LANGPACK_DIRS`. Unreal games (Deadpool VR) grey out a pack whose asset `Metadata` differs from the game's version string: the patch writes the APK's versionName as Metadata (env `FRAMEPORT_LANGPACK_META` overrides) and reports the pack under the `/storage/emulated/0/Android/obb/<pkg>/` spelling of its path; with `/sdcard/…` the text switched but the dialogue stayed silent (verified in the headset with Deadpool VR) |
|
||||
| `ClassNotFoundException com.oculus.os.AnalyticsEvent` → abort | Quest telemetry lookup in Meta XR Audio (Unreal build) or native code | `frame.metaxr_telemetry` + `frame.oculusos` (automatic) |
|
||||
| `JNI DETECTED ERROR`, `GetStringUTFChars … NULL` | CheckJNI is on because overport marks the app debuggable | `frame.nodebug` |
|
||||
| Unreal game quits a few seconds after start (`System.exit`) | ForceQuit after a failed Quest platform check | alternate build with `patch_remove_unreal_force_quit` (`use_alt`) |
|
||||
| Unreal game crashes a few seconds after the logo with no backtrace (Unreal's own signal handler hides it: logcat-crash.log empty, Zygote `exited due to signal 11`); the crashing thread is `GameThread`, pc in `libaaudio.so`, lr `libovrplatformloader.so (ovr_Microphone_GetOutputBufferMaxSize+0x10)`; the last platform call is `ovr_Microphone_Create` (e.g. The Walking Dead: Saints & Sinners Ch. 2) | OVRPort's platform loader opens the microphone's AAudio stream only in `ovr_Microphone_Start`, but `GetOutputBufferMaxSize` reads that stream unchecked; Unreal's Oculus voice asks for the size right after `Create` | `frame.ovr_microphone` (NULL check rewritten in place; size 0 until the microphone starts) |
|
||||
| Unreal game crashes a few seconds after the logo with no backtrace (Unreal's own signal handler hides it: logcat-crash.log empty, Zygote `exited due to signal 11`); the crashing thread is `GameThread`, pc in `libaaudio.so`, lr `libovrplatformloader.so (ovr_Microphone_GetOutputBufferMaxSize+0x10)`; the last platform call is `ovr_Microphone_Create` (e.g. The Walking Dead: Saints & Sinners Ch. 2) | OVRPort's platform loader opens the microphone's AAudio stream only in `ovr_Microphone_Start`, but `GetOutputBufferMaxSize` reads that stream unchecked; Unreal's Oculus voice asks for the size right after `Create` | `frame.ovr_microphone` (NULL check rewritten in place; size 0 until the microphone starts). OVRPort runtime 3.4.3-aa54c3f has the check itself: builds made with it leave the patch out (log "not needed: frame.ovr_microphone", `patches/upstream.py`) |
|
||||
| `xrCreateSwapchain` -26 / format unsupported (GLES) | Frame takes only sRGB formats, no MSAA | adapter `swapchain_fix` (default on) |
|
||||
| Frames rejected, "Waiting…" forever | a layer uses a failed swapchain or an extension that isn't enabled (e.g. equirect2) | adapter `layer_fix` (default on) |
|
||||
| `xrConvert…TimeKHR` FUNCTION_UNSUPPORTED spam; VrApi bridge stalls before recenter | runtime lacks timespec conversion | current adapter emulates it |
|
||||
@@ -68,14 +79,20 @@ version is `catalog/triage.yaml` (used by `frameport test` / the Job screen); ke
|
||||
| Batman: Arkham Shadow closes during smoke-bomb effects; later input-tree corruption | Meta XR Audio Wwise deletes queued metadata still referenced by the current audio frame, then writes through the stale pointer | FrameBridge automatically retires metadata after current-frame references disappear, for the verified AArch64 SDK build only; see [AUDIO_METADATA.md](AUDIO_METADATA.md) |
|
||||
| Game stays on a loading or "Waiting" box although it reached FOCUSED; log `FrameBridge: xrEndFrame failed -25` then no more `pacing:` lines (e.g. PowerWash Simulator on some Frames, GitHub #39) | The eye image rect ends a few pixels past its swapchain (Unity rounds the swapchain width, the runtime's recommended size differs per Frame); SteamVR rejects every frame with XR_ERROR_SWAPCHAIN_RECT_INVALID | FrameBridge clamps every projection/quad image rect to its swapchain (`rect_clamp`, default on since 0.11.0; log `rect_clamp: view N image rect clamped`): rebuild + reinstall the game |
|
||||
| Game (Unity, GLES) freezes, `zink: DEVICE LOST` | multisampled render-to-texture hangs the GPU | `frame.unity_no_msaa`; if it persists: unfixable → PC version |
|
||||
| Unreal GLES game crashes ~3 s after start: `Fatal signal 11 … fault addr 0x10000 in tid … (RHIThread)`, `#01 … libgallium_dri.so` (GitHub #83 Star Wars Pinball VR, triage `unreal-msrtt-crash`) | Unreal's mobile MSAA renders through multisampled render-to-texture; Zink's `find_rp_state` then indexes `rendering_state_cache[6]` one past its end (sample count ≥ 32) and calls a junk hash function (0x10000). Mesa bug (no bounds check) | `frame.unreal_gl_shim` (GL shim with `gl_hide_msrtt`, multiview kept for Unreal: Unreal 4.25 only enables multiview with GL_OVR_multiview, GL_OVR_multiview2 **and** GL_OVR_multiview_multisampled_render_to_texture, so the shim keeps the last one visible for Unreal and maps glFramebufferTextureMultisampleMultiviewOVR to the single-sampled glFramebufferTextureMultiviewOVR; log `multiview multisampled render-to-texture (N samples) drawn single-sampled`) |
|
||||
| Crash with `SIGILL (ILL_ILLOPN)` and `*pc=0xd50323bf` (autiasp), e.g. on Unreal's HttpManager thread (GitHub #83 Star Wars Pinball VR, triage `pac-unpaired`) | The engine's OpenSSL ARMv8 assembly has autiasp without a matching paciasp (libUE4.so: 38 paciasp, 40 autiasp; Poly1305 NEON). Quest CPUs treat PAC hints as NOPs, the Frame's CPU checks them | `frame.pac_hints`: in a library with unpaired counts every paciasp/autiasp becomes a NOP (in place) |
|
||||
| Unreal game (OVRPlugin) never starts VR: launch.log has `OVRPlugin: JNI_OnLoad` but never `CompositorOpenXR::PreInitialize`, no OpenXR session, then a crash a few seconds in (e.g. Star Wars Pinball VR, UE 4.25: null pointer in `FSceneRenderer::GetMultiViewSceneColor`, GitHub #83) | Unreal's Oculus module looks up every `ovrp_*` function of the OVRPlugin it was built against (`InitializeOculusPluginWrapper`, all ANDed); OVRPort's OpenXR OVRPlugin lacks a few old ones (UE 4.25 / OVRPlugin 1.44: `ovrp_GetPTWNear`), so the wrapper fails and OculusHMD is never pre-initialised | `frame.unreal_ovrp_entrypoints` (suggested when analysis `unreal_ovrp_lookups` name functions the shipped OVRPlugin lacks): generated `libfp_ovrpstubs.so` (DT_NEEDED of libOVRPlugin.so; dlsym on the plugin's handle searches its dependencies) with a stand-in per missing name returning ovrpFailure (-1000); build note lists the names |
|
||||
| Only the Android home screen shows; the log has Unity's VR device as `None` (e.g. Accounting+, Unity 2017) | Unity 2017–2018 built-in Oculus support starts VR only when `com.oculus.systemactivities` is installed; Lepton has no Meta system apps, so Unity falls back to non-VR | `frame.unity_oculus_check`: that package name in libunity.so → `android`, plus `native/ovrpshim` (libfp_ovrp.so): Unity 2017's legacy frame loop (`ovrp_Update2`/`ovrp_BeginFrame`) never calls `ovrp_WaitToBeginFrame`, so without the shim no `xrWaitFrame` happens, `CompositorOpenXR::Update … outside of frame bounds` floods the log and the dashboard freezes. With it: log `ovrp frame loop shim: waited for frame N`, ~71 fps. Accounting+ then stops at "press any button" although its OVRInput gets clean input (`INPUT_PROBE` in the patch logs connected controllers/buttons/input focus per call) — unresolved |
|
||||
| Black flat window, then a GPU hang: kernel `hangcheck detected gpu lockup` (offending task the game), `zink: DEVICE LOST`, Unity render-thread crash; `outside of frame bounds` thousands of times a second (e.g. BattleSisters, Unity 2019.4) | Unity 2019 on its built-in VR (no `libOculusXRPlugin.so`) uses the same legacy frame loop as Unity 2017: no `xrWaitFrame`, the render thread floods the GPU | `frame.unity_oculus_check` adds the ovrpshim frame wait for these too (revision 2) |
|
||||
| Unity built-in VR game (with `frame.unity_oculus_check`) freezes at a scene switch: the log stops after `Boot: Activating Scene: …`, the process stays alive, every thread sleeps (e.g. Sniper Elite VR, Unity 2019.4) | The shim's `xrWaitFrame` blocks until the previously waited frame is begun; Unity skipped beginning it at the scene switch and its render thread then waited for the main thread (gdb: UnityMain in vrclient `CSxrSession::StartNextFrame` ← `ovrp_WaitToBeginFrame` ← `fpov_Update2`). OVRPlugin also only begins the frame index it waited for | `frame.unity_oculus_check` revision 5: libunity.so's `ovrp_BeginFrame`/`ovrp_EndFrame` go through the shim, which waits ≤ 50 ms for the last waited frame to begin, else skips the wait (log `the last waited frame wasn't begun`), and gives a begin/end of another index the waited one |
|
||||
| Unity built-in VR game: the hands/weapons trail the controllers by centimetres when moving (headset fine, 72 fps), e.g. Sniper Elite VR | Unity's physics-step `ovrp_Update2` (prediction 0) makes OVRPlugin locate the nodes at the monotonic clock's "now", the XrTime base on a Quest but 0.05–0.9 s behind the Frame's XrTime; the runtime extrapolates backwards and the render-step reads after it get those poses too. A larger prediction is capped by OVRPlugin (~0.07 s) | `frame.unity_oculus_check` revision 5 holds the physics-step update back: both steps read the render update's display-time poses |
|
||||
| Unreal game stuck on a loading image after the intro, frames keep coming (72 fps), no crash (e.g. Vader Immortal) | suspect: a Meta Platform SDK request no message ever answers | diagnostics: `frame.ovr_trace` (opt-in) logs every `ovr_*` call, the answers `ovr_PopMessage` returns and every 10 s the unanswered requests (`fp_ovrtrace` in launch.log). Never fake an entitlement answer |
|
||||
| Own-engine game crashes in `libVkLayer_fossilize.so` (Fossilize's recording thread, e.g. Roblox) | same as Deadpool VR: uninitialised pointers in what Fossilize records | `frame.vk_sanitize` now also covers own-engine libraries that load `libvulkan.so` by name |
|
||||
| Crash right after the game gets focus, in `vrclient.so … UpdateActionStateInternal` / `sxr_xrSyncActions` (e.g. Myst) | a race in the Frame runtime's input code on the first sync after focus (not every launch) | adapter `sync_guard` (input syncs one at a time with event polling, paused 250 ms after FOCUSED) |
|
||||
| View jumps sideways / game pauses or freezes for a moment every few seconds (e.g. Blade & Sorcery, BattleGlide) | the Frame drops focus for ~0.5 s (FOCUSED→VISIBLE→SYNCHRONIZED); games pause or re-align the player (`OnVRPresence … Teleport`) | adapter `focus_hold` |
|
||||
| SDL / LÖVE app crashes at start: `NullPointerException … ClipboardManager.addPrimaryClipChangedListener` in `SDLClipboardHandler.<init>` (e.g. Dramatic Shape) | Lepton's Android has no clipboard service (`service check clipboard`: not found) | `frame.sdl_clipboard` (that call → nops in classes.dex, in place, `apk/dex.py`); reproduced and verified with LÖVE for Android 11.5 |
|
||||
| Controllers do nothing (e.g. stuck on a setup screen); log: `xrSuggestInteractionProfileBindings … XR_ERROR_PATH_UNSUPPORTED` | the game only suggests bindings for Meta's newer profiles (Touch Plus / Touch Pro); the Frame's Android runtime knows `oculus/touch_controller`, not those | adapter `profile_remap` (default on): the bindings are suggested again for Touch (log: `controller profile … -> oculus/touch_controller`) |
|
||||
| Some buttons do nothing or the wrong thing (e.g. a Quest game's X/Y on the Frame's left controller) | the game binds only Quest Touch and SteamVR maps Touch onto the Frame controllers with its own remap (Touch left X/Y land on the d-pad, right X and Y repeat B), or the runtime rejected a profile or an input call | turn on adapter `input_diag` (diagnostics, off by default; `frameport settings <pkg> input_diag=1`) and look for `input_diag:` lines: `bindings: <profile> accepted` or `unsupported: interaction profile <profile> -> <result>` with the rejected paths, `bindings: /user/hand/<hand> uses <profile>`, `unsupported: function <name>`, `unsupported: xrCreateAction -> <result> (<action>)` |
|
||||
| Unity game hangs or the whole Frame restarts (e.g. in a menu); log: `The current MSAA level is 0, but the recommended MSAA level is 4. Switching to the recommended level.` (e.g. Lucky's Tale) | Meta's OVRManager (`useRecommendedMSAALevel`) turns 4x MSAA on at runtime, past QualitySettings; multisampled render-to-texture on GLES/Zink hangs the GPU | `frame.unity_runtime_msaa_off` (Cpp2IL: `OVRDisplay.get_recommendedMSAALevel` → 0) |
|
||||
| Unity game: one eye shows only effects or grey, the other is fine (e.g. I Am Cat, Oculus XR Plugin on GLES) | the game's single-pass multiview rendering goes wrong for array slice 1 (the adapter submits both slices correctly) | `frame.unity_multipass` (Cpp2IL: `OculusSettings.GetStereoRenderingMode` → MultiPass); `swap_eyes=1` tells whether the game or the adapter is at fault |
|
||||
| Setup/intro loops every launch (Espire 2) | save folders created without write permission | launcher repairs permissions every 2 s (built in) |
|
||||
@@ -85,6 +102,8 @@ version is `catalog/triage.yaml` (used by `frameport test` / the Job screen); ke
|
||||
| Symptom | Cause | Fix |
|
||||
|---|---|---|
|
||||
| 2D Android app: Steam says it's running but nothing shows | Lepton runs apps headless unless the app folder has `lepton-show-flatscreen` | FramePort adds it for apps without VR (agent v28+); reinstall apps installed before |
|
||||
| A phone/tablet app shows nothing in the headset, or a VR app opens as a flat window | FramePort's VR/2D guess (`vr_kind`) is wrong for this app | patch `device.display_mode` → **Flat window** or **VR** (Customize → "Show as VR or as a flat window"), then Update on Frame |
|
||||
| "Install with FrameDrop" button opens FrameDrop (or nothing) instead of FramePort | another program owns `framedrop://`, or the switch is off, or macOS (Flet can't receive links there) | Settings → Install links → **Use FramePort for these links**; else Add games → Add from a link… (paste the button's address) |
|
||||
| 2D Android app: back/home/recents buttons cover the app's own buttons | Android's navigation bar | patch `device.hide_navbar` (on by default for apps without VR) sets `qemu.hw.mainkeys=1`; reinstall to apply |
|
||||
| Black screen, audio works, GLES engine with direct VrApi | Mesa rejects Quest-style GLSL | `frame.gl_shim` (logs `GLShim: SHADER COMPILE FAILED` + source lines) |
|
||||
| Black screen, audio works, log `Unsupported VrApi layer type N` | bridge drops frames containing that layer | extend the bridge (cylinder=3 is converted to a quad already) |
|
||||
@@ -101,16 +120,27 @@ version is `catalog/triage.yaml` (used by `frameport test` / the Job screen); ke
|
||||
| View vibrates even when holding still after `frame.unity_multipass` (I Am Cat) | poses/times are consistent, but two passes on Zink make every frame one period late, and the game clamps its physics step to 10 ms | not fixed (scale 0.8 didn't help); next ideas: fix multiview instead, or the game's fixed timestep |
|
||||
| Game freezes / pauses for 0.5-2 s now and then, no flicker (e.g. Blade & Sorcery, Lucky's Tale) | the headset's wear sensor flickers off while worn (`logs/eyetracking.txt` `HMD off, stopping eye tracking` … `HMD on`), the Frame turns it into a focus loss and Quest games that pause on focus loss pause | adapter `focus_hold` (on by default since 2026-10-05, dips up to `focus_hold_ms` = 5000 ms are hidden; longer ones still pause) |
|
||||
| Minor glitches on some objects (Myst, Unreal Vulkan) | unknown; not application space warp (turning it off changed nothing and ran worse) | unresolved |
|
||||
| Graphics crash in vkCreateInstance with pc == fault address, from the game's own Vulkan hooks (BONELAB 1.2974 `libSLZQuestNative`) | a pointer into memory freed with OVRPlugin's pre-init OpenXR instance; not the runtime (vrclient.so) or Fossilize being unloaded (keeping both loaded with RTLD_NODELETE didn't help) | unresolved |
|
||||
| Unity game crashes or hangs right as Vulkan starts, after `SLZ Graphics plugin loading!` and OVRPlugin's pre-init `xrDestroyInstance`: SIGSEGV with pc 0 (or pc == fault address in an unloaded library), x16/x23 in `libSLZQuestNative.so` (BONELAB 1.2974) | Stress Level Zero's graphics plugin hooks Unity's Vulkan start-up (IUnityGraphicsVulkanV2 interception: vkCreateInstance/vkCreateDevice) and vkCreateSampler; its vkCreateInstance wrapper calls an invalid pointer on the Frame | `frame.slz_vulkan_hooks` (its two registrations become no-ops; Unity starts Vulkan itself; ~35 s of shader prewarming without its pipeline cache) |
|
||||
| Unity game shows a picture but the player body is frozen: no head tracking, the controllers stay on the model, no buttons, although OpenXR input works (BONELAB 1.2068, Oculus XR Plugin) | OVRPlugin reports the headset as not worn (`ovrp_GetUserPresent2` → 0) a few seconds after start, and the game's rig only follows a present user (Marrow `XRHMD.IsUserPresent` = Unity's HMD `UserPresence`) | `frame.unity_user_presence` (the Oculus XR Plugin's lookup → `libfp_ovrp.so`, reports present; log `user presence: OVRPlugin 0 …`) |
|
||||
| Unreal 5 game crashes at its first render pass, backtrace `vulkan.freedreno.so` ← `libVkLayer_fossilize.so` ← `libfp_vk.so (create_render_pass2)` (Metro Awakening) | a subpass without a depth attachment names a depth/stencil resolve attachment; the Frame's Turnip reads the missing depth attachment (NULL) | the Vulkan shim drops that resolve (always, FramePort after 0.11.0; log `dropped the depth resolve of subpass N (no depth attachment)`); triage `unreal-vulkan-driver-crash` |
|
||||
| Unreal 5 game crashes in `vulkan.freedreno.so` called straight from `libUnreal.so` right after its swapchains, or a few seconds into the first frames (Metro Awakening) | Unreal turns on fragment-density-map foveation because Turnip offers VK_EXT_fragment_density_map, then records barriers (to `FRAGMENT_DENSITY_MAP_OPTIMAL`) and image views (2D array R8G8) for a density map the Frame never provides (VK_NULL_HANDLE); Turnip dereferences it | adapter `vk_hide_fdm=1` (the game doesn't see the extension) + `vk_spec_fixes=1` (leaves out null-image barriers, refuses null-image views); triage `unreal-fdm-missing`. Found by disassembling the driver at the crash pc: the struct offsets (0x58 = VkSubpassDescription2, 0x48/0x60 = image barriers, viewType/format in registers) name the call |
|
||||
| Own-engine game crashes in `je_free` from its own library on the first frames (Roblox) | the game frees memory it doesn't own; not the Vulkan shim or the format fallback | unsupported |
|
||||
|
||||
## Live view (Live view tab, `install/livestream.py`)
|
||||
| Symptom | Cause | Fix |
|
||||
|---|---|---|
|
||||
| Status line says "software encoder" (30 fps, the Frame's CPU busier) | `fp_venc --probe` failed (missing upload, encoder busy or refused a format: exit 4) or the helper couldn't be put on the Frame | on the Frame: `~/.local/share/frameport/bin/fp_venc --probe; echo $?` and `--selftest`; the app log names upload failures. `FP_VENC_DISABLE=1` forces the fallback for tests |
|
||||
| Picture drifts out of sync with the sound | the hardware path relies on one H.264 frame per fps slot (ffmpeg `-framerate`); `fp_venc: stats … skipped=` > 0 on stderr means slots were skipped | see the stats line (every 10 s); a stopped/suspended Frame skips slots on purpose |
|
||||
| Viewer joins only after several seconds | the keyframe request (`k` on the channel) didn't reach the encoder; the viewer then waits for the next regular keyframe (4 s) | check `live: encoder=hardware` came first (requests are sent only then) |
|
||||
|
||||
## Debugging techniques that worked
|
||||
- A user's problem report: `frameport diag inspect <FramePort-diag-*.zip>` re-triages its launch log with the current
|
||||
signatures; the zip has the recipe, analysis, ELF/PE imports, Frame logs and versions (docs/DIAGNOSTICS.md).
|
||||
- Read `<base>/launch.log` (logcat mirror). Filter the game's pid: `Start proc <pid>:<package>`.
|
||||
- **Monitor tab** (GUI, while a game runs): fps from FrameBridge's pacing lines next to GPU busy %, the hottest
|
||||
sensor, memory pressure and per-process CPU/GPU/memory. A memory runaway (Lucky's Tale, Vader Immortal) shows as
|
||||
rising memory + "waiting" before the OOM kill; a GPU-bound game as GPU near 100 % with fps under target; heat as the
|
||||
temperature tile turning amber/red. Sources and costs: FRAME_RUNTIME.md "Monitoring sources".
|
||||
- The adapter logs as `FrameBridge` (settings, xrCreateInstance result, swapchain retries, pacing fps).
|
||||
- For GLES/GLAD engines, wrap `eglGetProcAddress` to see shader compile errors (build the shim with `-DGLSHIM_TRACE`
|
||||
for per-FBO draw counts and draw-call errors; the bridge has `-DOVP_GL_DIAG` for eye-image readback).
|
||||
@@ -126,6 +156,14 @@ version is `catalog/triage.yaml` (used by `frameport test` / the Job screen); ke
|
||||
touching new memory (`perf script -F comm,tid,ip,dso`); `-t <tid> -F 499` samples one thread. Map IL2CPP
|
||||
addresses with a full Cpp2IL diffable-cs dump (method `Offset` = address − the r-xp mapping of libil2cpp.so).
|
||||
Sample memory per mapping name from `/proc/<pid>/smaps` (`[anon:libc_malloc]` = native heap).
|
||||
- Hangs (every thread asleep): backtraces of all threads with gdb. Root inside the Lepton container may ptrace the
|
||||
game (the host's `ptrace_scope` 1 doesn't apply there) and the guest has `gdbserver64`; `debuggerd -b` fails (no
|
||||
tombstoned). Copy every mapped library to a local sysroot (`podman exec <container> cat /proc/<pid>/maps`, then
|
||||
`tar -chf - -T <list>` through `podman exec -i`; the app's own libs from the installed `lepton-app/game.apk` at their
|
||||
`/data/app/…/lib/arm64` path), then on the PC: `gdb -batch -ex "set sysroot <dir>" -ex "target remote | ssh
|
||||
steamos@<frame> podman exec -i lepton-steamlaunch-<appid> gdbserver64 - --attach <pid in the container>" -ex
|
||||
"thread apply all bt 25" -ex detach` (`set sysroot target:` makes gdbserver assert in linux_mntns_readlink).
|
||||
`/proc/<pid>/task/*/syscall` (read inside the container) shows each thread's syscall and pc without a debugger.
|
||||
- Unity catches native crashes itself: no debuggerd backtrace in Lepton's logcat-crash.log, but a
|
||||
`tombstone_00` in the game's `Android/data/<pkg>/files/` with the memory map (map pc/lr/registers to libraries).
|
||||
- Focus losses: the game sees FOCUSED→VISIBLE→SYNCHRONIZED (OVRPlugin `[XR_SESSION]`, FrameBridge `focus_hold:`
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
# Screenshots and videos
|
||||
|
||||
The pictures in the docs and the videos are rendered by scripts, never taken by hand. The scripts show the real
|
||||
FramePort GUI with a demo library and a pretend Steam Frame, drive it the way a person would, and film or photograph
|
||||
it:
|
||||
|
||||
| What | Source | Output |
|
||||
|---|---|---|
|
||||
| Docs screenshots | `docs/showcase/shots.yaml` | `docs/images/*.png` |
|
||||
| Demo tour (about 95 s) | `docs/showcase/videos/tour.yaml` | `docs/media/frameport-tour.mp4` (+ `.jpg` poster), `docs/images/tour-teaser.webp` (README) |
|
||||
| Install tutorial (about 90 s) | `docs/showcase/videos/install.yaml` | `docs/media/frameport-install.mp4` (+ `.jpg` poster) |
|
||||
|
||||
Nothing comes from anyone's own library. The demo library (`docs/showcase/demo-library.yaml`) lists real catalog
|
||||
games, so recipes and patches are the ones FramePort really uses. Their technical analysis (`demo-analyses.json`:
|
||||
engine, VR API, libraries, sizes) was exported from real APK analyses without any paths. Art, in-game screenshots
|
||||
and store details come from the same public sources the app uses and are cached in `~/.cache/frameport-showcase`.
|
||||
The renderer refuses to run in FramePort's own data folder, scans the demo data for home paths and IP addresses
|
||||
first, and stops when a store didn't send art (placeholders never reach the docs; `--allow-missing-art` overrides
|
||||
that). Frame discovery is switched off during a render (no real device on your network can appear), and the setup
|
||||
command shows placeholders for the address and code (each PC has its own), never this computer's.
|
||||
|
||||
## Running it
|
||||
|
||||
You need the dev extras, Chromium for Playwright and ffmpeg:
|
||||
|
||||
```
|
||||
UV_LINK_MODE=copy uv sync --extra dev
|
||||
uv run playwright install chromium # once
|
||||
uv run python scripts/showcase/render_docs.py # all screenshots → docs/images (changed ones only)
|
||||
uv run python scripts/showcase/render_docs.py --only game,monitor --out /tmp/shots
|
||||
uv run python scripts/showcase/record_video.py install --draft # quick 720p check of a storyboard edit
|
||||
uv run python scripts/showcase/record_video.py # every video → docs/media (+ the README teaser)
|
||||
uv run python scripts/showcase/record_video.py tour install # some
|
||||
```
|
||||
|
||||
Every screenshot is rendered twice, each in a fresh window, and kept only when both agree (the headless GPU now and
|
||||
then draws a glyph wrong); a third render settles a disagreement, and `--fast` renders once for trying out an edit.
|
||||
A shot whose steps fail is tried again and never written. A screenshot is rewritten only when it visibly changed
|
||||
(`render_docs.changed`: anti-aliasing noise doesn't count), so running it twice changes nothing. `--check` writes
|
||||
nothing and exits 1 when a docs image is out of date.
|
||||
|
||||
For videos, `--names` prints what can be clicked after each scene and `SHOWCASE_DEBUG=1` prints every step with its
|
||||
start time (which step waited); `--draft --scenes a,b` records only some scenes. A video is encoded at the best
|
||||
quality that fits its `budget_mb` (12 by default), a teaser at 4 MB.
|
||||
|
||||
## Videos
|
||||
|
||||
One storyboard per video in `docs/showcase/videos/<name>.yaml`; adding a file adds a video (CI and releases pick it
|
||||
up by itself). The output must be `docs/media/frameport-<name>.mp4`: releases attach it as `FramePort-<name>.mp4`.
|
||||
|
||||
```yaml
|
||||
output: docs/media/frameport-install.mp4
|
||||
teaser: docs/images/tour-teaser.webp # optional: a looping WebP from the scenes' `teaser` parts
|
||||
budget_mb: 12
|
||||
poster_at: 9 # the poster frame, seconds after the title card
|
||||
start:
|
||||
profile: fresh # demo = FramePort in use (games installed, BONELAB running); fresh = its first start
|
||||
frame: disconnected # connected (default) or disconnected
|
||||
route: welcome # the page filming starts on (default library)
|
||||
stream: live # the monitor stream: live (default) or frozen
|
||||
setup: # steps before filming starts (a failure stops the recording)
|
||||
- hook: {name: first_run, args: ["D:/Games", 1.4]}
|
||||
vars: {game: com.playful.LuckysTale} # ${game} in any step
|
||||
title: {heading: Installing FramePort, line: …, seconds: 3.4}
|
||||
end: {heading: You're set, line: …, footer: github.com/spoopyghosty0/frameport, seconds: 4}
|
||||
scenes:
|
||||
- name: connect # a filmed scene
|
||||
caption: ["Connect your Steam Frame", "Once: FramePort shows a command to run on the Frame"]
|
||||
teaser: [0.6, 4.0] # optional: this part goes into the teaser
|
||||
hold: 1.5 # seconds of filming after the last step (default 0.6)
|
||||
steps: [...]
|
||||
- name: on-the-frame # an instruction card: for what happens outside FramePort
|
||||
seconds: 10
|
||||
card:
|
||||
eyebrow: "Step 3 · On the Frame, first time only"
|
||||
heading: Run the setup command
|
||||
steps: ["In the SteamVR dashboard: **Launch a program** → **Desktop**", …] # **bold** = a button or menu
|
||||
code: "curl -fsS <your-PC-address>:8765/<one-time-code> | bash"
|
||||
note: "Your address and code differ."
|
||||
```
|
||||
|
||||
Filmed scenes are one continuous session: each starts where the last one left off. Cards are rendered at the end
|
||||
and slotted in, with crossfades between everything. The `fresh` profile starts FramePort as on a new computer: an
|
||||
empty library, the welcome screen and a Frame that isn't set up. Its games wait for the pretend folder scan.
|
||||
|
||||
## Writing steps
|
||||
|
||||
Shots and scenes use one step language (`scripts/showcase/steps.py`). A step is a one-key mapping:
|
||||
|
||||
```yaml
|
||||
- go: monitor # a sidebar route
|
||||
- nav: "Monitor" # click that tab (checked: the page really changed)
|
||||
- open_game: ${game} # or {package: …, advanced: true}
|
||||
- call: {fn: settings_dialog, args: ["${game}"]} # any app method
|
||||
- hover: "Batman: Arkham Shadow" # the pointer: by name…
|
||||
- click: {name: "Lucky's Tale", dy: 0.35} # …offset inside the element (fraction of its size, or px)
|
||||
- click: "Install on Frame" # right_click, double_click, drag: [from, …, to]
|
||||
- type: "ri" # press: Escape
|
||||
- wait_for: "BONELAB · 2026-10-04 21:50"
|
||||
- wait: 1.2
|
||||
- hook: {name: held_install, args: ["${new_game}"]} # the pretend Frame's scripted events
|
||||
```
|
||||
|
||||
Elements are found by name through Flutter's accessibility tree: their visible text, a tooltip or a semantics
|
||||
label. Exact names win over prefixes, and buttons and cards win over plain text. When several match, the innermost
|
||||
one wins (a list carries the text of its rows; the row is meant). Icon-only buttons need a tooltip to be found,
|
||||
which also helps screen readers. The pointer moves on eased, slightly curved paths and is drawn into the picture,
|
||||
with a ring on every click. To open a game from a cover card, click its title (`dy: 0.35`): the card's middle is its
|
||||
Play/Install button.
|
||||
|
||||
Hooks (`steps.HOOKS`) cover what a real Frame would do:
|
||||
- `fake_install`: an install through the real job queue with every real stage name and a launch test that passes.
|
||||
- `held_install`: an install that stops mid-upload, for screenshots of the progress.
|
||||
- `connect` and `disconnect`
|
||||
- `first_run`: a first start. The welcome screen's tool download is a pretend one, and "Scan a folder…" scans a
|
||||
folder at once (the native folder picker can't be scripted).
|
||||
- `pairing_done`: the Frame ran the setup command, so FramePort connects.
|
||||
- `live_stream`: a test picture through the real relay.
|
||||
- `monitor_details`, `type_tab`, `select_files` and `settings_section`.
|
||||
|
||||
In a video, clicking Install runs the scripted install, and the game is then installed on the pretend Frame.
|
||||
|
||||
Pictures must not change from one run to the next:
|
||||
- Screenshot and file dates are fixed.
|
||||
- The Monitor's stream stops after its two-minute history.
|
||||
- The pointer leaves the page before a still picture is taken.
|
||||
- Each shot gets a fresh window and browser.
|
||||
- A picture is taken once the page has stopped changing.
|
||||
|
||||
Live data, such as the live view's relay port and data rate, doesn't belong in a docs screenshot.
|
||||
|
||||
## How it runs on GitHub
|
||||
|
||||
The `showcase` workflow (`.github/workflows/showcase.yml`):
|
||||
1. **When it runs:** on pushes to `main` that touch the UI, its translations or the showcase files, and on
|
||||
**Run workflow**.
|
||||
2. **What it renders:** the screenshots every time. Videos when their storyboard changed (all of them when the
|
||||
scripts changed), or the ones named on a manual run (`all`, or e.g. `tour install`). UI tweaks alone don't
|
||||
re-commit 10 MB videos.
|
||||
3. **What happens next:** every render is uploaded as the run's `showcase` artifact. When a picture changed, the
|
||||
workflow opens or updates the pull request on branch `showcase/update`, which you review and merge.
|
||||
|
||||
Releases attach every committed video as `FramePort-<name>.mp4`.
|
||||
|
||||
## Gallery
|
||||
|
||||
These are renders the README doesn't show (yet):
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|  |  |
|
||||
|  |  |
|
||||
@@ -0,0 +1,61 @@
|
||||
# Themes
|
||||
|
||||
FramePort comes with three colour themes, all dark:
|
||||
|
||||
| Theme | Look |
|
||||
|---|---|
|
||||
| **Portal** (default) | The logo's two portals: orange for actions and the current selection, blue for secondary actions, progress and the PC side. |
|
||||
| **Portal (OLED)** | Portal on true black, for OLED screens. |
|
||||
| **Original** | FramePort's first look, with a violet accent. |
|
||||
|
||||
Switch in **Settings → Appearance**. The change applies at once.
|
||||
|
||||
## Your own theme
|
||||
|
||||
A theme is a small JSON file. To make one:
|
||||
|
||||
1. In **Settings → Appearance**, pick the theme closest to what you want and click **Copy this theme as a file**.
|
||||
2. Paste it into a text editor and save it as `something.json`.
|
||||
3. Change the name and the colours you want different. You can delete every colour you keep: missing colours come
|
||||
from the `base` theme.
|
||||
4. Back in **Settings → Appearance**, click **Install theme file…** and choose the file. FramePort checks it,
|
||||
switches to it and keeps a copy in its data folder (`themes/`), so you can delete the original.
|
||||
|
||||
To remove an installed theme, click the bin icon on its card.
|
||||
|
||||
### Format
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Ember & Ice",
|
||||
"base": "portal",
|
||||
"dual": true,
|
||||
"colors": {
|
||||
"ACCENT": "#FF5A36",
|
||||
"SECONDARY": "#5CE1E6"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Meaning |
|
||||
|---|---|
|
||||
| `name` | Shown on the theme's card (up to 40 characters). |
|
||||
| `base` | The built-in theme that fills in every colour the file leaves out: `portal` (default), `portal_oled` or `original`. |
|
||||
| `dual` | `true`: two-colour touches like Portal's (blue-to-orange sidebar edge, two-colour "FramePort", the selected tab's fade, blue secondary buttons). `false`: one accent, like Original. Default: the base's. |
|
||||
| `colors` | Any of the colours below, as `#RRGGBB` or `#RGB`. Names may be upper or lower case. |
|
||||
|
||||
| Colour | Used for |
|
||||
|---|---|
|
||||
| `BG` | Window background |
|
||||
| `SIDEBAR` | Sidebar and activity panel |
|
||||
| `SURFACE`, `SURFACE_2`, `SURFACE_3` | Cards; raised and hovered parts; inputs and chips |
|
||||
| `BORDER`, `BORDER_STRONG` | Outlines |
|
||||
| `TEXT`, `TEXT_2`, `TEXT_3` | Main text; secondary text; captions and disabled text |
|
||||
| `ACCENT`, `ACCENT_SOFT`, `ON_ACCENT` | Main buttons and the current selection; its tint; text on it |
|
||||
| `SECONDARY`, `SECONDARY_SOFT` | Secondary buttons, progress, switch tracks; its tint |
|
||||
| `OK`, `WARN`, `ERROR`, `INFO` | Status: works, needs attention, failed, information |
|
||||
| `PC` | PC VR games and "on this PC" |
|
||||
|
||||
FramePort refuses a theme file it can't show well, and says why: a light window background (FramePort is dark only),
|
||||
text that's hard to read on cards, an unknown colour name or a value that isn't a colour. An example is in
|
||||
[`themes/example-theme.json`](themes/example-theme.json).
|
||||
@@ -0,0 +1,28 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="216" height="60" viewBox="0 0 216 60" role="img" aria-label="Install with FramePort"><title>Install with FramePort</title><style>.fp-wb,.fp-wo{transform-box:view-box}
|
||||
.fp-wb{transform-origin:0 0;animation:fp-wb 6s ease-in-out infinite}
|
||||
.fp-wo{transform-origin:216px 0;animation:fp-wo 6s ease-in-out infinite}
|
||||
.fp-core{animation:fp-core 6s ease-in-out infinite}
|
||||
@keyframes fp-wb{0%,10%,100%{opacity:.45;transform:scaleX(1)}32%{opacity:1;transform:scaleX(1.5)}54%{opacity:.3;transform:scaleX(1)}}
|
||||
@keyframes fp-core{0%,28%,100%{opacity:0}42%{opacity:1}60%{opacity:0}}
|
||||
@keyframes fp-wo{0%,38%,100%{opacity:.6;transform:scaleX(1)}60%{opacity:1;transform:scaleX(1.4)}84%{opacity:.6;transform:scaleX(1)}}
|
||||
@media (prefers-reduced-motion:reduce){.fp-wb,.fp-wo,.fp-core{animation:none!important}}</style><defs>
|
||||
<linearGradient id="fab" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-color="#3AA8FF" stop-opacity=".46"/><stop offset=".55" stop-color="#3AA8FF" stop-opacity="0"/></linearGradient>
|
||||
<linearGradient id="fao" x1="0" y1="0" x2="1" y2="0"><stop offset=".45" stop-color="#FF8A1F" stop-opacity="0"/><stop offset="1" stop-color="#FF8A1F" stop-opacity=".34"/></linearGradient>
|
||||
<radialGradient id="far" gradientUnits="userSpaceOnUse" cx="122" cy="39" r="46" gradientTransform="translate(122 39) scale(1 .62) translate(-122 -39)"><stop offset="0" stop-color="#FFE2BD" stop-opacity=".42"/><stop offset=".25" stop-color="#FF8A1F" stop-opacity=".2"/><stop offset=".6" stop-color="#3AA8FF" stop-opacity=".08"/><stop offset="1" stop-color="#3AA8FF" stop-opacity="0"/></radialGradient>
|
||||
<clipPath id="fac"><rect x="1" y="1" width="214" height="58" rx="11.5"/></clipPath></defs>
|
||||
<rect x=".5" y=".5" width="215" height="59" rx="12" fill="#0D0E12" stroke="#2A2D37"/>
|
||||
<g clip-path="url(#fac)"><rect class="fp-wb" x="1" y="1" width="214" height="58" fill="url(#fab)" opacity=".45"/><rect class="fp-wo" x="1" y="1" width="214" height="58" fill="url(#fao)" opacity=".6"/><rect class="fp-core" x="1" y="1" width="214" height="58" fill="url(#far)" opacity="0"/></g>
|
||||
<g transform="translate(10 10) scale(0.625)">
|
||||
<defs><linearGradient id="fal0" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-color="#3AA8FF" stop-opacity=".18"/><stop offset=".5" stop-color="#3AA8FF" stop-opacity="0"/><stop offset=".5" stop-color="#FF8A1F" stop-opacity="0"/><stop offset="1" stop-color="#FF8A1F" stop-opacity=".18"/></linearGradient>
|
||||
<linearGradient id="fal1" gradientUnits="userSpaceOnUse" x1="26" y1="0" x2="38" y2="0"><stop offset=".3" stop-color="#3AA8FF"/><stop offset=".7" stop-color="#FF8A1F"/></linearGradient>
|
||||
<clipPath id="fal2"><polygon points="-30,-30 49.145,-30 8.855,94 -30,94"/></clipPath><clipPath id="fal3"><polygon points="55.145,-30 94,-30 94,94 14.855,94"/></clipPath></defs>
|
||||
<rect width="64" height="64" rx="15" fill="#101218"/><rect width="64" height="64" rx="15" fill="url(#fal0)"/>
|
||||
<g clip-path="url(#fal2)"><path d="M34 15H9a3 3 0 0 0-3 3v20a3 3 0 0 0 3 3h25z" fill="#101218" stroke="#ECEDF3" stroke-width="3" stroke-linejoin="round"/><rect class="fp-scr" x="10.5" y="19.5" width="24" height="17" rx="1" fill="#3AA8FF" fill-opacity="0.35"/><path d="M18 41v6M11 47h14" stroke="#ECEDF3" stroke-width="3" stroke-linecap="round"/></g>
|
||||
<g clip-path="url(#fal3)"><path d="M56.5 31.5H58.5" stroke="#ECEDF3" stroke-width="3.4" stroke-linecap="round"/><path d="M22 21h27a8 8 0 0 1 8 8v5a8 8 0 0 1-8 8H48.65a3 3 0 0 1-2.6-1.5l-1-1.7a.9.9 0 0 0-1.6 0l-1 1.7a3 3 0 0 1-2.6 1.5H22z" fill="#101218" stroke="#ECEDF3" stroke-width="3" stroke-linejoin="round"/><g class="fp-lens"><ellipse cx="39.5" cy="30.5" rx="4.2" ry="3.8" fill="#FF8A1F"/><ellipse cx="49" cy="30.5" rx="4.2" ry="3.8" fill="#FF8A1F"/></g></g>
|
||||
<g transform="rotate(18 32 32)"><g class="fp-ptl"><ellipse cx="32" cy="32" rx="4.5" ry="22" fill="#08090C" stroke="#08090C" stroke-width="5.8"/><ellipse cx="32" cy="32" rx="4.5" ry="22" fill="none" stroke="url(#fal1)" stroke-opacity=".25" stroke-width="6.46" class="fp-halo"/><ellipse cx="32" cy="32" rx="4.5" ry="22" fill="url(#fal1)" fill-opacity="0.14" stroke="url(#fal1)" stroke-width="3.4"/></g></g></g>
|
||||
<text x="60" y="25" font-family="Segoe UI, Roboto, 'Helvetica Neue', Arial, sans-serif" font-size="9.5" font-weight="600" letter-spacing="1.4" fill="#A7ABB7">INSTALL WITH</text>
|
||||
<text x="60" y="47" font-family="Segoe UI, Roboto, 'Helvetica Neue', Arial, sans-serif" font-size="18" font-weight="800" fill="#FF8A1F" textLength="53.1" lengthAdjust="spacingAndGlyphs">Frame</text>
|
||||
<g transform="translate(115.25999999999999 29.36) scale(0.8035714285714286)"><g class="fp-ptl"><defs><linearGradient id="fawr" gradientUnits="userSpaceOnUse" x1="2" y1="0" x2="14" y2="0"><stop offset=".3" stop-color="#FF8A1F"/><stop offset=".7" stop-color="#3AA8FF"/></linearGradient></defs>
|
||||
<ellipse cx="8" cy="14" rx="4.4" ry="10.6" transform="rotate(14 8 14)" fill="none" stroke="url(#fawr)" stroke-opacity=".35" stroke-width="5" class="fp-halo"/>
|
||||
<ellipse cx="8" cy="14" rx="4.4" ry="10.6" transform="rotate(14 8 14)" fill="#0D0E12" stroke="url(#fawr)" stroke-width="2.6"/></g></g>
|
||||
<text x="130.27714285714285" y="47" font-family="Segoe UI, Roboto, 'Helvetica Neue', Arial, sans-serif" font-size="18" font-weight="800" fill="#3AA8FF" textLength="36.9" lengthAdjust="spacingAndGlyphs">Port</text></svg>
|
||||
|
After Width: | Height: | Size: 5.2 KiB |
@@ -0,0 +1,26 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="216" height="60" viewBox="0 0 216 60" role="img" aria-label="Install with FramePort"><title>Install with FramePort</title><style>.fp-wb,.fp-wo{transform-box:view-box;transition:opacity .5s ease,transform .7s cubic-bezier(.2,.8,.2,1)}
|
||||
.fp-wb{transform-origin:0 0}.fp-wo{transform-origin:216px 0}
|
||||
.fp-core{transition:opacity .6s ease}
|
||||
svg:hover .fp-wb{opacity:1;transform:scaleX(1.4)}svg:hover .fp-wo{opacity:1;transform:scaleX(1.3)}
|
||||
svg:hover .fp-core{opacity:1}
|
||||
@media (prefers-reduced-motion:reduce){.fp-wb,.fp-wo,.fp-core{transition:none!important}}</style><defs>
|
||||
<linearGradient id="fhb" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-color="#3AA8FF" stop-opacity=".46"></stop><stop offset=".55" stop-color="#3AA8FF" stop-opacity="0"></stop></linearGradient>
|
||||
<linearGradient id="fho" x1="0" y1="0" x2="1" y2="0"><stop offset=".45" stop-color="#FF8A1F" stop-opacity="0"></stop><stop offset="1" stop-color="#FF8A1F" stop-opacity=".34"></stop></linearGradient>
|
||||
<radialGradient id="fhr" gradientUnits="userSpaceOnUse" cx="122" cy="39" r="46" gradientTransform="translate(122 39) scale(1 .62) translate(-122 -39)"><stop offset="0" stop-color="#FFE2BD" stop-opacity=".42"></stop><stop offset=".25" stop-color="#FF8A1F" stop-opacity=".2"></stop><stop offset=".6" stop-color="#3AA8FF" stop-opacity=".08"></stop><stop offset="1" stop-color="#3AA8FF" stop-opacity="0"></stop></radialGradient>
|
||||
<clipPath id="fhc"><rect x="1" y="1" width="214" height="58" rx="11.5"></rect></clipPath></defs>
|
||||
<rect x=".5" y=".5" width="215" height="59" rx="12" fill="#0D0E12" stroke="#2A2D37"></rect>
|
||||
<g clip-path="url(#fhc)"><rect class="fp-wb" x="1" y="1" width="214" height="58" fill="url(#fhb)" opacity=".45"></rect><rect class="fp-wo" x="1" y="1" width="214" height="58" fill="url(#fho)" opacity=".6"></rect><rect class="fp-core" x="1" y="1" width="214" height="58" fill="url(#fhr)" opacity="0"></rect></g>
|
||||
<g transform="translate(10 10) scale(0.625)">
|
||||
<defs><linearGradient id="fhl0" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-color="#3AA8FF" stop-opacity=".18"></stop><stop offset=".5" stop-color="#3AA8FF" stop-opacity="0"></stop><stop offset=".5" stop-color="#FF8A1F" stop-opacity="0"></stop><stop offset="1" stop-color="#FF8A1F" stop-opacity=".18"></stop></linearGradient>
|
||||
<linearGradient id="fhl1" gradientUnits="userSpaceOnUse" x1="26" y1="0" x2="38" y2="0"><stop offset=".3" stop-color="#3AA8FF"></stop><stop offset=".7" stop-color="#FF8A1F"></stop></linearGradient>
|
||||
<clipPath id="fhl2"><polygon points="-30,-30 49.145,-30 8.855,94 -30,94"></polygon></clipPath><clipPath id="fhl3"><polygon points="55.145,-30 94,-30 94,94 14.855,94"></polygon></clipPath></defs>
|
||||
<rect width="64" height="64" rx="15" fill="#101218"></rect><rect width="64" height="64" rx="15" fill="url(#fhl0)"></rect>
|
||||
<g clip-path="url(#fhl2)"><path d="M34 15H9a3 3 0 0 0-3 3v20a3 3 0 0 0 3 3h25z" fill="#101218" stroke="#ECEDF3" stroke-width="3" stroke-linejoin="round"></path><rect class="fp-scr" x="10.5" y="19.5" width="24" height="17" rx="1" fill="#3AA8FF" fill-opacity="0.35"></rect><path d="M18 41v6M11 47h14" stroke="#ECEDF3" stroke-width="3" stroke-linecap="round"></path></g>
|
||||
<g clip-path="url(#fhl3)"><path d="M56.5 31.5H58.5" stroke="#ECEDF3" stroke-width="3.4" stroke-linecap="round"></path><path d="M22 21h27a8 8 0 0 1 8 8v5a8 8 0 0 1-8 8H48.65a3 3 0 0 1-2.6-1.5l-1-1.7a.9.9 0 0 0-1.6 0l-1 1.7a3 3 0 0 1-2.6 1.5H22z" fill="#101218" stroke="#ECEDF3" stroke-width="3" stroke-linejoin="round"></path><g class="fp-lens"><ellipse cx="39.5" cy="30.5" rx="4.2" ry="3.8" fill="#FF8A1F"></ellipse><ellipse cx="49" cy="30.5" rx="4.2" ry="3.8" fill="#FF8A1F"></ellipse></g></g>
|
||||
<g transform="rotate(18 32 32)"><g class="fp-ptl"><ellipse cx="32" cy="32" rx="4.5" ry="22" fill="#08090C" stroke="#08090C" stroke-width="5.8"></ellipse><ellipse cx="32" cy="32" rx="4.5" ry="22" fill="none" stroke="url(#fhl1)" stroke-opacity=".25" stroke-width="6.46" class="fp-halo"></ellipse><ellipse cx="32" cy="32" rx="4.5" ry="22" fill="url(#fhl1)" fill-opacity="0.14" stroke="url(#fhl1)" stroke-width="3.4"></ellipse></g></g></g>
|
||||
<text x="60" y="25" font-family="Segoe UI, Roboto, 'Helvetica Neue', Arial, sans-serif" font-size="9.5" font-weight="600" letter-spacing="1.4" fill="#A7ABB7">INSTALL WITH</text>
|
||||
<text x="60" y="47" font-family="Segoe UI, Roboto, 'Helvetica Neue', Arial, sans-serif" font-size="18" font-weight="800" fill="#FF8A1F" textLength="53.1" lengthAdjust="spacingAndGlyphs">Frame</text>
|
||||
<g transform="translate(115.25999999999999 29.36) scale(0.8035714285714286)"><g class="fp-ptl"><defs><linearGradient id="fhwr" gradientUnits="userSpaceOnUse" x1="2" y1="0" x2="14" y2="0"><stop offset=".3" stop-color="#FF8A1F"></stop><stop offset=".7" stop-color="#3AA8FF"></stop></linearGradient></defs>
|
||||
<ellipse cx="8" cy="14" rx="4.4" ry="10.6" transform="rotate(14 8 14)" fill="none" stroke="url(#fhwr)" stroke-opacity=".35" stroke-width="5" class="fp-halo"></ellipse>
|
||||
<ellipse cx="8" cy="14" rx="4.4" ry="10.6" transform="rotate(14 8 14)" fill="#0D0E12" stroke="url(#fhwr)" stroke-width="2.6"></ellipse></g></g>
|
||||
<text x="130.27714285714285" y="47" font-family="Segoe UI, Roboto, 'Helvetica Neue', Arial, sans-serif" font-size="18" font-weight="800" fill="#3AA8FF" textLength="36.9" lengthAdjust="spacingAndGlyphs">Port</text></svg>
|
||||
|
After Width: | Height: | Size: 5.3 KiB |
@@ -0,0 +1,21 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="216" height="60" viewBox="0 0 216 60" role="img" aria-label="Install with FramePort"><title>Install with FramePort</title><defs>
|
||||
<linearGradient id="fsb" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-color="#3AA8FF" stop-opacity=".46"/><stop offset=".55" stop-color="#3AA8FF" stop-opacity="0"/></linearGradient>
|
||||
<linearGradient id="fso" x1="0" y1="0" x2="1" y2="0"><stop offset=".45" stop-color="#FF8A1F" stop-opacity="0"/><stop offset="1" stop-color="#FF8A1F" stop-opacity=".34"/></linearGradient>
|
||||
<radialGradient id="fsr" gradientUnits="userSpaceOnUse" cx="122" cy="39" r="46" gradientTransform="translate(122 39) scale(1 .62) translate(-122 -39)"><stop offset="0" stop-color="#FFE2BD" stop-opacity=".42"/><stop offset=".25" stop-color="#FF8A1F" stop-opacity=".2"/><stop offset=".6" stop-color="#3AA8FF" stop-opacity=".08"/><stop offset="1" stop-color="#3AA8FF" stop-opacity="0"/></radialGradient>
|
||||
<clipPath id="fsc"><rect x="1" y="1" width="214" height="58" rx="11.5"/></clipPath></defs>
|
||||
<rect x=".5" y=".5" width="215" height="59" rx="12" fill="#0D0E12" stroke="#2A2D37"/>
|
||||
<g clip-path="url(#fsc)"><rect class="fp-wb" x="1" y="1" width="214" height="58" fill="url(#fsb)" opacity=".45"/><rect class="fp-wo" x="1" y="1" width="214" height="58" fill="url(#fso)" opacity=".6"/><rect class="fp-core" x="1" y="1" width="214" height="58" fill="url(#fsr)" opacity="0"/></g>
|
||||
<g transform="translate(10 10) scale(0.625)">
|
||||
<defs><linearGradient id="fsl0" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-color="#3AA8FF" stop-opacity=".18"/><stop offset=".5" stop-color="#3AA8FF" stop-opacity="0"/><stop offset=".5" stop-color="#FF8A1F" stop-opacity="0"/><stop offset="1" stop-color="#FF8A1F" stop-opacity=".18"/></linearGradient>
|
||||
<linearGradient id="fsl1" gradientUnits="userSpaceOnUse" x1="26" y1="0" x2="38" y2="0"><stop offset=".3" stop-color="#3AA8FF"/><stop offset=".7" stop-color="#FF8A1F"/></linearGradient>
|
||||
<clipPath id="fsl2"><polygon points="-30,-30 49.145,-30 8.855,94 -30,94"/></clipPath><clipPath id="fsl3"><polygon points="55.145,-30 94,-30 94,94 14.855,94"/></clipPath></defs>
|
||||
<rect width="64" height="64" rx="15" fill="#101218"/><rect width="64" height="64" rx="15" fill="url(#fsl0)"/>
|
||||
<g clip-path="url(#fsl2)"><path d="M34 15H9a3 3 0 0 0-3 3v20a3 3 0 0 0 3 3h25z" fill="#101218" stroke="#ECEDF3" stroke-width="3" stroke-linejoin="round"/><rect class="fp-scr" x="10.5" y="19.5" width="24" height="17" rx="1" fill="#3AA8FF" fill-opacity="0.35"/><path d="M18 41v6M11 47h14" stroke="#ECEDF3" stroke-width="3" stroke-linecap="round"/></g>
|
||||
<g clip-path="url(#fsl3)"><path d="M56.5 31.5H58.5" stroke="#ECEDF3" stroke-width="3.4" stroke-linecap="round"/><path d="M22 21h27a8 8 0 0 1 8 8v5a8 8 0 0 1-8 8H48.65a3 3 0 0 1-2.6-1.5l-1-1.7a.9.9 0 0 0-1.6 0l-1 1.7a3 3 0 0 1-2.6 1.5H22z" fill="#101218" stroke="#ECEDF3" stroke-width="3" stroke-linejoin="round"/><g class="fp-lens"><ellipse cx="39.5" cy="30.5" rx="4.2" ry="3.8" fill="#FF8A1F"/><ellipse cx="49" cy="30.5" rx="4.2" ry="3.8" fill="#FF8A1F"/></g></g>
|
||||
<g transform="rotate(18 32 32)"><g class="fp-ptl"><ellipse cx="32" cy="32" rx="4.5" ry="22" fill="#08090C" stroke="#08090C" stroke-width="5.8"/><ellipse cx="32" cy="32" rx="4.5" ry="22" fill="none" stroke="url(#fsl1)" stroke-opacity=".25" stroke-width="6.46" class="fp-halo"/><ellipse cx="32" cy="32" rx="4.5" ry="22" fill="url(#fsl1)" fill-opacity="0.14" stroke="url(#fsl1)" stroke-width="3.4"/></g></g></g>
|
||||
<text x="60" y="25" font-family="Segoe UI, Roboto, 'Helvetica Neue', Arial, sans-serif" font-size="9.5" font-weight="600" letter-spacing="1.4" fill="#A7ABB7">INSTALL WITH</text>
|
||||
<text x="60" y="47" font-family="Segoe UI, Roboto, 'Helvetica Neue', Arial, sans-serif" font-size="18" font-weight="800" fill="#FF8A1F" textLength="53.1" lengthAdjust="spacingAndGlyphs">Frame</text>
|
||||
<g transform="translate(115.25999999999999 29.36) scale(0.8035714285714286)"><g class="fp-ptl"><defs><linearGradient id="fswr" gradientUnits="userSpaceOnUse" x1="2" y1="0" x2="14" y2="0"><stop offset=".3" stop-color="#FF8A1F"/><stop offset=".7" stop-color="#3AA8FF"/></linearGradient></defs>
|
||||
<ellipse cx="8" cy="14" rx="4.4" ry="10.6" transform="rotate(14 8 14)" fill="none" stroke="url(#fswr)" stroke-opacity=".35" stroke-width="5" class="fp-halo"/>
|
||||
<ellipse cx="8" cy="14" rx="4.4" ry="10.6" transform="rotate(14 8 14)" fill="#0D0E12" stroke="url(#fswr)" stroke-width="2.6"/></g></g>
|
||||
<text x="130.27714285714285" y="47" font-family="Segoe UI, Roboto, 'Helvetica Neue', Arial, sans-serif" font-size="18" font-weight="800" fill="#3AA8FF" textLength="36.9" lengthAdjust="spacingAndGlyphs">Port</text></svg>
|
||||
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 146 KiB |
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 146 KiB |
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 365 KiB After Width: | Height: | Size: 417 KiB |
|
After Width: | Height: | Size: 505 KiB |
|
Before Width: | Height: | Size: 917 KiB After Width: | Height: | Size: 667 KiB |
|
After Width: | Height: | Size: 144 KiB |
|
After Width: | Height: | Size: 214 KiB |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 98 KiB |
|
Before Width: | Height: | Size: 916 KiB After Width: | Height: | Size: 561 KiB |
|
Before Width: | Height: | Size: 643 KiB After Width: | Height: | Size: 596 KiB |
|
After Width: | Height: | Size: 846 KiB |
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 93 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 283 KiB |
@@ -0,0 +1,64 @@
|
||||
# The demo library for the docs screenshots and the demo tour (built by scripts/showcase/demo_home.py into an
|
||||
# isolated FRAMEPORT_HOME; see docs/SHOWCASE.md). Real catalog games, so recipes, patches and store art are the
|
||||
# ones FramePort really uses; the technical analysis of each (engine, XR API, libraries, sizes) is in
|
||||
# demo-analyses.json, exported from real APK analyses without any paths. Nothing here is anyone's own data.
|
||||
#
|
||||
# Per game:
|
||||
# frame: on the pretend Frame: internal | sd | outdated (internal, but an older build: "Update on Frame");
|
||||
# left out = not installed
|
||||
# played: last played, days before the render (the Library sorts the "On your Frame" shelf by it)
|
||||
# added: added to the library, days before the render (default 30)
|
||||
# tested: the last launch test passed (default: when installed)
|
||||
# tags: user tags (store genres become tags by themselves)
|
||||
# title: overrides the catalog/store title
|
||||
# art: pick = the art a user gets from Find artwork's Meta result (when the store's own art is a placeholder)
|
||||
|
||||
frame:
|
||||
battery: 82 # %
|
||||
running: com.StressLevelZero.BONELAB # the game the Monitor tab and the sidebar's live card show (it needs
|
||||
# store screenshots: Take screenshot adds one of it)
|
||||
|
||||
games:
|
||||
- package: com.camouflaj.manta
|
||||
frame: internal
|
||||
played: 0.6
|
||||
tags: [Favorites]
|
||||
- package: com.Sanzaru.Wrath2
|
||||
art: pick # the store's image service has a placeholder cover for it: use the picker's Meta result
|
||||
frame: sd
|
||||
played: 1.2
|
||||
tags: [Favorites]
|
||||
- package: com.twistedpixelgames.PILO
|
||||
frame: internal
|
||||
played: 2.4
|
||||
- package: com.StressLevelZero.BONELAB
|
||||
frame: internal
|
||||
played: 0.05
|
||||
- package: com.vertigogames.ImpactDevelopment
|
||||
frame: outdated
|
||||
played: 4.5
|
||||
- package: com.CyanWorlds.Myst
|
||||
frame: sd
|
||||
played: 6
|
||||
- package: com.playful.LuckysTale
|
||||
frame: internal
|
||||
played: 9
|
||||
tags: [Favorites]
|
||||
- package: com.FuturLab.PowerWashSimulator
|
||||
frame: internal
|
||||
played: 12
|
||||
- package: com.CyanWorlds.Riven
|
||||
added: 2
|
||||
- package: com.FireproofStudios.TheRoomVR
|
||||
- package: com.NewFolderGames.IAmCat
|
||||
- package: com.BithellGames.Arcsmith
|
||||
- package: com.zenstudios.PFXVRQuest
|
||||
- package: com.Ubisoft.ACNexusVR
|
||||
- package: com.Solfar.InDeath
|
||||
- package: com.survios.Creed
|
||||
- package: com.crytek.climb2
|
||||
- package: com.thunderful.legobricktales
|
||||
- package: com.GhostlyBirdGames.BattleGlide
|
||||
- package: cn.vr4p.oculus4xvrplayerov
|
||||
- package: rift.rick_and_morty_virtual_rick_ality
|
||||
added: 5
|
||||
@@ -0,0 +1,109 @@
|
||||
# The docs screenshots: scripts/showcase/render_docs.py renders each into docs/images/<name>.png from the demo
|
||||
# library (demo-library.yaml) with a pretend Frame, and rewrites a file only when the picture really changed.
|
||||
# Steps: see scripts/showcase/steps.py. Each shot starts in a fresh window (its own app session).
|
||||
#
|
||||
# viewport: [w, h] browser size in px (default below); scale: UI scale (1.0)
|
||||
# crop: {dialog: true, pad}: the open dialog; {anchor: <name>, left, top, width, height}: a box placed
|
||||
# relative to the top-left corner of the element called <name> (left/top may be negative);
|
||||
# or {x, y, width, height} in page px
|
||||
# docs: where the image is used (checked by the tests: every image a doc shows has an entry here)
|
||||
|
||||
vars:
|
||||
game: com.camouflaj.manta # installed on the pretend Frame
|
||||
new_game: com.CyanWorlds.Riven # in the library, not installed yet
|
||||
|
||||
defaults:
|
||||
viewport: [1280, 820]
|
||||
|
||||
shots:
|
||||
- name: library
|
||||
docs: [README.md]
|
||||
steps:
|
||||
- go: library
|
||||
- wait_for: "On your Frame"
|
||||
- settle: true
|
||||
|
||||
- name: game
|
||||
docs: [docs/INSTALL.md, docs/SHOWCASE.md]
|
||||
viewport: [1280, 1100]
|
||||
steps:
|
||||
- open_game: ${game}
|
||||
- wait_for: "Where it's installed"
|
||||
|
||||
- name: game-settings
|
||||
docs: [docs/INSTALL.md]
|
||||
steps:
|
||||
- open_game: ${game}
|
||||
- call: {fn: settings_dialog, args: ["${game}"]}
|
||||
- wait_for: "Game settings"
|
||||
crop: {dialog: true}
|
||||
|
||||
- name: patches
|
||||
docs: [docs/COMPATIBILITY.md]
|
||||
viewport: [1280, 2600]
|
||||
steps:
|
||||
- open_game: {package: "${game}", advanced: true}
|
||||
- wait_for: "What FramePort will do"
|
||||
crop: {anchor: "What FramePort will do", left: -32, top: -12, width: 1044, height: 820}
|
||||
|
||||
- name: frame
|
||||
docs: [docs/COMPATIBILITY.md]
|
||||
steps:
|
||||
- go: frame
|
||||
- wait_for: "Ready to play"
|
||||
|
||||
- name: files
|
||||
docs: [docs/COMPATIBILITY.md]
|
||||
steps:
|
||||
- go: files
|
||||
- wait_for: "Upload files…"
|
||||
- wait: 1.0
|
||||
- hook: {name: select_files, args: [1, 2]}
|
||||
|
||||
- name: screenshots
|
||||
docs: [README.md]
|
||||
steps:
|
||||
- go: screenshots
|
||||
- wait_for: "Take screenshot"
|
||||
|
||||
- name: screenshot-viewer
|
||||
docs: [README.md]
|
||||
steps:
|
||||
- go: screenshots
|
||||
- wait_for: "Take screenshot"
|
||||
- wait: 1.5
|
||||
- call: {fn: screenshots_view.viewer, args: [0]}
|
||||
- wait_for: "Close"
|
||||
|
||||
- name: type-on-frame
|
||||
docs: [README.md]
|
||||
steps:
|
||||
- hook: type_tab
|
||||
- wait_for: "Keyboard connected"
|
||||
|
||||
- name: monitor
|
||||
docs: [README.md]
|
||||
viewport: [1280, 1150]
|
||||
steps:
|
||||
- go: monitor
|
||||
- wait_for: "Processes"
|
||||
|
||||
# newer screens (docs/SHOWCASE.md's gallery; the README picks what it needs)
|
||||
- name: live-view # idle: a running stream shows its relay's random port and the data rate (no stable picture)
|
||||
docs: [docs/SHOWCASE.md]
|
||||
steps:
|
||||
- go: live
|
||||
- wait_for: "What the player sees"
|
||||
|
||||
- name: install-progress
|
||||
docs: [docs/SHOWCASE.md]
|
||||
steps:
|
||||
- hook: {name: held_install, args: ["${new_game}"]}
|
||||
- open_game: ${new_game}
|
||||
- wait_for: "Cancel"
|
||||
|
||||
- name: appearance
|
||||
docs: [docs/SHOWCASE.md]
|
||||
steps:
|
||||
- go: settings
|
||||
- wait_for: "Portal (OLED)"
|
||||
@@ -0,0 +1,125 @@
|
||||
# The install tutorial: from the download to the first game on the Steam Frame (docs/INSTALL.md links it; every
|
||||
# release attaches it as FramePort-install.mp4). FramePort starts as on a new computer (the "fresh" demo profile:
|
||||
# empty library, welcome screen, no Frame set up); what happens outside FramePort (the download, a command typed
|
||||
# on the Frame) is told on instruction cards. Recorded by scripts/showcase/record_video.py; the format is in
|
||||
# docs/SHOWCASE.md ("Videos").
|
||||
|
||||
output: docs/media/frameport-install.mp4
|
||||
budget_mb: 12
|
||||
poster_at: 9
|
||||
start:
|
||||
profile: fresh # FramePort's first start
|
||||
frame: disconnected # the Frame isn't set up yet
|
||||
route: welcome
|
||||
setup:
|
||||
- hook: {name: first_run, args: ["D:/Games", 1.4]} # the tool download and the folder scan, at a watchable pace
|
||||
|
||||
vars:
|
||||
game: com.playful.LuckysTale
|
||||
|
||||
title:
|
||||
heading: Installing FramePort
|
||||
line: From the download to your first game on the Steam Frame
|
||||
seconds: 3.4
|
||||
end:
|
||||
heading: You're set
|
||||
line: Your game is in the Frame's Steam library. More help in docs/INSTALL.md
|
||||
footer: github.com/spoopyghosty0/frameport
|
||||
seconds: 4.0
|
||||
|
||||
scenes:
|
||||
- name: download
|
||||
seconds: 7.5
|
||||
card:
|
||||
eyebrow: "Step 1 · On your computer"
|
||||
heading: Download FramePort
|
||||
steps:
|
||||
- "Open **github.com/spoopyghosty0/frameport** → **Releases** → the latest one"
|
||||
- "Download the archive for your computer: **FramePort-windows-x64.zip**, **FramePort-macos-arm64.zip** or **FramePort-linux-x64.tar.gz**"
|
||||
- "Extract it anywhere. There's no installer and no admin rights are needed"
|
||||
|
||||
- name: first-start
|
||||
seconds: 7.5
|
||||
card:
|
||||
eyebrow: "Step 2 · First start"
|
||||
heading: Start FramePort
|
||||
steps:
|
||||
- "**Windows:** open **FramePort.exe**. At “Windows protected your PC” choose **More info** → **Run anyway**"
|
||||
- "**macOS:** right-click **FramePort.app** → **Open** → **Open**"
|
||||
- "**Linux:** run **FramePort/FramePort**"
|
||||
note: "FramePort is signed with a free certificate, so your system asks once."
|
||||
|
||||
- name: welcome
|
||||
caption: ["FramePort gets itself ready", "It downloads the tools it uses (Java, OVRPort, apksigner) by itself"]
|
||||
hold: 1.0
|
||||
steps:
|
||||
- wait: 1.0
|
||||
- hook: {name: wait_jobs, args: [40]}
|
||||
- wait_for: "Java, OVRPort and apksigner are ready."
|
||||
- wait: 1.0
|
||||
|
||||
- name: connect
|
||||
caption: ["Connect your Steam Frame", "Once: FramePort shows a command to run on the Frame"]
|
||||
hold: 1.5
|
||||
steps:
|
||||
- click: "Set up the Frame"
|
||||
- wait: 1.6
|
||||
- click: "Show setup command"
|
||||
- wait_for: "Waiting for your Frame"
|
||||
- wait: 1.0
|
||||
- hover: "Copy"
|
||||
- wait: 1.4
|
||||
|
||||
- name: on-the-frame
|
||||
seconds: 10
|
||||
card:
|
||||
eyebrow: "Step 3 · On the Frame, first time only"
|
||||
heading: Run the setup command
|
||||
steps:
|
||||
- "In the SteamVR dashboard: **Launch a program** → **Desktop**"
|
||||
- "Open the app menu (bottom left) → **System** → **Konsole**"
|
||||
- "Type the command FramePort shows and press **Enter**"
|
||||
code: "curl -fsS <your-PC-address>:8765/<one-time-code> | bash"
|
||||
note: "FramePort shows your PC's address and a one-time code in place of **<…>**. The desktop closes by itself after a few seconds (Steam restarts once); if Steam asks to install **Lepton**, confirm it. No password is needed."
|
||||
|
||||
- name: connected
|
||||
caption: ["Your Frame is connected", "From now on FramePort finds it by itself"]
|
||||
hold: 1.2
|
||||
steps:
|
||||
- hook: {name: pairing_done, args: [1.6]}
|
||||
- wait_for: "Ready to play"
|
||||
- wait: 1.2
|
||||
- hover: "Quest games (Lepton)"
|
||||
- wait: 1.6
|
||||
|
||||
- name: add-games
|
||||
caption: ["Add your games", "Point FramePort at the folder with your games"]
|
||||
hold: 1.0
|
||||
steps:
|
||||
- nav: "Library"
|
||||
- wait: 1.2
|
||||
- click: "Scan a folder…"
|
||||
- hook: {name: wait_jobs, args: [40]}
|
||||
- wait: 1.2
|
||||
- hover: {name: "Lucky's Tale", dy: 0.3}
|
||||
- wait: 1.0
|
||||
|
||||
- name: install
|
||||
caption: ["Install a game", "FramePort patches it, installs it and adds it to the Frame's Steam library"]
|
||||
hold: 1.2
|
||||
steps:
|
||||
- click: {name: "Lucky's Tale", dy: 0.35} # (the title: the card's middle is its Install button)
|
||||
- wait_for: "Where it's installed" # (the game page: a click that missed fails here)
|
||||
- wait: 1.2
|
||||
- click: "Install on Frame"
|
||||
- wait: 0.6
|
||||
- move: [860, 640]
|
||||
- hook: {name: wait_jobs, args: [45]}
|
||||
- wait: 1.0
|
||||
|
||||
- name: play
|
||||
caption: ["Play", "Start it from FramePort, or from Steam in the headset"]
|
||||
steps:
|
||||
- click: "Play on Frame"
|
||||
- wait: 2.6
|
||||
- park: true
|
||||
@@ -0,0 +1,134 @@
|
||||
# The demo tour: FramePort in use (README teaser, docs/media, every release as FramePort-tour.mp4).
|
||||
# Recorded by scripts/showcase/record_video.py; the storyboard format is in docs/SHOWCASE.md ("Videos").
|
||||
|
||||
output: docs/media/frameport-tour.mp4
|
||||
teaser: docs/images/tour-teaser.webp
|
||||
budget_mb: 12
|
||||
start:
|
||||
profile: demo # the library in use: games installed on the pretend Frame, BONELAB running
|
||||
frame: connected
|
||||
|
||||
vars:
|
||||
game: com.camouflaj.manta # installed on the pretend Frame
|
||||
new_game: com.CyanWorlds.Riven # installed during the tour
|
||||
|
||||
title:
|
||||
heading: FramePort
|
||||
line: Quest, Android and PC VR games on the Steam Frame
|
||||
seconds: 3.2
|
||||
end:
|
||||
heading: FramePort
|
||||
line: Open source · bring your own games
|
||||
footer: github.com/spoopyghosty0/frameport
|
||||
seconds: 3.6
|
||||
|
||||
scenes:
|
||||
- name: library
|
||||
caption: ["Your library, ready for the Frame", "Quest, Android and PC VR games from your own folders"]
|
||||
teaser: [0.8, 3.2]
|
||||
steps:
|
||||
- go: library
|
||||
- wait: 1.2
|
||||
- hover: {name: "Batman: Arkham Shadow", dy: 0.3}
|
||||
- wait: 1.0
|
||||
- hover: {name: "Marvel's Deadpool VR", dy: 0.3}
|
||||
- wait: 0.8
|
||||
- hover: "Assassin's Creed Nexus"
|
||||
- wait: 0.8
|
||||
- hover: "Lucky's Tale"
|
||||
- wait: 0.8
|
||||
- park: true
|
||||
- type: "ri"
|
||||
- wait: 1.6
|
||||
|
||||
- name: game
|
||||
caption: ["Every game gets its own recipe", "Known-good fixes from the catalog, or suggested from the game itself"]
|
||||
steps:
|
||||
- click: {name: "Riven", dy: 0.35} # (the title: the card's middle is its Install button)
|
||||
- wait: 1.8
|
||||
- hover: "Works"
|
||||
- wait: 0.7
|
||||
- scroll: {dy: 420, at: [860, 560]}
|
||||
- wait: 1.2
|
||||
- scroll: {dy: -420, at: [860, 560]}
|
||||
- wait: 0.5
|
||||
|
||||
- name: install
|
||||
caption: ["One click to install", "Patched, signed, uploaded, added to Steam and launch-tested"]
|
||||
teaser: [0.6, 4.0]
|
||||
hold: 1.2
|
||||
steps:
|
||||
- click: "Install on Frame"
|
||||
- wait: 0.6
|
||||
- move: [860, 640]
|
||||
- hook: {name: wait_jobs, args: [45]}
|
||||
- wait: 1.0
|
||||
|
||||
- name: play
|
||||
caption: ["Play from your PC", "Starts the game in the headset through Steam"]
|
||||
teaser: [4.3, 3.2]
|
||||
steps:
|
||||
- nav: "Library"
|
||||
- call: library_view.clear_search
|
||||
- wait: 1.4
|
||||
- hover: {name: "Asgard's Wrath 2", dy: 0.3}
|
||||
- wait: 0.6
|
||||
- hover: {name: "Batman: Arkham Shadow", dy: 0.3}
|
||||
- wait: 0.6
|
||||
- click: {name: "Play on Frame", nth: 0}
|
||||
- wait: 2.6
|
||||
- park: true
|
||||
- wait: 0.4
|
||||
|
||||
- name: monitor
|
||||
caption: ["See what the Frame is doing", "Frame rate, CPU, GPU, temperatures and every process, live"]
|
||||
teaser: [0.5, 2.6]
|
||||
steps:
|
||||
- nav: "Monitor"
|
||||
- wait: 2.4
|
||||
- hover: "Temperature" # (a tile only: "GPU" is also the process table's sortable column)
|
||||
- wait: 1.0
|
||||
- hover: "Battery"
|
||||
- wait: 1.0
|
||||
- click: "Show details"
|
||||
- wait: 1.8
|
||||
- park: true
|
||||
|
||||
- name: screenshots
|
||||
caption: ["Screenshots from the headset", "Take one from the PC, then view or download them"]
|
||||
steps:
|
||||
- nav: "Screenshots"
|
||||
- wait: 1.6
|
||||
- click: "Take screenshot"
|
||||
- wait_for: "BONELAB · 2026-10-04 21:50"
|
||||
- wait: 0.8
|
||||
- click: "BONELAB · 2026-10-04 21:50"
|
||||
- wait: 2.0
|
||||
- click: "Close"
|
||||
- wait: 0.4
|
||||
|
||||
- name: files
|
||||
caption: ["Files on the Frame", "Videos, mods and saves: upload, download, select with a drag"]
|
||||
steps:
|
||||
- nav: "Files"
|
||||
- wait: 1.6
|
||||
- drag: ["Concert 8K 3D.mp4", "Mars landing (VR180).mkv"]
|
||||
- wait: 1.0
|
||||
- right_click: "Earth from orbit (360).mp4"
|
||||
- wait: 1.4
|
||||
- press: Escape
|
||||
- wait: 0.6
|
||||
|
||||
- name: themes
|
||||
caption: ["Make it yours", "Dark themes, including true black for OLED screens"]
|
||||
steps:
|
||||
- nav: "Settings"
|
||||
- wait: 1.4
|
||||
- click: "Portal (OLED)"
|
||||
- wait: 1.4
|
||||
- click: "Original"
|
||||
- wait: 1.4
|
||||
- click: "Portal"
|
||||
- wait: 1.0
|
||||
- nav: "Library"
|
||||
- wait: 1.4
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "Ember & Ice",
|
||||
"base": "portal",
|
||||
"dual": true,
|
||||
"colors": {
|
||||
"ACCENT": "#FF5A36",
|
||||
"ACCENT_SOFT": "#3A1710",
|
||||
"SECONDARY": "#5CE1E6",
|
||||
"SECONDARY_SOFT": "#0E3033",
|
||||
"PC": "#5CE1E6",
|
||||
"INFO": "#5CE1E6"
|
||||
}
|
||||
}
|
||||
@@ -11,14 +11,15 @@ embeds debug paths (`-g`) and the dex depends on the d8 version, so those differ
|
||||
|
||||
| Dir | Artifact | What / why |
|
||||
|---|---|---|
|
||||
| `adapter/` | `{arm64-v8a,armeabi-v7a}/libopenxr_loader_generic.so` | **FrameBridge**: replaces overport's generic loader (which is renamed `libopenxr_loader_original.so`) and fixes Steam Frame runtime gaps. Hooks xrCreateInstance, swapchains, xrEndFrame, spaces, xrPollEvent, … everything else is forwarded by `gen_forwarders.py`-generated tail calls. `scene_emu.c` = Meta scene/spatial-entity emulation; `flip_vk.c` = Vulkan blit for VERTICAL_FLIP quads. `session_fixes.c` = per-game session fixes, all off by default and hooked only when on (`layer_debug` diagnostics, `stable_local`, `focus_hold`, aim correction `aim_pitch/aim_yaw/aim_forward`, `refresh_rate`); `layer_emul_gl.c` = `equirect_emul` (GLES sessions only): 360° equirect/equirect2 layers become one adapter projection layer, drawn by a worker thread with its own EGL context shared with the app's: each 360° image is converted to a cube map only when it changes, and the view is redrawn only after a 4° head turn (GL/EGL resolved with dlopen, so Vulkan games never load them); `layer_math.h` = their pose/face math, tested on the host by `tests/test_layer_emul.py`. `render_model.c` = XR_FB_render_model emulation (setting `controller_models`, off by default): serves `files/framebridge/controller_{left,right}.glb`, which the agent converts on the Frame from SteamVR's own Frame controller render models (never shipped by FramePort); tested on the host by `tests/test_render_model.py`. Settings: `libframe_settings.so` in the APK + `settings.conf`/`framebridge.conf` on the Frame. |
|
||||
| `vrapi-bridge/` | `arm64-v8a/libvrapi.so` | VrApi → OpenXR bridge from [Android-XR-Bridge/OVRPort](https://github.com/Android-XR-Bridge/OVRPort) `native/vrapi` at 5e7df52 (GPL-3.0, `LICENSE.upstream`; unchanged upstream as of OVRPort v1.2.5, which ships the unpatched code as its opt-in `patch_vrapi_openxr` in experimental CLI builds), with our changes in `upstream-patches/`: GLES sessions + GL texture swapchains, cylinder→quad layers, GL vertical flip, UNORM↔sRGB format twins, 30 s VR-mode deadline, VALID-only recenter, loading-icon layers skipped, `vrapi_PollEvent`/`RecenterPose`/`SetDisplayRefreshRate`/`GetSystemPropertyFloatArray` (BlazeRush imports them, GitHub #57), diagnostics behind `-DOVP_GL_DIAG`. `upstream-patches/` reproduces these sources from the fork's `native/vrapi` (checked 2026-10-06 against its latest commit). |
|
||||
| `adapter/` | `{arm64-v8a,armeabi-v7a}/libopenxr_loader_generic.so` | **FrameBridge**: replaces overport's generic loader (which is renamed `libopenxr_loader_original.so`) and fixes Steam Frame runtime gaps. Hooks xrCreateInstance, swapchains, xrEndFrame, spaces, xrPollEvent, … everything else is forwarded by `gen_forwarders.py`-generated tail calls. `scene_emu.c` = Meta scene/spatial-entity emulation; `flip_vk.c` = Vulkan blit for VERTICAL_FLIP quads. `session_fixes.c` = per-game session fixes, all off by default and hooked only when on (`layer_debug` diagnostics, `stable_local`, `focus_hold`, aim correction `aim_pitch/aim_yaw/aim_forward`, `refresh_rate`); `input_diag.c` = controller-input diagnostics (setting `input_diag`, off by default and hooked only when on; logs suggested interaction profiles and the runtime's answers, each hand's current profile, functions the runtime lacks and failing input/haptics/perf calls, each line once; tested on the host by `tests/test_input_diag.py`); `layer_emul_gl.c` = `equirect_emul` (GLES sessions only): 360° equirect/equirect2 layers become one adapter projection layer, drawn by a worker thread with its own EGL context shared with the app's: each 360° image is converted to a cube map only when it changes, and the view is redrawn only after a 4° head turn (GL/EGL resolved with dlopen, so Vulkan games never load them); `layer_math.h` = their pose/face math, tested on the host by `tests/test_layer_emul.py`. `render_model.c` = XR_FB_render_model emulation (setting `controller_models`, off by default): serves `files/framebridge/controller_{left,right}.glb`, which the agent converts on the Frame from SteamVR's own Frame controller render models (never shipped by FramePort); tested on the host by `tests/test_render_model.py`. Settings: `libframe_settings.so` in the APK + `settings.conf`/`framebridge.conf` on the Frame. |
|
||||
| `vrapi-bridge/` | `arm64-v8a/libvrapi.so` | VrApi → OpenXR bridge from [Android-XR-Bridge/OVRPort](https://github.com/Android-XR-Bridge/OVRPort) `native/vrapi` at 5e7df52 (GPL-3.0, `LICENSE.upstream`; unchanged upstream as of OVRPort v1.2.5, which ships the unpatched code as its opt-in `patch_vrapi_openxr` in experimental CLI builds), with our changes in `upstream-patches/`: GLES sessions + GL texture swapchains, cylinder→quad layers, GL vertical flip, UNORM↔sRGB format twins, 30 s VR-mode deadline, VALID-only recenter, loading-icon layers skipped, `vrapi_PollEvent`/`RecenterPose`/`SetDisplayRefreshRate`/`GetSystemPropertyFloatArray` (BlazeRush imports them, GitHub #57), diagnostics behind `-DOVP_GL_DIAG`. `upstream-patches/` reproduces these sources from the fork's `native/vrapi` (checked 2026-10-06 against its latest commit); upstream PRs Android-XR-Bridge/OVRPort#3-#8, tracked in GitHub #75. |
|
||||
| `platformcompat/` | `arm64-v8a/libovrplatformcompat.so` | Real `ovrMessageType_ToString` (same fork, `native/platform`). |
|
||||
| `langpack/` | `arm64-v8a/libfp_langpack.so` | Language packs for the Meta Platform SDK (patch `frame.langpacks`, opt-in). overport's platform loader is a dispatcher in front of Meta's own loader and answers `ovr_LanguagePack_GetCurrent/SetCurrent` with `return 0` (no reply ever). This library becomes the loader's first DT_NEEDED; the loader's own exports of the 31 functions it defines are made STB_LOCAL in `.dynsym` (`elf.hide_exports`, nothing moves), so symbol lookups reach the library first. It serves `<tag>.lang` files found in the game's OBB / app files (`$FRAMEPORT_LANGPACK_DIRS` overrides the search path) through `ovr_LanguagePack_*`, `ovr_AssetFile_GetList` (the loader's list + the packs) and `ovr_AssetFile_StatusById`; its own message queue is merged into `ovr_PopMessage`, and every handle that is not ours (an address-range check) goes to the loader's original function, whose address is read at run time from the loader's in-memory `.dynsym`. With patch `frame.asset_files` (marker byte `@FPASSETS@`, or env `FRAMEPORT_ASSET_FILES=1`) it also lists the data's `*.pak` content files as installed `default` asset files and answers `ovr_AssetFile_DownloadById` for them at once (a completed `DownloadUpdate`, then the result with the path). Host-tested against a stand-in loader (`tests/test_langpack.py`, plain `cc`, no NDK); the bionic/headset side is unverified. |
|
||||
| `glshim/` | `arm64-v8a/libglshim.so` | Mesa GLSL compatibility for GLAD engines (hooks eglGetProcAddress): comments out `#pragma` before `#extension`, enables `GL_EXT_shader_implicit_conversions`, hides GL_OVR_multiview (`gl_hide_multiview`, default 1) and logs failed shaders. `-DGLSHIM_TRACE` adds per-FBO draw/error tracing. |
|
||||
| `xrlayer/` | `linux-arm64/libxr_frameport_timefix.so` + `XR_APILAYER_FRAMEPORT_timefix.json` | OpenXR API layer for Windows PC VR games under Proton on the Frame (glibc aarch64, built freestanding with the NDK's clang), on by default (patch `pcvr.xr_timefix`). Retries `xrCreateInstance` as an OpenXR 1.0 app when the runtime rejects 1.1 (the Frame's SteamVR runtime does, and Proton 11's VR helper asks for 1.1). Also emulates `xrConvertTimespecTimeToTimeKHR`/`xrConvertTimeToTimespecTimeKHR` if the runtime refuses them (the Frame's Android runtime does; its Linux runtime, used by Proton, supports them as of 2026-09-29 — so this part is only a fallback; Proton's wineopenxr needs them for `XR_KHR_win32_convert_performance_counter_time`, which Revive requires) with the adapter's xrWaitFrame-calibrated offset, and drops the extension from xrCreateInstance if the runtime rejects it. Enabled per game by the Proton launch.sh (`XR_API_LAYER_PATH`, `XR_ENABLE_API_LAYERS`). `tests/test_xrlayer.py` builds it for x86_64 and drives it via ctypes. |
|
||||
| `oculushmd/` | `win-x64/fp_oculushmd.exe` | PC VR counterpart of overport's `patch_oculus_unreal` (patch `pcvr.oculus_unreal`, default for Unreal Rift games on the Frame). Unreal's OculusHMD and LibOVR's `ovr_Detect` only start when the Windows named event `OculusHMDConnected` exists and is signalled (the Oculus service creates it). `fp_oculushmd.exe <command line>` creates it (manual reset, signalled), runs the command (Revive's injector) in a job object and keeps the event until every process in the job — the game and its children — has exited (fallback without job support: 3 minutes); returns the command's exit code and logs `FramePort oculushmd: …` to stderr (launch.log). Freestanding Windows x64 console exe (no CRT, no Windows SDK): the NDK's clang + `lld-link /Brepro` with a kernel32 import library generated by `llvm-dlltool`, so it's byte-reproducible. Tested on Windows from WSL with a build whose event name is `-DEVENT_NAME=L"…"` (the Oculus service owns the real event on a PC with the Oculus app). |
|
||||
| `xrshim/` | `arm64-v8a/libframe_xrshim.so` | FrameBridge extension shim, only in builds with `controller_models=1`. overport's dispatcher (`libopenxr_loader.so`) answers `xrGetInstanceProcAddr` from a fixed table and refuses everything else (`overportOXR: Unknown proc addr: xrLoadRenderModelFB`), so the adapter never sees XR_FB_render_model lookups. Meta's OVRPlugin gets the function with `dlopen("libopenxr_loader.so")` + `dlsym`, so FramePort rewrites that `.rodata` string in `libOVRPlugin.so` (same length, in place) to `libframe_xrshim.so`. The shim returns the adapter's emulated functions (`framebridge_extension_proc`) and forwards every other name to overport. A DT_NEEDED interposer does not work here (dlsym on a handle searches that library first); tried and dropped. |
|
||||
| `venc/` | `linux-arm64-bin/fp_venc` | Hardware H.264 encoder for the live view, run on the Frame (spec: `venc/SPEC.md`). Reads SteamVR's "headset view" webcam (v4l2loopback `/dev/video99`, RGB24), box-scales and converts it to NV12 (BT.709 limited range; `convert.c`, NEON with a bit-identical scalar reference, also built for x86_64 by the host test), and feeds the SoC's V4L2 stateful encoder (`dev-encoder.rst`, Qualcomm iris `/dev/video-enc0`): CBR, no B-frames, SPS/PPS on every IDR, one frame per slot of a fixed grid (fps = a divisor of the panel refresh read through DRM KMS, default cap 45), Annex B on stdout. stdin `k` = keyframe, `q`/EOF = drain and stop; `--probe` prints the setup as JSON, `--selftest` compares NEON and scalar output. Fully static and freestanding (raw syscalls, own `_start`; only the NDK's kernel UAPI headers, staged in `.cache/uapi-arm64`), byte-reproducible. Lives in `linux-arm64-bin/` because `linux-arm64/` is uploaded whole as the OpenXR layer. |
|
||||
| `java-stubs/` | `dex/oculusos-stubs.dex` | No-op `com.oculus.os.AnalyticsEvent` / `UnifiedTelemetryLogger` for native code that looks them up. |
|
||||
|
||||
The ovr_* stub library is *not* prebuilt: `src/frameport/analysis/stubgen.py` generates it per game from the exact
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
// render_model.c);
|
||||
// * per-game session fixes (session_fixes.c, all off by default): layer_debug diagnostics, stable_local,
|
||||
// focus_hold, aim pose correction (aim_pitch/aim_yaw/aim_forward), refresh_rate;
|
||||
// * optionally logs controller-input diagnostics: suggested interaction profiles and the runtime's answers, each
|
||||
// hand's current profile, functions the runtime lacks, failing input/haptics/perf calls (input_diag,
|
||||
// input_diag.c, off by default);
|
||||
// * optionally shows 360° (equirect/equirect2) layers as cube-face quads drawn by a worker thread with a shared
|
||||
// GLES context (equirect_emul, layer_emul_gl.c; GLES sessions only, off by default).
|
||||
//
|
||||
@@ -125,6 +128,7 @@ static int controller_models; // serve Frame controller models via XR_FB_render
|
||||
static int sync_guard; // xrSyncActions one at a time with xrPollEvent, paused briefly after focus returns
|
||||
static int profile_remap = 1; // Meta's newer controller profiles (rejected by the Frame) -> oculus/touch_controller
|
||||
static int layer_debug; // diagnostics: layers, swapchains, session states, spaces, aim/grip, refresh rates
|
||||
static int input_diag; // diagnostics: controller profiles, bindings, missing functions, failing input calls
|
||||
static int stable_local; // keep every LOCAL space the app creates on the session-start origin
|
||||
static int focus_hold = 1; // hide brief focus dips once the session has been focused for a while
|
||||
static float focus_hold_ms = 5000; // longest focus dip focus_hold hides
|
||||
@@ -171,6 +175,7 @@ static void read_settings(const char *path) {
|
||||
if (sscanf(line, "scene_depth=%f", &value) == 1 && value > 0.5f && value < 20.0f) scene_depth = value;
|
||||
if (sscanf(line, "controller_models=%f", &value) == 1) controller_models = value != 0;
|
||||
if (sscanf(line, "layer_debug=%f", &value) == 1) layer_debug = value != 0;
|
||||
if (sscanf(line, "input_diag=%f", &value) == 1) input_diag = value != 0;
|
||||
if (sscanf(line, "surface_emul=%f", &value) == 1) surface_emul = value != 0;
|
||||
if (sscanf(line, "eye_debug=%f", &value) == 1) eye_debug = value != 0;
|
||||
if (sscanf(line, "release_wait=%f", &value) == 1) release_wait = (int)value;
|
||||
@@ -234,6 +239,7 @@ static void initialize(void) {
|
||||
snprintf(path, sizeof(path), "/sdcard/Android/data/%s/files/framebridge.log", process);
|
||||
log_file = fopen(path, "a");
|
||||
}
|
||||
if (input_diag) LOG("per-game: input_diag=1 (controller-input diagnostics)");
|
||||
if (hide_space_warp) LOG("per-game: hide_space_warp=1 (XR_FB_space_warp hidden, space warp info removed)");
|
||||
if (strip_color_bias) LOG("per-game: strip_color_bias=%d (layer color scale/bias removed)", strip_color_bias);
|
||||
if (frame_balance) LOG("per-game: frame_balance=1 (an open frame is ended before the next one begins)");
|
||||
@@ -820,6 +826,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrDestroySpace(XrSpace space) {
|
||||
return fn ? fn(space) : XR_ERROR_FUNCTION_UNSUPPORTED;
|
||||
}
|
||||
|
||||
#include "input_diag.c"
|
||||
#include "session_fixes.c"
|
||||
#include "layer_emul_gl.c"
|
||||
#include "snapshot_gl.c"
|
||||
@@ -873,8 +880,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrCreateSession(XrInstance instance, const XrSess
|
||||
// Vibrations: logged (the first few, to see what games ask for) and scaled by haptic_scale. Plain vibrations, Meta's
|
||||
// amplitude envelopes and PCM buffers all pass here: games' own calls, OVRPort's VrApi bridge and the xrshim alike.
|
||||
static int haptics_logged;
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrApplyHapticFeedback(XrSession session, const XrHapticActionInfo *info,
|
||||
const XrHapticBaseHeader *feedback) {
|
||||
static XrResult apply_haptics(XrSession session, const XrHapticActionInfo *info, const XrHapticBaseHeader *feedback) {
|
||||
PFN_xrApplyHapticFeedback fn = (PFN_xrApplyHapticFeedback)lookup(active_instance, "xrApplyHapticFeedback");
|
||||
if (!fn) return XR_ERROR_FUNCTION_UNSUPPORTED;
|
||||
if (!feedback) return fn(session, info, feedback);
|
||||
@@ -919,6 +925,15 @@ XRAPI_ATTR XrResult XRAPI_CALL xrApplyHapticFeedback(XrSession session, const Xr
|
||||
return fn(session, info, feedback);
|
||||
}
|
||||
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrApplyHapticFeedback(XrSession session, const XrHapticActionInfo *info,
|
||||
const XrHapticBaseHeader *feedback) {
|
||||
XrResult result = apply_haptics(session, info, feedback);
|
||||
if (input_diag && XR_FAILED(result)) // always hooked (haptic_scale), so input_diag reports failures here
|
||||
diag_call_failed("xrApplyHapticFeedback", result,
|
||||
feedback && feedback->type != XR_TYPE_HAPTIC_VIBRATION ? "(not XrHapticVibration)" : NULL);
|
||||
return result;
|
||||
}
|
||||
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrEnumerateSwapchainImages(XrSwapchain swapchain, uint32_t capacity, uint32_t *count,
|
||||
XrSwapchainImageBaseHeader *images) {
|
||||
PFN_xrEnumerateSwapchainImages fn = (PFN_xrEnumerateSwapchainImages)lookup(active_instance, "xrEnumerateSwapchainImages");
|
||||
@@ -1573,6 +1588,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrGetCurrentInteractionProfile(XrSession session,
|
||||
(PFN_xrGetCurrentInteractionProfile)lookup(active_instance, "xrGetCurrentInteractionProfile");
|
||||
if (!fn) return XR_ERROR_FUNCTION_UNSUPPORTED;
|
||||
XrResult result = fn(session, user, state);
|
||||
if (input_diag && XR_SUCCEEDED(result) && state) input_diag_current_profile(user, state->interactionProfile);
|
||||
if (layer_debug && active_instance) { // which device each hand has, as the runtime reports it
|
||||
PFN_xrPathToString str = (PFN_xrPathToString)lookup(active_instance, "xrPathToString");
|
||||
char who[XR_MAX_PATH_LENGTH] = "?", what[XR_MAX_PATH_LENGTH] = "(none)";
|
||||
@@ -1726,15 +1742,22 @@ XRAPI_ATTR XrResult XRAPI_CALL xrGetInstanceProcAddr(XrInstance instance, const
|
||||
HOOK(xrWaitSwapchainImage)
|
||||
HOOK(xrReleaseSwapchainImage)
|
||||
}
|
||||
if (sync_guard || layer_debug) HOOK_AS(xrSyncActions, hook_xrSyncActions)
|
||||
if (sync_guard || layer_debug || input_diag) HOOK_AS(xrSyncActions, hook_xrSyncActions)
|
||||
if (layer_debug) HOOK_AS(xrGetActionStateBoolean, hook_xrGetActionStateBoolean)
|
||||
if (layer_debug || aim_correction_on() || profile_remap)
|
||||
if (layer_debug || aim_correction_on() || profile_remap || input_diag)
|
||||
HOOK_AS(xrSuggestInteractionProfileBindings, hook_xrSuggestInteractionProfileBindings)
|
||||
if (layer_debug || aim_correction_on()) {
|
||||
HOOK_AS(xrCreateActionSpace, hook_xrCreateActionSpace)
|
||||
}
|
||||
#undef HOOK_AS
|
||||
#undef HOOK
|
||||
if (input_diag) { // logs only: wraps a few input/haptics/perf calls, notes lookups the runtime can't answer
|
||||
PFN_xrVoidFunction diag = input_diag_hook(name);
|
||||
XrResult result = next_gipa(instance, name, function);
|
||||
input_diag_lookup(instance, name, result, *function);
|
||||
if (diag && XR_SUCCEEDED(result) && *function) *function = diag;
|
||||
return result;
|
||||
}
|
||||
return next_gipa(instance, name, function);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Included by frame_adapter.c (before session_fixes.c). input_diag: controller-input diagnostics, off by default and
|
||||
// hooked only when on; logs only, never changes what the game or the runtime sees. Each distinct line is logged once:
|
||||
// * every interaction profile the game suggests bindings for, with the runtime's answer; a rejected profile lists
|
||||
// all its binding paths ("unsupported: interaction profile ...");
|
||||
// * the profile the runtime reports for each hand (xrGetCurrentInteractionProfile, before controller_fix rewrites
|
||||
// the answer for the game): a game without a Steam Frame binding gets SteamVR's Touch remap, so this shows
|
||||
// whether the game's input runs through it;
|
||||
// * functions the game looks up that the runtime doesn't provide ("unsupported: function ...");
|
||||
// * failing input, haptics and performance calls with the result name and the argument that failed.
|
||||
|
||||
#define DIAG_MAX 512
|
||||
#define DIAG_KEY (2 * XR_MAX_PATH_LENGTH + 32)
|
||||
static uint64_t diag_seen[DIAG_MAX]; // FNV-1a hashes of the keys already logged
|
||||
static int diag_count;
|
||||
static pthread_mutex_t diag_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static int diag_first(const char *key) { // 1 the first time `key` is seen; 0 for everything after DIAG_MAX keys
|
||||
uint64_t hash = 14695981039346656037ull;
|
||||
for (const unsigned char *c = (const unsigned char *)key; *c; ++c) hash = (hash ^ *c) * 1099511628211ull;
|
||||
pthread_mutex_lock(&diag_lock);
|
||||
int first = 1;
|
||||
for (int i = 0; i < diag_count && first; ++i) first = diag_seen[i] != hash;
|
||||
if (first && diag_count < DIAG_MAX) diag_seen[diag_count++] = hash;
|
||||
else if (first) { // full: stop rather than repeat a per-frame failure
|
||||
static int full;
|
||||
if (!full) { full = 1; LOG("input_diag: %d distinct findings, logging no more", DIAG_MAX); }
|
||||
first = 0;
|
||||
}
|
||||
pthread_mutex_unlock(&diag_lock);
|
||||
return first;
|
||||
}
|
||||
|
||||
static const char *diag_result_name(XrResult result, char *buf, size_t size) {
|
||||
PFN_xrResultToString fn =
|
||||
active_instance ? (PFN_xrResultToString)lookup(active_instance, "xrResultToString") : NULL;
|
||||
char name[XR_MAX_RESULT_STRING_SIZE];
|
||||
if (fn && XR_SUCCEEDED(fn(active_instance, result, name))) snprintf(buf, size, "%s", name);
|
||||
else snprintf(buf, size, "%d", result);
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void diag_call_failed(const char *fn, XrResult result, const char *detail) {
|
||||
char key[DIAG_KEY], name[XR_MAX_RESULT_STRING_SIZE];
|
||||
snprintf(key, sizeof(key), "%s:%d:%s", fn, result, detail ? detail : "");
|
||||
if (diag_first(key))
|
||||
LOG("input_diag: unsupported: %s -> %s%s%s", fn, diag_result_name(result, name, sizeof(name)),
|
||||
detail ? " " : "", detail ? detail : "");
|
||||
}
|
||||
|
||||
// Called by hook_xrSuggestInteractionProfileBindings with the runtime's answer to the game's own suggestion (before
|
||||
// profile_remap suggests it again for Touch).
|
||||
static void input_diag_suggested(XrInstance instance, const XrInteractionProfileSuggestedBinding *suggested,
|
||||
XrResult result, PFN_xrPathToString to_string) {
|
||||
if (!input_diag || !suggested || !to_string) return;
|
||||
char profile[XR_MAX_PATH_LENGTH] = "?", key[DIAG_KEY], name[XR_MAX_RESULT_STRING_SIZE];
|
||||
uint32_t size = 0;
|
||||
to_string(instance, suggested->interactionProfile, sizeof(profile), &size, profile);
|
||||
snprintf(key, sizeof(key), "suggest:%s:%d", profile, result);
|
||||
if (!diag_first(key)) return;
|
||||
if (XR_SUCCEEDED(result)) {
|
||||
LOG("input_diag: bindings: %s accepted (%u paths)", profile, suggested->countSuggestedBindings);
|
||||
return;
|
||||
}
|
||||
LOG("input_diag: unsupported: interaction profile %s -> %s (%u bindings):", profile,
|
||||
diag_result_name(result, name, sizeof(name)), suggested->countSuggestedBindings);
|
||||
for (uint32_t i = 0; i < suggested->countSuggestedBindings; ++i) {
|
||||
char path[XR_MAX_PATH_LENGTH];
|
||||
if (XR_SUCCEEDED(to_string(instance, suggested->suggestedBindings[i].binding, sizeof(path), &size, path)))
|
||||
LOG("input_diag: %s", path);
|
||||
}
|
||||
}
|
||||
|
||||
// Called by xrGetCurrentInteractionProfile with the runtime's answer.
|
||||
static void input_diag_current_profile(XrPath user, XrPath profile) {
|
||||
PFN_xrPathToString to_string =
|
||||
active_instance ? (PFN_xrPathToString)lookup(active_instance, "xrPathToString") : NULL;
|
||||
if (!input_diag || !to_string) return;
|
||||
char u[XR_MAX_PATH_LENGTH] = "?", p[XR_MAX_PATH_LENGTH] = "none", key[DIAG_KEY];
|
||||
uint32_t size = 0;
|
||||
to_string(active_instance, user, sizeof(u), &size, u);
|
||||
if (profile) to_string(active_instance, profile, sizeof(p), &size, p);
|
||||
snprintf(key, sizeof(key), "current:%s:%s", u, p);
|
||||
if (diag_first(key)) LOG("input_diag: bindings: %s uses %s", u, p);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- failing calls
|
||||
// xrSyncActions and xrSuggestInteractionProfileBindings are reported from session_fixes.c's hooks,
|
||||
// xrApplyHapticFeedback from frame_adapter.c's (always hooked for haptic_scale).
|
||||
#define DIAG_CHECKED(name, params, args, detail) \
|
||||
static XRAPI_ATTR XrResult XRAPI_CALL diag_##name params { \
|
||||
PFN_##name fn = (PFN_##name)lookup(active_instance, #name); \
|
||||
if (!fn) return XR_ERROR_FUNCTION_UNSUPPORTED; \
|
||||
XrResult result = fn args; \
|
||||
if (XR_FAILED(result)) diag_call_failed(#name, result, detail); \
|
||||
return result; \
|
||||
}
|
||||
static const char *diag_name_detail(const char *name) {
|
||||
static __thread char buf[XR_MAX_PATH_LENGTH + 8];
|
||||
snprintf(buf, sizeof(buf), "(%s)", name ? name : "null");
|
||||
return buf;
|
||||
}
|
||||
static const char *diag_perf_detail(XrPerfSettingsDomainEXT domain, XrPerfSettingsLevelEXT level) {
|
||||
static __thread char buf[64];
|
||||
snprintf(buf, sizeof(buf), "(domain %d level %d)", (int)domain, (int)level);
|
||||
return buf;
|
||||
}
|
||||
DIAG_CHECKED(xrStringToPath, (XrInstance instance, const char *path, XrPath *out), (instance, path, out),
|
||||
diag_name_detail(path))
|
||||
DIAG_CHECKED(xrCreateAction, (XrActionSet set, const XrActionCreateInfo *info, XrAction *action), (set, info, action),
|
||||
diag_name_detail(info ? info->actionName : NULL))
|
||||
DIAG_CHECKED(xrAttachSessionActionSets, (XrSession session, const XrSessionActionSetsAttachInfo *info),
|
||||
(session, info), NULL)
|
||||
DIAG_CHECKED(xrPerfSettingsSetPerformanceLevelEXT,
|
||||
(XrSession session, XrPerfSettingsDomainEXT domain, XrPerfSettingsLevelEXT level),
|
||||
(session, domain, level), diag_perf_detail(domain, level))
|
||||
#undef DIAG_CHECKED
|
||||
|
||||
// xrGetInstanceProcAddr: our wrapper for `name`, NULL if it isn't one of ours.
|
||||
static PFN_xrVoidFunction input_diag_hook(const char *name) {
|
||||
#define DIAG(fn) if (!strcmp(name, #fn)) return (PFN_xrVoidFunction)diag_##fn;
|
||||
DIAG(xrStringToPath)
|
||||
DIAG(xrCreateAction)
|
||||
DIAG(xrAttachSessionActionSets)
|
||||
DIAG(xrPerfSettingsSetPerformanceLevelEXT)
|
||||
#undef DIAG
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// After the runtime's own lookup: a function the game asked for that the runtime doesn't provide.
|
||||
static void input_diag_lookup(XrInstance instance, const char *name, XrResult result, PFN_xrVoidFunction fn) {
|
||||
if (!input_diag || instance == XR_NULL_HANDLE || (XR_SUCCEEDED(result) && fn)) return;
|
||||
char key[DIAG_KEY], rname[XR_MAX_RESULT_STRING_SIZE];
|
||||
snprintf(key, sizeof(key), "fn:%s", name);
|
||||
if (diag_first(key))
|
||||
LOG("input_diag: unsupported: function %s not provided by the runtime (%s)", name,
|
||||
diag_result_name(result, rname, sizeof(rname)));
|
||||
}
|
||||
@@ -110,11 +110,12 @@ static int input_syncs, input_sync_ok, input_bool_reads, input_bool_true, input_
|
||||
static XRAPI_ATTR XrResult XRAPI_CALL hook_xrSyncActions(XrSession session, const XrActionsSyncInfo *info) {
|
||||
PFN_xrSyncActions fn = (PFN_xrSyncActions)lookup(active_instance, "xrSyncActions");
|
||||
if (!fn) return XR_ERROR_FUNCTION_UNSUPPORTED;
|
||||
if (!sync_guard) { // installed for layer_debug only: count
|
||||
if (!sync_guard) { // installed for layer_debug / input_diag only: count, report failures
|
||||
XrResult r = fn(session, info);
|
||||
__atomic_add_fetch(&input_syncs, 1, __ATOMIC_RELAXED);
|
||||
if (r == XR_SUCCESS) __atomic_add_fetch(&input_sync_ok, 1, __ATOMIC_RELAXED);
|
||||
input_last_sync_result = r;
|
||||
if (input_diag && XR_FAILED(r)) diag_call_failed("xrSyncActions", r, NULL);
|
||||
return r;
|
||||
}
|
||||
pthread_mutex_lock(&sync_lock);
|
||||
@@ -123,6 +124,7 @@ static XRAPI_ATTR XrResult XRAPI_CALL hook_xrSyncActions(XrSession session, cons
|
||||
pthread_mutex_unlock(&sync_lock);
|
||||
static int logged;
|
||||
if (wait > 0 && logged++ < 5) LOG("sync_guard: input paused for %.0f ms after focus returned", wait / 1e6);
|
||||
if (input_diag && XR_FAILED(r)) diag_call_failed("xrSyncActions", r, NULL);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -324,6 +326,7 @@ static XRAPI_ATTR XrResult XRAPI_CALL hook_xrSuggestInteractionProfileBindings(X
|
||||
note_pose_binding(suggested->suggestedBindings[i].action, path);
|
||||
}
|
||||
XrResult r = fn(instance, suggested);
|
||||
input_diag_suggested(instance, suggested, r, to_string); // the runtime's answer to the game's own suggestion
|
||||
if (!profile_remap || !suggested || !to_string) return r;
|
||||
char profile[XR_MAX_PATH_LENGTH] = {0};
|
||||
uint32_t size = 0;
|
||||
|
||||
@@ -7,10 +7,10 @@ Everything is fetched on demand into native/.cache (git-ignored):
|
||||
- Temurin JDK 21 (javac) and Android build-tools (d8) for the Java stub classes
|
||||
Then builds: FrameBridge adapter (arm64 + arm32), VrApi bridge, platform compat, language packs, GL shim, oculusos stub dex, the
|
||||
timefix OpenXR layer for Proton games (linux-arm64, glibc; the NDK's clang builds it freestanding), the
|
||||
OculusHMDConnected helper for Rift games under Proton (win-x64 PE; the NDK's clang + lld-link, no Windows SDK), and
|
||||
rewrites artifacts/SHA256SUMS. Run `frameport parity` afterwards to see which games change.
|
||||
OculusHMDConnected helper for Rift games under Proton (win-x64 PE; the NDK's clang + lld-link, no Windows SDK), the
|
||||
live view's hardware H.264 encoder fp_venc (linux-arm64-bin, static freestanding executable), and rewrites artifacts/SHA256SUMS. Run `frameport parity` afterwards to see which games change.
|
||||
|
||||
python native/build.py [--only adapter,bridge,compat,langpack,glshim,eglfmt,ovrtrace,dex,xrlayer,oculushmd,xrshim,vkshim,ovrpshim,vrsettings] [--ndk PATH]
|
||||
python native/build.py [--only adapter,bridge,compat,langpack,glshim,eglfmt,ovrtrace,dex,xrlayer,oculushmd,xrshim,vkshim,ovrpshim,vrsettings,venc] [--ndk PATH]
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -158,6 +158,32 @@ def build_xrlayer(tc: Path):
|
||||
shutil.copy(src / "XR_APILAYER_FRAMEPORT_timefix.json", out / "XR_APILAYER_FRAMEPORT_timefix.json")
|
||||
|
||||
|
||||
def uapi_arm64(tc: Path) -> Path:
|
||||
"""Only the kernel UAPI headers of the NDK sysroot (linux/, asm-generic/, drm/, aarch64 asm/), rebuilt every time,
|
||||
so no bionic libc header can end up on a freestanding build's include path."""
|
||||
inc = tc / "sysroot/usr/include"
|
||||
dest = CACHE / "uapi-arm64"
|
||||
shutil.rmtree(dest, ignore_errors=True)
|
||||
for d in ("linux", "asm-generic", "drm"):
|
||||
shutil.copytree(inc / d, dest / d)
|
||||
shutil.copytree(inc / "aarch64-linux-android/asm", dest / "asm")
|
||||
return dest
|
||||
|
||||
|
||||
def build_venc(tc: Path):
|
||||
"""fp_venc (Linux aarch64, runs on the Frame): SteamVR headset view -> V4L2 hardware H.264 encoder -> stdout, for the
|
||||
live view. Fully static and freestanding (raw syscalls, own _start), so it needs no libc at build or run time.
|
||||
Goes to linux-arm64-bin/, not linux-arm64/ (that folder is uploaded whole as the OpenXR layer)."""
|
||||
src = HERE / "venc"
|
||||
uapi = uapi_arm64(tc)
|
||||
out = ART / "linux-arm64-bin"
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
run([tc / "bin/clang", "--target=aarch64-linux-gnu", "-ffreestanding", "-nostdlib", "-nostdlibinc", "-static",
|
||||
"-fno-stack-protector", "-fno-builtin", "-O2", "-Wall", "-Wextra", "-Werror", "-fuse-ld=lld",
|
||||
"-Wl,--build-id=none", "-Wl,-z,max-page-size=65536", "-e", "_start", "-I", src / "include", "-I", uapi,
|
||||
f"-ffile-prefix-map={HERE}=native", "fp_venc.c", "convert.c", "sys.c", "-o", out / "fp_venc"], cwd=src)
|
||||
|
||||
|
||||
OCULUSHMD_IMPORTS = ("CreateEventW", "CreateJobObjectW", "AssignProcessToJobObject", "QueryInformationJobObject",
|
||||
"CreateProcessW", "ResumeThread", "WaitForSingleObject", "GetExitCodeProcess", "CloseHandle",
|
||||
"Sleep", "GetCommandLineW", "GetLastError", "GetStdHandle", "WriteFile", "ExitProcess")
|
||||
@@ -326,7 +352,7 @@ def write_sums():
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--only", default="adapter,bridge,compat,langpack,glshim,eglfmt,ovrtrace,dex,xrlayer,oculushmd,xrshim,vkshim,ovrpshim,vrsettings")
|
||||
ap.add_argument("--only", default="adapter,bridge,compat,langpack,glshim,eglfmt,ovrtrace,dex,xrlayer,oculushmd,xrshim,vkshim,ovrpshim,vrsettings,venc")
|
||||
ap.add_argument("--ndk")
|
||||
args = ap.parse_args()
|
||||
parts = set(args.only.split(","))
|
||||
@@ -338,8 +364,8 @@ def main():
|
||||
"glshim": lambda: build_glshim(tc), "eglfmt": lambda: build_eglfmt(tc), "ovrtrace": lambda: build_ovrtrace(tc), "xrshim": lambda: build_xrshim(tc), "dex": build_dex, "xrlayer": lambda: build_xrlayer(tc),
|
||||
"oculushmd": lambda: build_oculushmd(tc), "vkshim": lambda: build_vkshim(tc),
|
||||
"ovrpshim": lambda: build_ovrpshim(tc),
|
||||
"vrsettings": lambda: build_vrsettings(tc)}
|
||||
for name in ("adapter", "bridge", "compat", "langpack", "glshim", "eglfmt", "ovrtrace", "xrshim", "vkshim", "ovrpshim", "dex", "xrlayer", "oculushmd", "vrsettings"):
|
||||
"vrsettings": lambda: build_vrsettings(tc), "venc": lambda: build_venc(tc)}
|
||||
for name in ("adapter", "bridge", "compat", "langpack", "glshim", "eglfmt", "ovrtrace", "xrshim", "vkshim", "ovrpshim", "dex", "xrlayer", "oculushmd", "vrsettings", "venc"):
|
||||
if name in parts:
|
||||
log(f"build {name}")
|
||||
steps[name]()
|
||||
|
||||
@@ -30,8 +30,13 @@ static void (*real_glGetIntegerv)(GLenum, GLint *);
|
||||
static __eglMustCastToProperFunctionPointerType (*real_eglGetProcAddress)(const char *);
|
||||
static pthread_once_t once = PTHREAD_ONCE_INIT;
|
||||
|
||||
static int hide_multiview = -1; // -1: not set (Unity keeps multiview, everything else hides it)
|
||||
static int hide_multiview = -1; // -1: not set (Unity and Unreal keep multiview, everything else hides it)
|
||||
static int hide_msrtt = 1;
|
||||
// Unreal (4.25) only turns on its mobile multiview when GL_OVR_multiview, GL_OVR_multiview2 AND
|
||||
// GL_OVR_multiview_multisampled_render_to_texture are all there (FOpenGLES::ProcessExtensions). Hiding the last one
|
||||
// with the MSRTT extensions switched Unreal's multiview off, so for Unreal it stays visible and its function draws
|
||||
// single-sampled (glFramebufferTextureMultiviewOVR), like the EXT stand-ins below.
|
||||
static int unreal;
|
||||
|
||||
static void read_conf_file(const char *path) {
|
||||
FILE *f = fopen(path, "r");
|
||||
@@ -335,12 +340,21 @@ static void init(void) {
|
||||
real_glGetStringi = gles ? dlsym(gles, "glGetStringi") : NULL;
|
||||
real_glGetIntegerv = gles ? dlsym(gles, "glGetIntegerv") : NULL;
|
||||
real_eglGetProcAddress = egl ? dlsym(egl, "eglGetProcAddress") : NULL;
|
||||
if (hide_multiview < 0) { // Unity renders multiview itself and only needs MSRTT hidden
|
||||
void *unity = dlopen("libunity.so", RTLD_NOW | RTLD_NOLOAD);
|
||||
hide_multiview = unity ? 0 : 1;
|
||||
if (unity) dlclose(unity);
|
||||
static const char *const engines[] = {"libunity.so", "libUE4.so", "libUnreal.so"};
|
||||
int engine_found = 0;
|
||||
for (unsigned i = 0; i < sizeof engines / sizeof *engines && !engine_found; i++) {
|
||||
void *engine = dlopen(engines[i], RTLD_NOW | RTLD_NOLOAD);
|
||||
if (engine) {
|
||||
engine_found = 1;
|
||||
unreal = i > 0;
|
||||
dlclose(engine);
|
||||
}
|
||||
}
|
||||
LOG("GL shim active: hide_multiview=%d hide_msrtt=%d", hide_multiview, hide_msrtt);
|
||||
// Unity and Unreal render multiview themselves and only need MSRTT hidden
|
||||
if (hide_multiview < 0) hide_multiview = !engine_found;
|
||||
unreal = unreal && hide_msrtt && !hide_multiview; // only matters while MSRTT is hidden and multiview kept
|
||||
LOG("GL shim active: hide_multiview=%d hide_msrtt=%d%s", hide_multiview, hide_msrtt,
|
||||
unreal ? " (Unreal: multiview MSRTT kept, drawn single-sampled)" : "");
|
||||
}
|
||||
|
||||
static int is_hidden(const char *name) {
|
||||
@@ -349,7 +363,8 @@ static int is_hidden(const char *name) {
|
||||
if (!strcmp(name, hidden_multiview[i])) return 1;
|
||||
if (hide_msrtt)
|
||||
for (size_t i = 0; i < sizeof(hidden_msrtt) / sizeof(hidden_msrtt[0]); ++i)
|
||||
if (!strcmp(name, hidden_msrtt[i])) return 1;
|
||||
if (!strcmp(name, hidden_msrtt[i]))
|
||||
return !(unreal && !strcmp(name, "GL_OVR_multiview_multisampled_render_to_texture"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -416,6 +431,14 @@ static void plain_rbsms(GLenum target, GLsizei samples, GLenum format, GLsizei w
|
||||
(void)samples;
|
||||
if (r_plain_rbs) r_plain_rbs(target, format, width, height);
|
||||
}
|
||||
static PFN_FTMV r_plain_ftmv;
|
||||
static int mv_msrtt_logged;
|
||||
static void plain_ftmsmv(GLenum target, GLenum attachment, GLuint texture, GLint level, GLsizei samples,
|
||||
GLint base, GLsizei views) {
|
||||
if (!mv_msrtt_logged++)
|
||||
LOG("GL shim: multiview multisampled render-to-texture (%d samples) drawn single-sampled", (int)samples);
|
||||
if (r_plain_ftmv) r_plain_ftmv(target, attachment, texture, level, base, views);
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *name) {
|
||||
pthread_once(&once, init);
|
||||
@@ -432,6 +455,10 @@ __attribute__((visibility("default"))) __eglMustCastToProperFunctionPointerType
|
||||
return name[2] == 'F' ? (__eglMustCastToProperFunctionPointerType)plain_ft2dms
|
||||
: (__eglMustCastToProperFunctionPointerType)plain_rbsms;
|
||||
}
|
||||
if (unreal && !strcmp(name, "glFramebufferTextureMultisampleMultiviewOVR")) {
|
||||
if (!r_plain_ftmv) r_plain_ftmv = (PFN_FTMV)real_eglGetProcAddress("glFramebufferTextureMultiviewOVR");
|
||||
return (__eglMustCastToProperFunctionPointerType)plain_ftmsmv;
|
||||
}
|
||||
#ifdef GLSHIM_TRACE // build with -DGLSHIM_TRACE for eye-buffer / draw / error tracing
|
||||
WRAP("glFramebufferTextureMultiviewOVR", real_ftmv, w_ftmv)
|
||||
WRAP("glFramebufferTextureMultisampleMultiviewOVR", real_ftmsmv, w_ftmsmv)
|
||||
|
||||
@@ -9,10 +9,14 @@
|
||||
//
|
||||
// FramePort renames the "ovrp_Update2" lookup in libunity.so to "fpov_Update2" (same length) and adds this library to
|
||||
// libOVRPlugin.so's DT_NEEDED, so Unity's dlsym on the plugin finds this function: it waits for the frame first (once
|
||||
// per frame index, render step only), then calls the real ovrp_Update2.
|
||||
// per frame index, render step only), then calls the real ovrp_Update2 (render step; the physics step: see below).
|
||||
#include <android/log.h>
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#define TAG "FrameBridge"
|
||||
#define EXPORT __attribute__((visibility("default")))
|
||||
@@ -25,31 +29,168 @@ static PFN_Update2 real_update2;
|
||||
static PFN_WaitToBeginFrame real_wait;
|
||||
static pthread_once_t once = PTHREAD_ONCE_INIT;
|
||||
|
||||
// Per-game settings (the same sources as FrameBridge and the GL shim, later ones winning): the frame-begin gate and
|
||||
// the held-back physics update below were needed by Sniper Elite VR; in Unity 2019 games (BattleSisters) holding the
|
||||
// physics update back made the hands lag and the gate made loading screens stutter, so both are off unless the recipe
|
||||
// turns them on (ovrp_begin_gate=1, ovrp_hold_physics=1).
|
||||
static int begin_gate, hold_physics;
|
||||
|
||||
static void read_conf_file(const char *path) {
|
||||
FILE *f = fopen(path, "r");
|
||||
if (!f) return;
|
||||
char line[256];
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
if (!strncmp(line, "ovrp_begin_gate=", 16)) begin_gate = atoi(line + 16);
|
||||
if (!strncmp(line, "ovrp_hold_physics=", 18)) hold_physics = atoi(line + 18);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
static void read_conf(void) {
|
||||
Dl_info info;
|
||||
char path[600];
|
||||
if (dladdr((void *)read_conf, &info) && info.dli_fname) {
|
||||
const char *slash = strrchr(info.dli_fname, '/');
|
||||
if (slash && slash - info.dli_fname < 500) {
|
||||
snprintf(path, sizeof(path), "%.*s/libframe_settings.so", (int)(slash - info.dli_fname), info.dli_fname);
|
||||
read_conf_file(path);
|
||||
}
|
||||
}
|
||||
char pkg[256] = {0};
|
||||
FILE *f = fopen("/proc/self/cmdline", "r");
|
||||
if (f) {
|
||||
size_t n = fread(pkg, 1, sizeof(pkg) - 1, f);
|
||||
fclose(f);
|
||||
pkg[n] = 0;
|
||||
}
|
||||
char *colon = strchr(pkg, ':');
|
||||
if (colon) *colon = 0;
|
||||
if (*pkg && !strchr(pkg, '/')) {
|
||||
snprintf(path, sizeof(path), "/sdcard/Android/data/%s/files/framebridge.conf", pkg);
|
||||
read_conf_file(path);
|
||||
}
|
||||
const char *env = getenv("FRAMEBRIDGE_CONFIG");
|
||||
if (env && *env) read_conf_file(env);
|
||||
}
|
||||
|
||||
static void init(void) {
|
||||
read_conf();
|
||||
void *ovrp = dlopen("libOVRPlugin.so", RTLD_NOW | RTLD_NOLOAD);
|
||||
if (!ovrp) ovrp = dlopen("libOVRPlugin.so", RTLD_NOW);
|
||||
if (ovrp) {
|
||||
real_update2 = (PFN_Update2)dlsym(ovrp, "ovrp_Update2");
|
||||
real_wait = (PFN_WaitToBeginFrame)dlsym(ovrp, "ovrp_WaitToBeginFrame");
|
||||
}
|
||||
LOG("ovrp frame loop shim: ovrp_Update2 %s, ovrp_WaitToBeginFrame %s", real_update2 ? "OK" : "MISSING",
|
||||
real_wait ? "OK" : "MISSING");
|
||||
LOG("ovrp frame loop shim: ovrp_Update2 %s, ovrp_WaitToBeginFrame %s, begin gate %d, hold physics %d",
|
||||
real_update2 ? "OK" : "MISSING", real_wait ? "OK" : "MISSING", begin_gate, hold_physics);
|
||||
}
|
||||
|
||||
#define STEP_RENDER (-1) // ovrpStep_Render
|
||||
|
||||
static void mouse_click_frame(void); // below: controller presses as Unity mouse clicks
|
||||
|
||||
// xrWaitFrame blocks until the frame waited for before it has begun (xrBeginFrame). Unity begins frames on its render
|
||||
// thread, which sometimes skips one (scene activation) and then waits for the main thread: our next wait never
|
||||
// returned (Sniper Elite VR hung at its Init scene, main thread in SteamVR's CSxrSession::StartNextFrame, render
|
||||
// thread idle). FramePort also renames libunity.so's "ovrp_BeginFrame"/"ovrp_EndFrame" lookups to the functions below.
|
||||
// Once a begin has come through, the main thread first waits (≤ BEGIN_TIMEOUT_MS) for the last waited frame to begin
|
||||
// and skips this frame's wait if it doesn't (normally the render thread begins it within a frame: pacing unchanged).
|
||||
// OVRPlugin only begins the frame index it waited for (else "outside of frame bounds" and no xrBeginFrame, after which
|
||||
// the next wait blocked for good), so a begin of another index while a wait is outstanding becomes a begin of the
|
||||
// waited index, and the matching end follows it.
|
||||
#define BEGIN_TIMEOUT_MS 50
|
||||
static pthread_mutex_t begin_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_cond_t begin_cond = PTHREAD_COND_INITIALIZER;
|
||||
static int begin_hooked; // fpov_BeginFrame has been called: the gate is armed
|
||||
static int outstanding = -1; // frame index waited for and not begun yet, else -1 (under begin_lock)
|
||||
static int remap_from = -1, remap_to = -1; // the last begin that was given the waited index (for its end)
|
||||
|
||||
static int last_wait_begun(int frame_index) {
|
||||
if (!begin_gate) return 1;
|
||||
pthread_mutex_lock(&begin_lock);
|
||||
struct timespec until;
|
||||
clock_gettime(CLOCK_REALTIME, &until);
|
||||
until.tv_nsec += BEGIN_TIMEOUT_MS * 1000000L;
|
||||
if (until.tv_nsec >= 1000000000L) until.tv_sec++, until.tv_nsec -= 1000000000L;
|
||||
while (begin_hooked && outstanding >= 0)
|
||||
if (pthread_cond_timedwait(&begin_cond, &begin_lock, &until)) break;
|
||||
int ok = !begin_hooked || outstanding < 0;
|
||||
if (ok) outstanding = frame_index;
|
||||
pthread_mutex_unlock(&begin_lock);
|
||||
return ok;
|
||||
}
|
||||
|
||||
// Unity's physics step updates OVRPlugin's poses with prediction 0 ("now"). OVRPlugin takes "now" from the monotonic
|
||||
// clock, which is the XrTime base on a Quest but not on the Frame (its XrTime ran 0.05-0.9 s ahead), so it located
|
||||
// every node that much in the past (the runtime extrapolates backwards), and the render-step reads after it got those
|
||||
// poses too: the game's hands trailed the controllers by several centimetres whenever they moved (Sniper Elite VR). A
|
||||
// larger prediction doesn't reach (OVRPlugin caps it at ~0.07 s), so the physics update isn't passed on: OVRPlugin
|
||||
// keeps the render update's display-time poses for the whole frame (physics and render reads agree).
|
||||
#define STEP_PHYSICS 0
|
||||
|
||||
EXPORT int fpov_Update2(int step, int frame_index, double prediction_seconds) {
|
||||
pthread_once(&once, init);
|
||||
static int last_waited = -1, logged;
|
||||
static int last_waited = -1, rendered, logged, skipped, last_result;
|
||||
if (step == STEP_RENDER && real_wait && frame_index != last_waited) {
|
||||
last_waited = frame_index;
|
||||
int r = real_wait(frame_index);
|
||||
if (logged++ < 3) LOG("ovrp frame loop shim: waited for frame %d: %d", frame_index, r);
|
||||
if (last_wait_begun(frame_index)) {
|
||||
int r = real_wait(frame_index);
|
||||
if (logged++ < 3) LOG("ovrp frame loop shim: waited for frame %d: %d", frame_index, r);
|
||||
} else if (skipped++ < 20 || skipped % 1000 == 0) {
|
||||
LOG("ovrp frame loop shim: frame %d: the last waited frame wasn't begun within %d ms, not waiting "
|
||||
"(%d times)", frame_index, BEGIN_TIMEOUT_MS, skipped);
|
||||
}
|
||||
mouse_click_frame();
|
||||
}
|
||||
return real_update2 ? real_update2(step, frame_index, prediction_seconds) : -1000; // ovrpFailure
|
||||
if (hold_physics && step == STEP_PHYSICS && rendered) return last_result; // see above: keeps the display-time poses
|
||||
int r = real_update2 ? real_update2(step, frame_index, prediction_seconds) : -1000; // ovrpFailure
|
||||
if (step == STEP_RENDER) rendered = 1, last_result = r;
|
||||
return r;
|
||||
}
|
||||
|
||||
// Unity's legacy ovrp_BeginFrame(frameIndex) / ovrp_EndFrame(frameIndex) on the render thread; further arguments
|
||||
// (older plugins) are passed on as they are
|
||||
typedef int (*PFN_FrameCall)(long, long, long, long);
|
||||
|
||||
static PFN_FrameCall ovrp_fn(const char *name) {
|
||||
void *ovrp = dlopen("libOVRPlugin.so", RTLD_NOW | RTLD_NOLOAD);
|
||||
PFN_FrameCall fn = ovrp ? (PFN_FrameCall)dlsym(ovrp, name) : 0;
|
||||
LOG("ovrp frame loop shim: %s %s", name, fn ? "OK" : "MISSING");
|
||||
return fn;
|
||||
}
|
||||
|
||||
EXPORT int fpov_BeginFrame(long frame, long b, long c, long d) {
|
||||
static PFN_FrameCall real;
|
||||
static int logged;
|
||||
pthread_once(&once, init); // the settings (begin_gate) before the first begin
|
||||
if (!real) real = ovrp_fn("ovrp_BeginFrame");
|
||||
pthread_mutex_lock(&begin_lock);
|
||||
long index = frame;
|
||||
if (begin_gate && outstanding >= 0 && outstanding != (int)frame) {
|
||||
index = outstanding;
|
||||
remap_from = (int)frame, remap_to = outstanding;
|
||||
} else {
|
||||
remap_from = remap_to = -1;
|
||||
}
|
||||
pthread_mutex_unlock(&begin_lock);
|
||||
int r = real ? real(index, b, c, d) : -1000;
|
||||
if (index != frame && logged++ < 20)
|
||||
LOG("ovrp frame loop shim: begin frame %ld as waited frame %ld: %d", frame, index, r);
|
||||
pthread_mutex_lock(&begin_lock);
|
||||
begin_hooked = 1;
|
||||
outstanding = -1; // the waited frame (if any) is begun now
|
||||
pthread_cond_broadcast(&begin_cond);
|
||||
pthread_mutex_unlock(&begin_lock);
|
||||
return r;
|
||||
}
|
||||
|
||||
EXPORT int fpov_EndFrame(long frame, long b, long c, long d) {
|
||||
static PFN_FrameCall real;
|
||||
if (!real) real = ovrp_fn("ovrp_EndFrame");
|
||||
pthread_mutex_lock(&begin_lock);
|
||||
if ((int)frame == remap_from) frame = remap_to;
|
||||
pthread_mutex_unlock(&begin_lock);
|
||||
return real ? real(frame, b, c, d) : -1000;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- input diagnostics (pass-through)
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
# fp_venc — specification
|
||||
|
||||
A small program that runs **on the Steam Frame** (SteamOS, aarch64 Linux with glibc) and hardware-encodes the
|
||||
SteamVR "headset view" webcam to an H.264 elementary stream on stdout. FramePort's live view (PC side) pipes that
|
||||
stream into ffmpeg on the Frame, which adds sound and packs fragmented MP4. The program is used for **live viewing
|
||||
only**: low latency, constant bitrate, evenly spaced frames, a keyframe whenever the viewer side asks for one.
|
||||
|
||||
Sources: the Linux kernel's V4L2 documentation (`Documentation/userspace-api/media/v4l/dev-encoder.rst` = the
|
||||
memory-to-memory stateful encoder interface, `ext-ctrls-codec.rst`, `buffer.rst`, `vidioc-*.rst`), the DRM KMS UAPI
|
||||
(`drm_mode.h`), and the facts measured on the Frame listed in "Measured facts". Nothing else.
|
||||
|
||||
## Files
|
||||
- `native/venc/convert.h`, `convert.c` — the picture converter (pure computation, no syscalls). Must compile for
|
||||
**aarch64** (NEON path + scalar path) **and x86_64** (scalar path only; used by the host unit test).
|
||||
- `native/venc/sys.h` (+ `.c` if wanted) — raw Linux aarch64 syscalls (`svc #0`), `_start`, `memcpy`/`memset`/`memmove`
|
||||
(the compiler may emit calls to them), small string/number helpers (parse decimal, print decimal, write a whole buffer).
|
||||
- `native/venc/fp_venc.c` — command line, source, encoder, DRM refresh query, main loop.
|
||||
- `native/venc/include/sys/time.h` — minimal stub so the kernel UAPI `linux/videodev2.h` compiles without a libc
|
||||
(`struct timeval { long tv_sec; long tv_usec; };` and whatever else that header needs).
|
||||
- `native/build.py` — a `build_venc(tc)` step (see "Build").
|
||||
|
||||
Keep it small and readable: plain C11, no clever macros, comments that explain *why*. Target ≤ ~900 lines total.
|
||||
|
||||
## Build
|
||||
No libc exists at build time (the toolchain is the Android NDK's clang; its sysroot is bionic). The program is a fully
|
||||
static, freestanding executable:
|
||||
|
||||
```
|
||||
clang --target=aarch64-linux-gnu -ffreestanding -nostdlib -nostdlibinc -static -fno-stack-protector
|
||||
-fno-builtin -O2 -Wall -Wextra -Werror -fuse-ld=lld -Wl,--build-id=none -Wl,-z,max-page-size=65536
|
||||
-e _start -I native/venc/include -I <uapi> -ffile-prefix-map=<native dir>=native
|
||||
fp_venc.c convert.c [sys.c] -o artifacts/linux-arm64-bin/fp_venc
|
||||
```
|
||||
- `<uapi>`: a staging directory made by build.py under `native/.cache/uapi-arm64/` containing **only** copies of the
|
||||
NDK sysroot's kernel UAPI folders `usr/include/linux`, `usr/include/asm-generic`, `usr/include/drm` and
|
||||
`usr/include/aarch64-linux-android/asm` (as `asm/`). Never put the bionic libc headers on the include path.
|
||||
- `stdint.h`, `stddef.h`, `stdbool.h` and `arm_neon.h` come from clang's own resource directory (allowed).
|
||||
- Floating point is allowed but not needed; prefer integer math.
|
||||
- Add `venc` to build.py's `--only` default list, the docstring, the `steps` dict and the ordered build tuple (last).
|
||||
The step creates `artifacts/linux-arm64-bin/` itself (not `linux-arm64/`: that folder is uploaded whole as the OpenXR layer). `write_sums()` then lists the new file.
|
||||
- The binary must be reproducible (same source → same bytes) and contain no local paths.
|
||||
|
||||
## Command line
|
||||
```
|
||||
fp_venc [--height N] [--bitrate BPS] [--peak BPS] [--fps N] [--max-fps N] [--gop-seconds N]
|
||||
[--source PATH] [--encoder PATH] [--probe | --selftest]
|
||||
```
|
||||
- `--height N`: output height, scaled **down** only. Default: the source height. See "Output size".
|
||||
- `--bitrate BPS`: target bitrate in bit/s. Default 3000000.
|
||||
- `--peak BPS`: above the bitrate = VBR capped at this peak (the live view uses 1.5×), else CBR.
|
||||
- `--fps N`: output frame rate; overrides the automatic choice.
|
||||
- `--max-fps N`: cap for the automatic choice. Default 45.
|
||||
- `--gop-seconds N`: keyframe interval in seconds. Default 4.
|
||||
- `--source PATH`: V4L2 capture device. Default: the `/dev/videoN` whose `/sys/class/video4linux/videoN/name` is
|
||||
exactly `SteamVR` (strip the trailing newline).
|
||||
- `--encoder PATH`: the encoder node. Default: `/dev/video-enc0` if it exists, else the first
|
||||
`/sys/class/video4linux/videoN` whose `name` contains `encoder` and that passes the capability check below.
|
||||
- `--probe`: do every setup step up to and including buffer allocation (no STREAMON, no frames), print the info JSON
|
||||
(below) on **stdout**, exit.
|
||||
- `--selftest`: run the converter self-test (below) and exit. Needs no devices.
|
||||
|
||||
Exit codes: 0 ok · 1 self-test failed / runtime error after streaming started · 2 bad arguments · 3 no source
|
||||
device · 4 hardware encoder not usable (missing, wrong caps, a required format refused, any setup ioctl failed).
|
||||
When the environment variable `FP_VENC_DISABLE=1` is set, setup fails with exit 4 (used to test the fallback).
|
||||
The environment is on the stack after argv (`_start`: `argc` at `[sp]`, `argv` at `sp+8`, `envp` after argv's NULL).
|
||||
|
||||
### Info JSON
|
||||
One line, keys in this order, no spaces:
|
||||
`{"encoder":"/dev/video23","source":"/dev/video99","src":[1920,1080],"out":[1280,720],"refresh":96,"fps":32,"bitrate":3000000}`
|
||||
`refresh` is the panel rate in whole Hz (0 when unknown). In normal (streaming) mode the same line is written to
|
||||
**stderr** right after setup, prefixed `fp_venc: info ` — the PC side reads it for its status line.
|
||||
|
||||
## Frame rate
|
||||
1. Read the panel's current refresh rate through DRM (read-only, no master needed; `/dev/dri/card0` is mode 0666 on
|
||||
the Frame): open `/dev/dri/card0` (`O_RDWR|O_CLOEXEC`), `DRM_IOCTL_MODE_GETRESOURCES` once for the counts and
|
||||
once more with an array for the CRTC ids, then `DRM_IOCTL_MODE_GETCRTC` for each. Among CRTCs with `mode_valid`,
|
||||
take the one with the largest `hdisplay × vdisplay`. Rate in milli-Hz = `clock(kHz) × 1 000 000 / (htotal × vtotal)`;
|
||||
round to whole Hz. Any failure → refresh unknown.
|
||||
2. `fps` = `--fps` if given; else if the refresh is known: `refresh / ceil(refresh / max_fps)` (integer division,
|
||||
rounded to nearest): 72→36, 80→40, 90→45, 96→32, 108→36, 120→40, 144→36; else 30.
|
||||
Rationale: frames on an even grid of the panel's refresh look smooth; 30 fps on a 72/96 Hz panel judders.
|
||||
|
||||
## Output size
|
||||
`out_h = min(--height or src_h, src_h)`, rounded **down** to even. `out_w = floor(src_w × out_h / src_h)` rounded down
|
||||
to even. Both ≥ 2. (1920×1080 → 360: 640×360; 480: 852×480; 720: 1280×720; 1080: 1920×1080.)
|
||||
|
||||
## Converter (`convert.h`)
|
||||
```c
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
void fp_out_size(int src_w, int src_h, int max_h, int *out_w, int *out_h); /* rule above; max_h <= 0 = src_h */
|
||||
size_t fp_scratch_size(int src_w, int src_h, int out_w, int out_h); /* bytes of scratch fp_convert needs */
|
||||
/* RGB24 (R,G,B bytes) → NV12 (BT.709, limited range). Writes out_w×out_h luma and out_w×out_h/2 interleaved CbCr. */
|
||||
void fp_convert_scalar(const uint8_t *src, int src_w, int src_h, int src_stride,
|
||||
uint8_t *y, int y_stride, uint8_t *uv, int uv_stride,
|
||||
int out_w, int out_h, void *scratch);
|
||||
void fp_convert(/* same parameters */); /* NEON on aarch64; identical to fp_convert_scalar elsewhere */
|
||||
```
|
||||
Both functions must produce **bit-identical** output; the exact definition is:
|
||||
|
||||
1. **Scaling (box average).** For output column `i` the source columns are `[x0, x1)` with
|
||||
`x0 = i·src_w / out_w`, `x1 = (i+1)·src_w / out_w` (integer division); rows likewise with `src_h/out_h`. Each
|
||||
channel of output pixel (i, j) is `(S + n/2) / n` (integer division), `S` = sum of that channel over the block,
|
||||
`n` = block width × block height. When the size is unchanged this is the identity.
|
||||
2. **Luma** from each scaled pixel (R, G, B):
|
||||
`Y = 16 + ((47·R + 157·G + 16·B + 128) >> 8)`.
|
||||
3. **Chroma** per 2×2 block of scaled pixels: first average each channel, `C = (c00 + c01 + c10 + c11 + 2) >> 2`,
|
||||
then `Cb = 128 + ((−26·R − 86·G + 112·B + 128) >> 8)`, `Cr = 128 + ((112·R − 102·G − 10·B + 128) >> 8)`
|
||||
(`>>` on a signed 32-bit value = floor division by 256). Write Cb then Cr.
|
||||
4. Clamp Y to [16, 235] and Cb/Cr to [16, 240] (the formulas already stay inside; clamp anyway).
|
||||
The input is sRGB-encoded full-range RGB; no linearisation (video expects gamma-encoded values).
|
||||
|
||||
**Performance:** at 1920×1080 → 1920×1080 the aarch64 `fp_convert` should take ≤ 4 ms per frame on one core; scaled
|
||||
outputs not more. Suggested shape (free to differ if output stays identical): NEON vertical accumulation of the rows of
|
||||
each output row into a uint16/uint32 row buffer, horizontal block sums + division (a per-block-size reciprocal table is
|
||||
fine only if it is exact for every possible sum; otherwise divide), NEON colour conversion with `vld3`/widening
|
||||
multiplies. The identity size gets a direct NEON path (no box step). Exact 3:2 and 3:1 ratios (720p and 360p from
|
||||
1080p) get their own NEON paths: the boxes repeat every 3 source pixels (widths 1,2 resp. 3), so the averages are
|
||||
rounding shifts / an exact multiply (×7282 >> 16 = ÷9 for every possible sum). The self-test covers them, including
|
||||
columns left over after the 48-pixel steps (1158×648 → 432/216).
|
||||
|
||||
### Self-test (`--selftest`)
|
||||
Deterministic synthetic images (a 32-bit LCG noise image, a horizontal gradient, solid black/white/red/green/blue,
|
||||
a 1-pixel checkerboard) at source sizes 1920×1080, 1922×1080, 333×201 and 64×64, each converted for max heights
|
||||
{source height, 720, 480, 360, 100} where ≤ source height. `fp_convert` must equal `fp_convert_scalar` byte for byte
|
||||
(Y and UV planes, using strides larger than the width to catch stride bugs). Print `fp_venc: selftest ok (N cases)` or
|
||||
the first mismatch (size, plane, x, y, both values) on stderr; exit 0/1. Also time 50 conversions 1920×1080→1080 and
|
||||
→720 and print the average ms each.
|
||||
|
||||
## Source (V4L2 capture, `/dev/video99`)
|
||||
v4l2loopback device written by SteamVR's `v4l2cam` (single-planar `V4L2_BUF_TYPE_VIDEO_CAPTURE`).
|
||||
- Open `O_RDWR|O_NONBLOCK|O_CLOEXEC`. `VIDIOC_QUERYCAP`: needs `V4L2_CAP_VIDEO_CAPTURE` + `V4L2_CAP_STREAMING`
|
||||
(check `device_caps` when `V4L2_CAP_DEVICE_CAPS` is set). `VIDIOC_G_FMT`: pixelformat must be `V4L2_PIX_FMT_RGB24`
|
||||
(else exit 4); use its width, height and `bytesperline` (0 → width×3).
|
||||
- `VIDIOC_REQBUFS` 3 × `V4L2_MEMORY_MMAP`, `VIDIOC_QUERYBUF` + `mmap(PROT_READ, MAP_SHARED)` each, `VIDIOC_QBUF` all,
|
||||
`VIDIOC_STREAMON`.
|
||||
- At most one dequeued buffer is held (the newest frame). When a newer one is dequeued, re-queue the held one first.
|
||||
Drain all ready buffers on each wake-up so the held one is always the newest.
|
||||
|
||||
## Encoder (V4L2 memory-to-memory, multi-planar)
|
||||
Follow the "Initialization" and "Encoding" sections of `dev-encoder.rst`:
|
||||
1. Open `O_RDWR|O_NONBLOCK|O_CLOEXEC`. `VIDIOC_QUERYCAP`: needs `V4L2_CAP_VIDEO_M2M_MPLANE` and
|
||||
`V4L2_CAP_STREAMING` (in `device_caps`).
|
||||
2. **Coded format first** — `VIDIOC_S_FMT` on `V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE`: `pixelformat = V4L2_PIX_FMT_H264`,
|
||||
width/height = out size, `num_planes = 1`. Must come back as H264 (else exit 4). Its `sizeimage` is the size of
|
||||
the encoded-frame buffers.
|
||||
3. **Raw format** — `VIDIOC_S_FMT` on `V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE`: `V4L2_PIX_FMT_NV12`, out size,
|
||||
`num_planes = 1`, `colorspace = V4L2_COLORSPACE_REC709`, `ycbcr_enc = V4L2_YCBCR_ENC_709`,
|
||||
`quantization = V4L2_QUANTIZATION_LIM_RANGE`, `xfer_func = V4L2_XFER_FUNC_709`. Use what comes back:
|
||||
`num_planes` must be 1 (else exit 4); `stride = plane_fmt[0].bytesperline`; the returned `height` is the padded
|
||||
height `H'`; the CbCr plane starts at `stride × H'` inside the same buffer; require
|
||||
`stride × H' × 3/2 ≤ plane_fmt[0].sizeimage` and `stride ≥ out_w` (else exit 4).
|
||||
4. **Visible rectangle** — `VIDIOC_S_SELECTION` (type `V4L2_BUF_TYPE_VIDEO_OUTPUT`, target `V4L2_SEL_TGT_CROP`,
|
||||
rect 0,0,out_w,out_h). If the driver rejects the single-planar type, retry with the `_MPLANE` type. Failure is only
|
||||
a warning when `G_SELECTION` already reports that rectangle.
|
||||
5. **Frame rate** — `VIDIOC_S_PARM` on the OUTPUT queue: `timeperframe = 1/fps` (warning on failure).
|
||||
6. **Controls** — `VIDIOC_S_EXT_CTRLS` (or `VIDIOC_S_CTRL` one by one), each best-effort: a refused control prints
|
||||
`fp_venc: warning: <name> refused (<errno>)` and continues:
|
||||
- `V4L2_CID_MPEG_VIDEO_H264_PROFILE` = HIGH; `V4L2_CID_MPEG_VIDEO_H264_LEVEL` = the lowest level whose limits
|
||||
(H.264 Table A-1: MaxFS macroblocks per frame, MaxMBPS macroblocks per second, MaxBR ×1.25 for High in kbit/s)
|
||||
fit out size × fps × bitrate, among 3.1, 3.2, 4, 4.1, 4.2, 5, 5.1, 5.2;
|
||||
- `V4L2_CID_MPEG_VIDEO_BITRATE_MODE` = CBR; `V4L2_CID_MPEG_VIDEO_BITRATE` = bitrate;
|
||||
`V4L2_CID_MPEG_VIDEO_BITRATE_PEAK` = bitrate; `V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE` = 1;
|
||||
- `V4L2_CID_MPEG_VIDEO_B_FRAMES` = 0; `V4L2_CID_MPEG_VIDEO_GOP_SIZE` = fps × gop_seconds;
|
||||
- `V4L2_CID_MPEG_VIDEO_HEADER_MODE` = JOINED_WITH_1ST_FRAME; `V4L2_CID_MPEG_VIDEO_PREPEND_SPSPPS_TO_IDR` = 1
|
||||
(every keyframe is decodable on its own — a viewer may join at any keyframe);
|
||||
- `V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE` = DISABLED (one output frame per input frame: the PC side derives
|
||||
timestamps from the frame count).
|
||||
7. **Buffers** — `VIDIOC_REQBUFS` OUTPUT_MPLANE 4 × MMAP and CAPTURE_MPLANE 4 × MMAP; `VIDIOC_QUERYBUF` + `mmap` every
|
||||
buffer (OUTPUT: read/write, fill with Y=16/CbCr=128 once so padding rows are defined; CAPTURE: read).
|
||||
(`--probe` stops here: print the JSON, exit 0.)
|
||||
8. Queue all CAPTURE buffers, `VIDIOC_STREAMON` both queues.
|
||||
9. Per frame: write NV12 into a free OUTPUT buffer (`bytesused` = sizeimage), `VIDIOC_QBUF`. Dequeue finished OUTPUT
|
||||
buffers (they become free). Dequeue CAPTURE buffers: write `bytesused − data_offset` bytes from
|
||||
`mem + data_offset` to stdout, re-queue. `V4L2_BUF_FLAG_ERROR` on a capture buffer: re-queue, count, don't write.
|
||||
`V4L2_BUF_FLAG_LAST`: the encoder is drained.
|
||||
10. **Keyframe on request** — set `V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME` (button) just before queuing the next frame.
|
||||
11. **Stop** — `VIDIOC_ENCODER_CMD` `V4L2_ENC_CMD_STOP`, keep dequeuing/writing CAPTURE buffers until one has
|
||||
`V4L2_BUF_FLAG_LAST` (or 1 s passes), `VIDIOC_STREAMOFF` both queues, close, exit 0.
|
||||
|
||||
## Main loop and timing
|
||||
- Ignore `SIGPIPE` (`rt_sigaction` with `SIG_IGN`; no restorer needed for SIG_IGN) so a closed stdout is an `EPIPE`
|
||||
error → stop quietly (exit 0).
|
||||
- **stdin protocol** (stdin is the SSH channel; non-blocking reads after `poll`): byte `k` = request a keyframe;
|
||||
byte `q` or end of file = stop (step 11); other bytes ignored.
|
||||
- **Fixed frame grid.** `t0` = `CLOCK_MONOTONIC` when streaming starts; slot `n` is due at `t0 + n·10⁹/fps` ns.
|
||||
Exactly **one** frame is queued per slot, always: at slot time, convert the held (newest) source frame — even if it
|
||||
was already used, e.g. while the headset is in standby the source delivers ~1 fps — so the stream's frame count
|
||||
always equals elapsed time × fps. The ffmpeg side relies on that (`-framerate fps`, no timestamps in the stream).
|
||||
Before the first source frame arrives, submit black frames (Y=16, CbCr=128).
|
||||
- If no OUTPUT buffer is free at slot time, wait for one (it's the encoder's latency; normal is a few ms). If the loop
|
||||
falls behind (several slots due), submit the missed slots back to back with the same picture. If more than `fps`
|
||||
slots (1 s) are missed at once (e.g. the process was stopped), log it, skip forward to the current slot and continue.
|
||||
- Wait with `ppoll` on: source fd (POLLIN), encoder fd (POLLIN = capture ready, POLLOUT = output buffer done),
|
||||
stdin (POLLIN|POLLHUP), timeout = time to the next slot.
|
||||
- stdout writes are blocking writes of whole packets (loop over partial writes; `EINTR`/`EAGAIN` retry).
|
||||
- Every 10 s print one stderr line: `fp_venc: stats frames=<n> repeats=<frames that reused an already-sent picture>
|
||||
late=<slots submitted late> skipped=<slots skipped> kbps=<average output bitrate>`.
|
||||
- All stderr lines start with `fp_venc: `. No output on stdout except the H.264 stream (or the probe JSON).
|
||||
|
||||
## Measured facts (the Frame, SteamOS 0.3.0 kernel 6.18, 2026-10-07)
|
||||
- Encoder: `/dev/video23` (`/dev/video-enc0` → it), name `qcom-iris-encoder`, driver `iris_driver`, caps
|
||||
M2M multiplanar + streaming. OUTPUT formats: Q08C, NV12, NV21, AB24, QC24. CAPTURE formats: H264, HEVC. Frame sizes
|
||||
128×128 … 8192×8192 step 1. The `steamos` user can open it (group `video`).
|
||||
- NV12 S_FMT results (stride / returned height / sizeimage): 640×360 → 640/384/368640; 854×480 → 896/480/647168;
|
||||
1280×720 → 1280/736/1413120; 1920×1080 → 1920/1088/3133440. Default OUTPUT crop = the requested size.
|
||||
- Controls present: B_FRAMES (0–7), GOP_SIZE, BITRATE_MODE (VBR, CBR), BITRATE / BITRATE_PEAK (≤ 245 000 000),
|
||||
FRAME_RC_ENABLE, HEADER_MODE (separate, joined with 1st frame), FORCE_KEY_FRAME, H264 PROFILE (Baseline, Constrained
|
||||
Baseline, Main, High, Constrained High), H264 LEVEL (1 … 6.0, default 5), PREPEND_SPSPPS_TO_IDR, FRAME_SKIP_MODE,
|
||||
H264 entropy (CABAC default), I/P QP ranges, intra-refresh period, LTR, hierarchical coding.
|
||||
- Source: `/dev/video99`, v4l2loopback, name `SteamVR`, single-planar capture, RGB24 only, 1920×1080, bytesperline
|
||||
5760, advertised 30 fps but frames come at the panel rate when worn, ~1.1 fps in standby.
|
||||
- DRM: `/dev/dri/card0` (msm, mode 0666); one active CRTC 4320×2160 (`2*2160x2160_96`, clock 1402720 kHz,
|
||||
htotal 4448, vtotal 3285 → 96.00 Hz). The panel offers 72/80/90/96/108/120/144 Hz.
|
||||
- ffmpeg's stock `h264_v4l2m2m` hangs on this encoder; that's why this program exists.
|
||||
@@ -0,0 +1,356 @@
|
||||
/* RGB24 -> NV12 converter (see convert.h and SPEC.md "Converter"). The scalar code is the definition; the NEON code
|
||||
* must produce the same bytes (fp_venc --selftest compares them). */
|
||||
#include "convert.h"
|
||||
|
||||
#if defined(__aarch64__)
|
||||
#include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
void fp_out_size(int src_w, int src_h, int max_h, int *out_w, int *out_h)
|
||||
{
|
||||
int h = (max_h <= 0 || max_h > src_h) ? src_h : max_h;
|
||||
h &= ~1;
|
||||
int w = (int)((int64_t)src_w * h / src_h) & ~1;
|
||||
*out_w = w < 2 ? 2 : w;
|
||||
*out_h = h < 2 ? 2 : h;
|
||||
}
|
||||
|
||||
static size_t align16(size_t n) { return (n + 15) & ~(size_t)15; }
|
||||
|
||||
/* Scratch layout for scaled output: per-column channel sums of the current output row's source rows (uint32, or
|
||||
* uint16 in the NEON path), the source column where each output column starts, and two scaled RGB rows (one NV12
|
||||
* row pair: chroma needs both). */
|
||||
size_t fp_scratch_size(int src_w, int src_h, int out_w, int out_h)
|
||||
{
|
||||
(void)src_h;
|
||||
(void)out_h;
|
||||
return align16((size_t)src_w * 3 * 4) + align16(((size_t)out_w + 1) * 4) + align16((size_t)out_w * 6 + 16);
|
||||
}
|
||||
|
||||
static uint8_t clamp_u8(int v, int lo, int hi) { return (uint8_t)(v < lo ? lo : v > hi ? hi : v); }
|
||||
|
||||
/* BT.709 limited range. `>>` on a negative int is an arithmetic (floor) shift with clang/gcc on every target we
|
||||
* build for, which is what the spec's formula means. */
|
||||
static uint8_t luma(int r, int g, int b) { return clamp_u8(16 + ((47 * r + 157 * g + 16 * b + 128) >> 8), 16, 235); }
|
||||
static uint8_t cb_of(int r, int g, int b) { return clamp_u8(128 + ((-26 * r - 86 * g + 112 * b + 128) >> 8), 16, 240); }
|
||||
static uint8_t cr_of(int r, int g, int b) { return clamp_u8(128 + ((112 * r - 102 * g - 10 * b + 128) >> 8), 16, 240); }
|
||||
|
||||
/* One NV12 row pair from two RGB rows, columns [x, w) (w even). */
|
||||
static void pair_scalar(const uint8_t *r0, const uint8_t *r1, int x, int w, uint8_t *y0, uint8_t *y1, uint8_t *uv)
|
||||
{
|
||||
for (; x < w; x += 2) {
|
||||
const uint8_t *a = r0 + x * 3, *b = r1 + x * 3;
|
||||
y0[x] = luma(a[0], a[1], a[2]);
|
||||
y0[x + 1] = luma(a[3], a[4], a[5]);
|
||||
y1[x] = luma(b[0], b[1], b[2]);
|
||||
y1[x + 1] = luma(b[3], b[4], b[5]);
|
||||
int r = (a[0] + a[3] + b[0] + b[3] + 2) >> 2;
|
||||
int g = (a[1] + a[4] + b[1] + b[4] + 2) >> 2;
|
||||
int bl = (a[2] + a[5] + b[2] + b[5] + 2) >> 2;
|
||||
uv[x] = cb_of(r, g, bl);
|
||||
uv[x + 1] = cr_of(r, g, bl);
|
||||
}
|
||||
}
|
||||
|
||||
struct layout { uint32_t *colsum; int32_t *xb; uint8_t *rgb; };
|
||||
|
||||
static struct layout split(void *scratch, int src_w, int out_w)
|
||||
{
|
||||
struct layout l;
|
||||
uint8_t *p = scratch;
|
||||
l.colsum = (uint32_t *)p;
|
||||
p += align16((size_t)src_w * 3 * 4);
|
||||
l.xb = (int32_t *)p;
|
||||
p += align16(((size_t)out_w + 1) * 4);
|
||||
l.rgb = p;
|
||||
for (int i = 0; i <= out_w; i++) l.xb[i] = (int32_t)((int64_t)i * src_w / out_w);
|
||||
return l;
|
||||
}
|
||||
|
||||
void fp_convert_scalar(const uint8_t *src, int src_w, int src_h, int src_stride,
|
||||
uint8_t *y, int y_stride, uint8_t *uv, int uv_stride,
|
||||
int out_w, int out_h, void *scratch)
|
||||
{
|
||||
if (out_w == src_w && out_h == src_h) {
|
||||
for (int j = 0; j < out_h; j += 2)
|
||||
pair_scalar(src + (size_t)j * src_stride, src + (size_t)(j + 1) * src_stride, 0, out_w,
|
||||
y + (size_t)j * y_stride, y + (size_t)(j + 1) * y_stride, uv + (size_t)(j / 2) * uv_stride);
|
||||
return;
|
||||
}
|
||||
struct layout l = split(scratch, src_w, out_w);
|
||||
int cols = src_w * 3;
|
||||
for (int j = 0; j < out_h; j++) {
|
||||
int ya = (int)((int64_t)j * src_h / out_h), yb = (int)((int64_t)(j + 1) * src_h / out_h);
|
||||
for (int k = 0; k < cols; k++) l.colsum[k] = 0;
|
||||
for (int r = ya; r < yb; r++) {
|
||||
const uint8_t *row = src + (size_t)r * src_stride;
|
||||
for (int k = 0; k < cols; k++) l.colsum[k] += row[k];
|
||||
}
|
||||
uint8_t *out = l.rgb + (size_t)(j & 1) * out_w * 3;
|
||||
for (int i = 0; i < out_w; i++) {
|
||||
int xa = l.xb[i], xe = l.xb[i + 1];
|
||||
uint64_t n = (uint64_t)(xe - xa) * (uint64_t)(yb - ya);
|
||||
for (int c = 0; c < 3; c++) {
|
||||
uint64_t s = 0;
|
||||
for (int x = xa; x < xe; x++) s += l.colsum[x * 3 + c];
|
||||
out[i * 3 + c] = (uint8_t)((s + n / 2) / n);
|
||||
}
|
||||
}
|
||||
if (j & 1)
|
||||
pair_scalar(l.rgb, l.rgb + (size_t)out_w * 3, 0, out_w, y + (size_t)(j - 1) * y_stride,
|
||||
y + (size_t)j * y_stride, uv + (size_t)(j / 2) * uv_stride);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__aarch64__)
|
||||
|
||||
/* 16 pixels of 2 rows -> 32 luma bytes + 8 CbCr pairs. All intermediates fit: luma sums <= 220*255+128 < 2^16
|
||||
* (uint16), chroma partial sums stay within +-28688 (int16). vrshrn_n_u16(x, 8) == (x + 128) >> 8 and
|
||||
* vrshrq_n_u16(x, 2) == (x + 2) >> 2 exactly (the rounding add is done without overflow). */
|
||||
static inline uint8x16_t luma16(uint8x16x3_t p)
|
||||
{
|
||||
uint16x8_t lo = vmull_u8(vget_low_u8(p.val[0]), vdup_n_u8(47));
|
||||
lo = vmlal_u8(lo, vget_low_u8(p.val[1]), vdup_n_u8(157));
|
||||
lo = vmlal_u8(lo, vget_low_u8(p.val[2]), vdup_n_u8(16));
|
||||
uint16x8_t hi = vmull_u8(vget_high_u8(p.val[0]), vdup_n_u8(47));
|
||||
hi = vmlal_u8(hi, vget_high_u8(p.val[1]), vdup_n_u8(157));
|
||||
hi = vmlal_u8(hi, vget_high_u8(p.val[2]), vdup_n_u8(16));
|
||||
uint8x16_t yv = vaddq_u8(vcombine_u8(vrshrn_n_u16(lo, 8), vrshrn_n_u16(hi, 8)), vdupq_n_u8(16));
|
||||
return vminq_u8(vmaxq_u8(yv, vdupq_n_u8(16)), vdupq_n_u8(235));
|
||||
}
|
||||
|
||||
static inline uint8x8_t chroma8(int16x8_t r, int16x8_t g, int16x8_t b, int16_t kr, int16_t kg, int16_t kb)
|
||||
{
|
||||
int16x8_t v = vmulq_n_s16(r, kr);
|
||||
v = vmlaq_n_s16(v, g, kg);
|
||||
v = vmlaq_n_s16(v, b, kb);
|
||||
v = vshrq_n_s16(vaddq_s16(v, vdupq_n_s16(128)), 8); /* arithmetic = floor */
|
||||
v = vaddq_s16(v, vdupq_n_s16(128));
|
||||
v = vminq_s16(vmaxq_s16(v, vdupq_n_s16(16)), vdupq_n_s16(240));
|
||||
return vqmovun_s16(v);
|
||||
}
|
||||
|
||||
static void pair_neon(const uint8_t *r0, const uint8_t *r1, int w, uint8_t *y0, uint8_t *y1, uint8_t *uv)
|
||||
{
|
||||
int x = 0;
|
||||
for (; x + 16 <= w; x += 16) {
|
||||
uint8x16x3_t a = vld3q_u8(r0 + x * 3), b = vld3q_u8(r1 + x * 3);
|
||||
vst1q_u8(y0 + x, luma16(a));
|
||||
vst1q_u8(y1 + x, luma16(b));
|
||||
int16x8_t rr = vreinterpretq_s16_u16(vrshrq_n_u16(vpadalq_u8(vpaddlq_u8(a.val[0]), b.val[0]), 2));
|
||||
int16x8_t gg = vreinterpretq_s16_u16(vrshrq_n_u16(vpadalq_u8(vpaddlq_u8(a.val[1]), b.val[1]), 2));
|
||||
int16x8_t bb = vreinterpretq_s16_u16(vrshrq_n_u16(vpadalq_u8(vpaddlq_u8(a.val[2]), b.val[2]), 2));
|
||||
uint8x8x2_t c;
|
||||
c.val[0] = chroma8(rr, gg, bb, -26, -86, 112);
|
||||
c.val[1] = chroma8(rr, gg, bb, 112, -102, -10);
|
||||
vst2_u8(uv + x, c);
|
||||
}
|
||||
pair_scalar(r0, r1, x, w, y0, y1, uv);
|
||||
}
|
||||
|
||||
/* Box sums of one output row's source rows, as uint16 (callers ensure rows * 255 fits). */
|
||||
static void vsum16(const uint8_t *src, int src_stride, int ya, int yb, int cols, uint16_t *cs)
|
||||
{
|
||||
const uint8_t *row = src + (size_t)ya * src_stride;
|
||||
int k = 0;
|
||||
for (; k + 16 <= cols; k += 16) {
|
||||
uint8x16_t v = vld1q_u8(row + k);
|
||||
vst1q_u16(cs + k, vmovl_u8(vget_low_u8(v)));
|
||||
vst1q_u16(cs + k + 8, vmovl_high_u8(v));
|
||||
}
|
||||
for (; k < cols; k++) cs[k] = row[k];
|
||||
for (int r = ya + 1; r < yb; r++) {
|
||||
row = src + (size_t)r * src_stride;
|
||||
k = 0;
|
||||
for (; k + 16 <= cols; k += 16) {
|
||||
uint8x16_t v = vld1q_u8(row + k);
|
||||
vst1q_u16(cs + k, vaddw_u8(vld1q_u16(cs + k), vget_low_u8(v)));
|
||||
vst1q_u16(cs + k + 8, vaddw_high_u8(vld1q_u16(cs + k + 8), v));
|
||||
}
|
||||
for (; k < cols; k++) cs[k] = (uint16_t)(cs[k] + row[k]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Exact fast paths for the two ratios the live view uses from SteamVR's 1920x1080: 3:2 (720p) and 3:1 (360p). The
|
||||
* box rule (x0 = i * src / out) then repeats every 3 source pixels: 3:2 gives widths 1, 2, 1, 2, ... (rows alike),
|
||||
* 3:1 width 3. Same bytes as the generic path, without its per-pixel scalar loop. */
|
||||
|
||||
/* 48 pixels of an RGB row -> ph[c][k] = channel c of pixels 3g+k, g = 0..15. */
|
||||
static inline void load48(const uint8_t *row, uint8x16_t ph[3][3])
|
||||
{
|
||||
uint8_t planes[3][48];
|
||||
for (int q = 0; q < 3; q++) {
|
||||
uint8x16x3_t p = vld3q_u8(row + q * 48);
|
||||
for (int c = 0; c < 3; c++) vst1q_u8(planes[c] + q * 16, p.val[c]);
|
||||
}
|
||||
for (int c = 0; c < 3; c++) {
|
||||
uint8x16x3_t s = vld3q_u8(planes[c]);
|
||||
ph[c][0] = s.val[0], ph[c][1] = s.val[1], ph[c][2] = s.val[2];
|
||||
}
|
||||
}
|
||||
|
||||
/* (a + b + c + d + 2) >> 2 for 16 lanes. */
|
||||
static inline uint8x16_t avg4(uint8x16_t a, uint8x16_t b, uint8x16_t c, uint8x16_t d)
|
||||
{
|
||||
uint16x8_t lo = vaddq_u16(vaddl_u8(vget_low_u8(a), vget_low_u8(b)), vaddl_u8(vget_low_u8(c), vget_low_u8(d)));
|
||||
uint16x8_t hi = vaddq_u16(vaddl_high_u8(a, b), vaddl_high_u8(c, d));
|
||||
return vcombine_u8(vrshrn_n_u16(lo, 2), vrshrn_n_u16(hi, 2));
|
||||
}
|
||||
|
||||
/* Store even/odd output pixels (16 each per channel) as 32 interleaved RGB pixels. */
|
||||
static inline void store_pairs(uint8_t *out, uint8x16_t even[3], uint8x16_t odd[3])
|
||||
{
|
||||
uint8x16x3_t a, b;
|
||||
for (int c = 0; c < 3; c++) a.val[c] = vzip1q_u8(even[c], odd[c]), b.val[c] = vzip2q_u8(even[c], odd[c]);
|
||||
vst3q_u8(out, a);
|
||||
vst3q_u8(out + 48, b);
|
||||
}
|
||||
|
||||
/* 3 source rows -> 2 RGB output rows (3:2 both ways): row a from r0 alone, row b from r1 + r2. */
|
||||
static void rows_3to2(const uint8_t *r0, const uint8_t *r1, const uint8_t *r2, int src_w, uint8_t *oa, uint8_t *ob)
|
||||
{
|
||||
int x = 0;
|
||||
uint8_t *pa = oa, *pb = ob;
|
||||
for (; x + 48 <= src_w; x += 48, pa += 96, pb += 96) {
|
||||
uint8x16_t a[3][3], b[3][3], c[3][3], ea[3], odda[3], eb[3], oddb[3];
|
||||
load48(r0 + x * 3, a), load48(r1 + x * 3, b), load48(r2 + x * 3, c);
|
||||
for (int ch = 0; ch < 3; ch++) {
|
||||
ea[ch] = a[ch][0]; /* 1x1 */
|
||||
odda[ch] = vrhaddq_u8(a[ch][1], a[ch][2]); /* 2x1: (s + 1) >> 1 */
|
||||
eb[ch] = vrhaddq_u8(b[ch][0], c[ch][0]); /* 1x2 */
|
||||
oddb[ch] = avg4(b[ch][1], b[ch][2], c[ch][1], c[ch][2]); /* 2x2: (s + 2) >> 2 */
|
||||
}
|
||||
store_pairs(pa, ea, odda);
|
||||
store_pairs(pb, eb, oddb);
|
||||
}
|
||||
for (; x < src_w; x += 3, pa += 6, pb += 6)
|
||||
for (int ch = 0; ch < 3; ch++) {
|
||||
const uint8_t *p0 = r0 + x * 3 + ch, *p1 = r1 + x * 3 + ch, *p2 = r2 + x * 3 + ch;
|
||||
pa[ch] = p0[0];
|
||||
pa[3 + ch] = (uint8_t)((p0[3] + p0[6] + 1) >> 1);
|
||||
pb[ch] = (uint8_t)((p1[0] + p2[0] + 1) >> 1);
|
||||
pb[3 + ch] = (uint8_t)((p1[3] + p1[6] + p2[3] + p2[6] + 2) >> 2);
|
||||
}
|
||||
}
|
||||
|
||||
/* 3 source rows -> 1 RGB output row (3:1 both ways): (sum of 9 + 4) / 9, the division as *7282 >> 16 (exact for
|
||||
* every sum up to 9 * 255 + 4). */
|
||||
static void row_3to1(const uint8_t *r0, const uint8_t *r1, const uint8_t *r2, int src_w, uint8_t *out)
|
||||
{
|
||||
int x = 0;
|
||||
uint8_t *p = out;
|
||||
for (; x + 48 <= src_w; x += 48, p += 48) {
|
||||
uint8x16_t a[3][3], b[3][3], c[3][3];
|
||||
load48(r0 + x * 3, a), load48(r1 + x * 3, b), load48(r2 + x * 3, c);
|
||||
uint8x16x3_t o;
|
||||
for (int ch = 0; ch < 3; ch++) {
|
||||
uint16x8_t lo = vdupq_n_u16(4), hi = vdupq_n_u16(4);
|
||||
for (int k = 0; k < 3; k++) {
|
||||
lo = vaddw_u8(vaddw_u8(vaddw_u8(lo, vget_low_u8(a[ch][k])), vget_low_u8(b[ch][k])), vget_low_u8(c[ch][k]));
|
||||
hi = vaddw_high_u8(vaddw_high_u8(vaddw_high_u8(hi, a[ch][k]), b[ch][k]), c[ch][k]);
|
||||
}
|
||||
uint16x4_t m = vdup_n_u16(7282);
|
||||
uint16x8_t qlo = vcombine_u16(vshrn_n_u32(vmull_u16(vget_low_u16(lo), m), 16),
|
||||
vshrn_n_u32(vmull_u16(vget_high_u16(lo), m), 16));
|
||||
uint16x8_t qhi = vcombine_u16(vshrn_n_u32(vmull_u16(vget_low_u16(hi), m), 16),
|
||||
vshrn_n_u32(vmull_u16(vget_high_u16(hi), m), 16));
|
||||
o.val[ch] = vcombine_u8(vmovn_u16(qlo), vmovn_u16(qhi));
|
||||
}
|
||||
vst3q_u8(p, o);
|
||||
}
|
||||
for (; x < src_w; x += 3, p += 3)
|
||||
for (int ch = 0; ch < 3; ch++) {
|
||||
int s = 4;
|
||||
for (int k = 0; k < 3; k++) s += r0[(x + k) * 3 + ch] + r1[(x + k) * 3 + ch] + r2[(x + k) * 3 + ch];
|
||||
p[ch] = (uint8_t)(s / 9);
|
||||
}
|
||||
}
|
||||
|
||||
#define MAX_RECIP_BW 64
|
||||
|
||||
void fp_convert(const uint8_t *src, int src_w, int src_h, int src_stride,
|
||||
uint8_t *y, int y_stride, uint8_t *uv, int uv_stride,
|
||||
int out_w, int out_h, void *scratch)
|
||||
{
|
||||
if (out_w == src_w && out_h == src_h) {
|
||||
for (int j = 0; j < out_h; j += 2)
|
||||
pair_neon(src + (size_t)j * src_stride, src + (size_t)(j + 1) * src_stride, out_w,
|
||||
y + (size_t)j * y_stride, y + (size_t)(j + 1) * y_stride, uv + (size_t)(j / 2) * uv_stride);
|
||||
return;
|
||||
}
|
||||
if (src_w * 2 == out_w * 3 && src_h * 2 == out_h * 3) { /* 3:2 (out_h even: whole 3-row groups) */
|
||||
struct layout l = split(scratch, src_w, out_w);
|
||||
uint8_t *a = l.rgb, *b = l.rgb + (size_t)out_w * 3;
|
||||
for (int t = 0; t < out_h / 2; t++) {
|
||||
const uint8_t *r0 = src + (size_t)(3 * t) * src_stride;
|
||||
rows_3to2(r0, r0 + src_stride, r0 + 2 * (size_t)src_stride, src_w, a, b);
|
||||
pair_neon(a, b, out_w, y + (size_t)(2 * t) * y_stride, y + (size_t)(2 * t + 1) * y_stride,
|
||||
uv + (size_t)t * uv_stride);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (src_w == out_w * 3 && src_h == out_h * 3) { /* 3:1 */
|
||||
struct layout l = split(scratch, src_w, out_w);
|
||||
uint8_t *a = l.rgb, *b = l.rgb + (size_t)out_w * 3;
|
||||
for (int j = 0; j < out_h; j += 2) {
|
||||
const uint8_t *r0 = src + (size_t)(3 * j) * src_stride, *r3 = r0 + 3 * (size_t)src_stride;
|
||||
row_3to1(r0, r0 + src_stride, r0 + 2 * (size_t)src_stride, src_w, a);
|
||||
row_3to1(r3, r3 + src_stride, r3 + 2 * (size_t)src_stride, src_w, b);
|
||||
pair_neon(a, b, out_w, y + (size_t)j * y_stride, y + (size_t)(j + 1) * y_stride,
|
||||
uv + (size_t)(j / 2) * uv_stride);
|
||||
}
|
||||
return;
|
||||
}
|
||||
int bh_max = (src_h + out_h - 1) / out_h + 1;
|
||||
if (bh_max > 257) { /* uint16 column sums would overflow: extreme downscale, not worth a NEON path */
|
||||
fp_convert_scalar(src, src_w, src_h, src_stride, y, y_stride, uv, uv_stride, out_w, out_h, scratch);
|
||||
return;
|
||||
}
|
||||
struct layout l = split(scratch, src_w, out_w);
|
||||
uint16_t *cs = (uint16_t *)l.colsum;
|
||||
int cols = src_w * 3;
|
||||
for (int j = 0; j < out_h; j++) {
|
||||
int ya = (int)((int64_t)j * src_h / out_h), yb = (int)((int64_t)(j + 1) * src_h / out_h);
|
||||
int bh = yb - ya;
|
||||
vsum16(src, src_stride, ya, yb, cols, cs);
|
||||
/* (S + n/2) / n as a multiply: with m = ceil(2^32 / n) and e = m*n - 2^32 < n, floor(x*m / 2^32) ==
|
||||
* floor(x / n) whenever x*e < 2^32. Here x < 256*n, so n <= 4096 is enough. Otherwise divide. */
|
||||
uint64_t recip[MAX_RECIP_BW + 1];
|
||||
for (int bw = 1; bw <= MAX_RECIP_BW; bw++) {
|
||||
uint64_t n = (uint64_t)bw * bh;
|
||||
recip[bw] = n <= 4096 ? ((1ULL << 32) + n - 1) / n : 0;
|
||||
}
|
||||
uint8_t *out = l.rgb + (size_t)(j & 1) * out_w * 3;
|
||||
for (int i = 0; i < out_w; i++) {
|
||||
int xa = l.xb[i], bw = l.xb[i + 1] - xa;
|
||||
const uint16_t *c = cs + xa * 3;
|
||||
uint32_t sr = 0, sg = 0, sb = 0;
|
||||
for (int x = 0; x < bw; x++, c += 3) sr += c[0], sg += c[1], sb += c[2];
|
||||
uint64_t n = (uint64_t)bw * bh, half = n / 2;
|
||||
uint64_t m = bw <= MAX_RECIP_BW ? recip[bw] : 0;
|
||||
if (m) {
|
||||
out[i * 3] = (uint8_t)(((sr + half) * m) >> 32);
|
||||
out[i * 3 + 1] = (uint8_t)(((sg + half) * m) >> 32);
|
||||
out[i * 3 + 2] = (uint8_t)(((sb + half) * m) >> 32);
|
||||
} else {
|
||||
out[i * 3] = (uint8_t)((sr + half) / n);
|
||||
out[i * 3 + 1] = (uint8_t)((sg + half) / n);
|
||||
out[i * 3 + 2] = (uint8_t)((sb + half) / n);
|
||||
}
|
||||
}
|
||||
if (j & 1)
|
||||
pair_neon(l.rgb, l.rgb + (size_t)out_w * 3, out_w, y + (size_t)(j - 1) * y_stride,
|
||||
y + (size_t)j * y_stride, uv + (size_t)(j / 2) * uv_stride);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void fp_convert(const uint8_t *src, int src_w, int src_h, int src_stride,
|
||||
uint8_t *y, int y_stride, uint8_t *uv, int uv_stride,
|
||||
int out_w, int out_h, void *scratch)
|
||||
{
|
||||
fp_convert_scalar(src, src_w, src_h, src_stride, y, y_stride, uv, uv_stride, out_w, out_h, scratch);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
/* RGB24 -> NV12 picture converter for fp_venc (pure computation, no syscalls). See native/venc/SPEC.md "Converter".
|
||||
* Built for aarch64 (NEON + scalar) and for x86_64 (scalar only; the host unit test loads it with ctypes). */
|
||||
#ifndef FP_VENC_CONVERT_H
|
||||
#define FP_VENC_CONVERT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* Output size: height = min(max_h, src_h) (max_h <= 0 = src_h), width keeps the aspect; both rounded down to even,
|
||||
* both >= 2. */
|
||||
void fp_out_size(int src_w, int src_h, int max_h, int *out_w, int *out_h);
|
||||
|
||||
/* Bytes of scratch memory fp_convert/fp_convert_scalar need for these sizes. */
|
||||
size_t fp_scratch_size(int src_w, int src_h, int out_w, int out_h);
|
||||
|
||||
/* RGB24 (R,G,B bytes) -> NV12 (BT.709, limited range): box-average downscale to out_w x out_h (out_w <= src_w,
|
||||
* out_h <= src_h, both even), then out_w x out_h luma bytes and out_w x out_h/2 interleaved Cb,Cr bytes. */
|
||||
void fp_convert_scalar(const uint8_t *src, int src_w, int src_h, int src_stride,
|
||||
uint8_t *y, int y_stride, uint8_t *uv, int uv_stride,
|
||||
int out_w, int out_h, void *scratch);
|
||||
|
||||
/* Same result, byte for byte; NEON on aarch64, fp_convert_scalar elsewhere. */
|
||||
void fp_convert(const uint8_t *src, int src_w, int src_h, int src_stride,
|
||||
uint8_t *y, int y_stride, uint8_t *uv, int uv_stride,
|
||||
int out_w, int out_h, void *scratch);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,858 @@
|
||||
/* fp_venc: hardware H.264 encoding of the Steam Frame's SteamVR "headset view" webcam for FramePort's live view.
|
||||
* Source (v4l2loopback, RGB24) -> NV12 (convert.c) -> the SoC's V4L2 stateful encoder -> H.264 Annex B on stdout.
|
||||
* Specification: native/venc/SPEC.md (V4L2: kernel Documentation/userspace-api/media/v4l/dev-encoder.rst). */
|
||||
#include "sys.h"
|
||||
#include "convert.h"
|
||||
#include <linux/videodev2.h>
|
||||
#include <drm/drm.h>
|
||||
#include <drm/drm_mode.h>
|
||||
|
||||
#define SRC_BUFS 3
|
||||
#define ENC_BUFS 4
|
||||
#define TAG "fp_venc: "
|
||||
|
||||
/* ---------------------------------------------------------------- output helpers */
|
||||
|
||||
static void say(const char *a, const char *b, long n, int with_n)
|
||||
{
|
||||
struct line l = {.n = 0};
|
||||
ls(&l, TAG);
|
||||
ls(&l, a);
|
||||
if (b) ls(&l, b);
|
||||
if (with_n) ln(&l, n);
|
||||
ls(&l, "\n");
|
||||
write_all(2, l.b, (size_t)l.n);
|
||||
}
|
||||
static void msg(const char *a) { say(a, 0, 0, 0); }
|
||||
static void msg_err(const char *what, long err) { say(what, " failed, errno ", -err, 1); }
|
||||
static int fail(int code, const char *what, long err)
|
||||
{
|
||||
msg_err(what, err);
|
||||
return code;
|
||||
}
|
||||
|
||||
/* Whole-packet blocking write to stdout. Returns 0, or -1 when the reader is gone (EPIPE etc.). */
|
||||
static int out_all(const uint8_t *p, size_t n)
|
||||
{
|
||||
while (n) {
|
||||
long r = sys_write(1, p, n);
|
||||
if (r == -EINTR) continue;
|
||||
if (r == -EAGAIN) { /* stdout happens to be non-blocking: wait instead of spinning */
|
||||
struct pollfd_k f = {1, POLLOUT, 0};
|
||||
sys_ppoll(&f, 1, 0);
|
||||
continue;
|
||||
}
|
||||
if (r <= 0) return -1;
|
||||
p += r;
|
||||
n -= (size_t)r;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- options */
|
||||
|
||||
struct opts {
|
||||
long height, bitrate, peak, fps, max_fps, gop_seconds;
|
||||
const char *source, *encoder;
|
||||
int probe, selftest;
|
||||
};
|
||||
|
||||
static int parse_args(int argc, char **argv, struct opts *o)
|
||||
{
|
||||
o->height = 0, o->bitrate = 3000000, o->peak = 0, o->fps = 0, o->max_fps = 45, o->gop_seconds = 4;
|
||||
o->source = o->encoder = 0;
|
||||
o->probe = o->selftest = 0;
|
||||
for (int i = 1; i < argc; i++) {
|
||||
const char *a = argv[i];
|
||||
long *num = 0;
|
||||
long lo = 1, hi = 0x7fffffff;
|
||||
if (str_eq(a, "--probe")) { o->probe = 1; continue; }
|
||||
if (str_eq(a, "--selftest")) { o->selftest = 1; continue; }
|
||||
if (i + 1 >= argc) return 0;
|
||||
if (str_eq(a, "--source")) { o->source = argv[++i]; continue; }
|
||||
if (str_eq(a, "--encoder")) { o->encoder = argv[++i]; continue; }
|
||||
if (str_eq(a, "--height")) num = &o->height, lo = 2;
|
||||
else if (str_eq(a, "--bitrate")) num = &o->bitrate, lo = 10000;
|
||||
else if (str_eq(a, "--peak")) num = &o->peak, lo = 10000, hi = 245000000;
|
||||
else if (str_eq(a, "--fps")) num = &o->fps, hi = 240;
|
||||
else if (str_eq(a, "--max-fps")) num = &o->max_fps, hi = 240;
|
||||
else if (str_eq(a, "--gop-seconds")) num = &o->gop_seconds, hi = 3600;
|
||||
else return 0;
|
||||
if (!parse_uint(argv[++i], num) || *num < lo || *num > hi) return 0;
|
||||
}
|
||||
return !(o->probe && o->selftest);
|
||||
}
|
||||
|
||||
static const char *getenv_(char **envp, const char *name)
|
||||
{
|
||||
size_t n = str_len(name);
|
||||
for (; envp && *envp; envp++) {
|
||||
const char *e = *envp;
|
||||
size_t i = 0;
|
||||
while (i < n && e[i] == name[i]) i++;
|
||||
if (i == n && e[n] == '=') return e + n + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *alloc(size_t n)
|
||||
{
|
||||
void *p = sys_mmap(0, n, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
return mmap_failed(p) ? 0 : p;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- converter self-test */
|
||||
|
||||
static void fill_image(uint8_t *p, int w, int h, int stride, int kind)
|
||||
{
|
||||
uint32_t s = 12345;
|
||||
for (int y = 0; y < h; y++)
|
||||
for (int x = 0; x < w; x++) {
|
||||
uint8_t *q = p + (size_t)y * stride + x * 3;
|
||||
uint8_t r = 0, g = 0, b = 0;
|
||||
switch (kind) {
|
||||
case 0: /* 32-bit LCG noise */
|
||||
s = s * 1664525u + 1013904223u, r = (uint8_t)(s >> 24);
|
||||
s = s * 1664525u + 1013904223u, g = (uint8_t)(s >> 24);
|
||||
s = s * 1664525u + 1013904223u, b = (uint8_t)(s >> 24);
|
||||
break;
|
||||
case 1: r = g = b = (uint8_t)(x * 255 / (w > 1 ? w - 1 : 1)); break; /* horizontal gradient */
|
||||
case 2: break; /* black */
|
||||
case 3: r = g = b = 255; break; /* white */
|
||||
case 4: r = 255; break;
|
||||
case 5: g = 255; break;
|
||||
case 6: b = 255; break;
|
||||
default: r = g = b = ((x ^ y) & 1) ? 255 : 0; break; /* 1-pixel checkerboard */
|
||||
}
|
||||
q[0] = r, q[1] = g, q[2] = b;
|
||||
}
|
||||
}
|
||||
|
||||
static int selftest(void)
|
||||
{
|
||||
/* 1158x648: 3:2 (-> 432) and 3:1 (-> 216) fast paths with columns left over after their 48-pixel steps */
|
||||
static const int sizes[5][2] = {{1920, 1080}, {1922, 1080}, {333, 201}, {64, 64}, {1158, 648}};
|
||||
static const int heights[7] = {0, 720, 480, 360, 100, 432, 216};
|
||||
size_t src_cap = (size_t)(1922 * 3 + 13) * 1080, plane_cap = (size_t)(1922 + 37) * 1080;
|
||||
uint8_t *src = alloc(src_cap), *ya = alloc(plane_cap), *yb = alloc(plane_cap);
|
||||
uint8_t *uva = alloc(plane_cap), *uvb = alloc(plane_cap);
|
||||
void *scratch = alloc(fp_scratch_size(1922, 1080, 1922, 1080) + 4096);
|
||||
if (!src || !ya || !yb || !uva || !uvb || !scratch) return fail(1, "selftest memory", -ENOMEM);
|
||||
int cases = 0;
|
||||
for (int s = 0; s < 5; s++)
|
||||
for (int k = 0; k < 8; k++) {
|
||||
int w = sizes[s][0], h = sizes[s][1], stride = w * 3 + 13; /* odd stride: catches stride bugs */
|
||||
fill_image(src, w, h, stride, k);
|
||||
for (int hi = 0; hi < 7; hi++) {
|
||||
if (heights[hi] > h) continue;
|
||||
int ow, oh;
|
||||
fp_out_size(w, h, heights[hi], &ow, &oh);
|
||||
int ys = ow + 37, uvs = ow + 21;
|
||||
memset(ya, 0x5a, (size_t)ys * oh), memset(yb, 0x5a, (size_t)ys * oh);
|
||||
memset(uva, 0x5a, (size_t)uvs * oh / 2), memset(uvb, 0x5a, (size_t)uvs * oh / 2);
|
||||
fp_convert_scalar(src, w, h, stride, ya, ys, uva, uvs, ow, oh, scratch);
|
||||
fp_convert(src, w, h, stride, yb, ys, uvb, uvs, ow, oh, scratch);
|
||||
cases++;
|
||||
for (int pl = 0; pl < 2; pl++) {
|
||||
const uint8_t *a = pl ? uva : ya, *b = pl ? uvb : yb;
|
||||
int st = pl ? uvs : ys, rows = pl ? oh / 2 : oh;
|
||||
for (int y = 0; y < rows; y++)
|
||||
for (int x = 0; x < st; x++) {
|
||||
if (a[(size_t)y * st + x] == b[(size_t)y * st + x]) continue;
|
||||
struct line l = {.n = 0};
|
||||
ls(&l, TAG "selftest mismatch: ");
|
||||
ln(&l, w), ls(&l, "x"), ln(&l, h), ls(&l, " -> "), ln(&l, ow), ls(&l, "x"), ln(&l, oh);
|
||||
ls(&l, " image "), ln(&l, k), ls(&l, pl ? " plane UV" : " plane Y");
|
||||
ls(&l, " x="), ln(&l, x), ls(&l, " y="), ln(&l, y);
|
||||
ls(&l, " scalar="), ln(&l, a[(size_t)y * st + x]);
|
||||
ls(&l, " fast="), ln(&l, b[(size_t)y * st + x]), ls(&l, "\n");
|
||||
write_all(2, l.b, (size_t)l.n);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
struct line ok = {.n = 0};
|
||||
ls(&ok, TAG "selftest ok ("), ln(&ok, cases), ls(&ok, " cases)\n");
|
||||
write_all(2, ok.b, (size_t)ok.n);
|
||||
/* Speed of the real path on the real source size. */
|
||||
fill_image(src, 1920, 1080, 5760, 0);
|
||||
static const int timed[4] = {1080, 720, 480, 360};
|
||||
for (int t = 0; t < 4; t++) {
|
||||
int ow, oh;
|
||||
fp_out_size(1920, 1080, timed[t], &ow, &oh);
|
||||
int64_t t0 = now_ns();
|
||||
for (int i = 0; i < 50; i++) fp_convert(src, 1920, 1080, 5760, ya, ow, uva, ow, ow, oh, scratch);
|
||||
struct line l = {.n = 0};
|
||||
ls(&l, TAG "selftest 1920x1080 -> "), ln(&l, oh), ls(&l, ": "), lms(&l, (now_ns() - t0) / 50), ls(&l, " ms\n");
|
||||
write_all(2, l.b, (size_t)l.n);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- devices */
|
||||
|
||||
static int read_small(const char *path, char *buf, int cap)
|
||||
{
|
||||
int fd = sys_open(path, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) return -1;
|
||||
long n = sys_read(fd, buf, (size_t)cap - 1);
|
||||
sys_close(fd);
|
||||
if (n < 0) return -1;
|
||||
while (n > 0 && (buf[n - 1] == '\n' || buf[n - 1] == '\r')) n--;
|
||||
buf[n] = 0;
|
||||
return (int)n;
|
||||
}
|
||||
|
||||
/* "/sys/class/video4linux/video<n>/name" / "/dev/video<n>" */
|
||||
static void node_path(char *out, const char *pre, int n, const char *post)
|
||||
{
|
||||
struct line l = {.n = 0};
|
||||
ls(&l, pre), ln(&l, n), ls(&l, post);
|
||||
memcpy(out, l.b, (size_t)l.n);
|
||||
out[l.n] = 0;
|
||||
}
|
||||
|
||||
static uint32_t v4l2_caps(int fd)
|
||||
{
|
||||
struct v4l2_capability cap;
|
||||
memset(&cap, 0, sizeof cap);
|
||||
if (sys_ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0) return 0;
|
||||
return (cap.capabilities & V4L2_CAP_DEVICE_CAPS) ? cap.device_caps : cap.capabilities;
|
||||
}
|
||||
|
||||
static int enc_caps_ok(uint32_t c) { return (c & V4L2_CAP_VIDEO_M2M_MPLANE) && (c & V4L2_CAP_STREAMING); }
|
||||
|
||||
static int find_source(char *path)
|
||||
{
|
||||
char name[128], sys[96];
|
||||
for (int n = 0; n < 256; n++) {
|
||||
node_path(sys, "/sys/class/video4linux/video", n, "/name");
|
||||
if (read_small(sys, name, sizeof name) >= 0 && str_eq(name, "SteamVR")) {
|
||||
node_path(path, "/dev/video", n, "");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int find_encoder(char *path)
|
||||
{
|
||||
char link[64];
|
||||
long n = sys_readlink("/dev/video-enc0", link, sizeof link - 1);
|
||||
if (n > 0) { /* report the real node (/dev/video23), as the PC side shows it */
|
||||
link[n] = 0;
|
||||
struct line l = {.n = 0};
|
||||
if (link[0] != '/') ls(&l, "/dev/");
|
||||
ls(&l, link);
|
||||
memcpy(path, l.b, (size_t)l.n);
|
||||
path[l.n] = 0;
|
||||
return 1;
|
||||
}
|
||||
int fd = sys_open("/dev/video-enc0", O_RDWR | O_CLOEXEC);
|
||||
if (fd >= 0) {
|
||||
sys_close(fd);
|
||||
memcpy(path, "/dev/video-enc0", 16);
|
||||
return 1;
|
||||
}
|
||||
char name[128], sys[96];
|
||||
for (int i = 0; i < 256; i++) {
|
||||
node_path(sys, "/sys/class/video4linux/video", i, "/name");
|
||||
if (read_small(sys, name, sizeof name) < 0 || !str_contains(name, "encoder")) continue;
|
||||
node_path(path, "/dev/video", i, "");
|
||||
fd = sys_open(path, O_RDWR | O_NONBLOCK | O_CLOEXEC);
|
||||
if (fd < 0) continue;
|
||||
int ok = enc_caps_ok(v4l2_caps(fd));
|
||||
sys_close(fd);
|
||||
if (ok) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Panel refresh in whole Hz via DRM KMS (read-only ioctls, no master needed); 0 = unknown. */
|
||||
static int panel_refresh(void)
|
||||
{
|
||||
int fd = sys_open("/dev/dri/card0", O_RDWR | O_CLOEXEC);
|
||||
if (fd < 0) return 0;
|
||||
struct drm_mode_card_res res;
|
||||
uint32_t ids[16];
|
||||
int best = 0;
|
||||
uint64_t best_area = 0;
|
||||
memset(&res, 0, sizeof res);
|
||||
if (sys_ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res) == 0 && res.count_crtcs) {
|
||||
uint32_t n = res.count_crtcs > 16 ? 16 : res.count_crtcs;
|
||||
memset(&res, 0, sizeof res);
|
||||
res.count_crtcs = n; /* other counts 0: the kernel copies only the arrays we provide room for */
|
||||
res.crtc_id_ptr = (uint64_t)(uintptr_t)ids;
|
||||
if (sys_ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res) == 0) {
|
||||
if (res.count_crtcs < n) n = res.count_crtcs;
|
||||
for (uint32_t i = 0; i < n; i++) {
|
||||
struct drm_mode_crtc c;
|
||||
memset(&c, 0, sizeof c);
|
||||
c.crtc_id = ids[i];
|
||||
if (sys_ioctl(fd, DRM_IOCTL_MODE_GETCRTC, &c) < 0 || !c.mode_valid) continue;
|
||||
uint64_t area = (uint64_t)c.mode.hdisplay * c.mode.vdisplay;
|
||||
uint64_t tot = (uint64_t)c.mode.htotal * c.mode.vtotal;
|
||||
if (area <= best_area || !tot) continue;
|
||||
uint64_t mhz = (uint64_t)c.mode.clock * 1000000 / tot;
|
||||
best_area = area;
|
||||
best = (int)((mhz + 500) / 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
sys_close(fd);
|
||||
return best;
|
||||
}
|
||||
|
||||
/* H.264 Table A-1 (MaxMBPS, MaxFS, MaxBR in 1000 bit/s; High profile allows 1.25x MaxBR). */
|
||||
static int pick_level(int w, int h, int fps, long bitrate)
|
||||
{
|
||||
static const struct { int level; long mbps, fs, br; } t[] = {
|
||||
{V4L2_MPEG_VIDEO_H264_LEVEL_3_1, 108000, 3600, 14000}, {V4L2_MPEG_VIDEO_H264_LEVEL_3_2, 216000, 5120, 20000},
|
||||
{V4L2_MPEG_VIDEO_H264_LEVEL_4_0, 245760, 8192, 20000}, {V4L2_MPEG_VIDEO_H264_LEVEL_4_1, 245760, 8192, 50000},
|
||||
{V4L2_MPEG_VIDEO_H264_LEVEL_4_2, 522240, 8704, 50000}, {V4L2_MPEG_VIDEO_H264_LEVEL_5_0, 589824, 22080, 135000},
|
||||
{V4L2_MPEG_VIDEO_H264_LEVEL_5_1, 983040, 36864, 240000}, {V4L2_MPEG_VIDEO_H264_LEVEL_5_2, 2073600, 36864, 240000},
|
||||
};
|
||||
long fs = (long)((w + 15) / 16) * ((h + 15) / 16);
|
||||
for (unsigned i = 0; i < sizeof t / sizeof t[0]; i++)
|
||||
if (fs <= t[i].fs && fs * fps <= t[i].mbps && bitrate <= t[i].br * 1250) return t[i].level;
|
||||
return V4L2_MPEG_VIDEO_H264_LEVEL_5_2;
|
||||
}
|
||||
|
||||
static int set_ctrl(int fd, uint32_t id, int32_t value, const char *name, int quiet)
|
||||
{
|
||||
struct v4l2_ext_control c;
|
||||
struct v4l2_ext_controls cs;
|
||||
memset(&c, 0, sizeof c);
|
||||
memset(&cs, 0, sizeof cs);
|
||||
c.id = id;
|
||||
c.value = value;
|
||||
cs.which = V4L2_CTRL_WHICH_CUR_VAL;
|
||||
cs.count = 1;
|
||||
cs.controls = &c;
|
||||
int r = sys_ioctl(fd, VIDIOC_S_EXT_CTRLS, &cs);
|
||||
if (r < 0 && !quiet) {
|
||||
struct line l = {.n = 0};
|
||||
ls(&l, TAG "warning: "), ls(&l, name), ls(&l, " refused ("), ln(&l, -r), ls(&l, ")\n");
|
||||
write_all(2, l.b, (size_t)l.n);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
struct src {
|
||||
int fd, w, h, stride;
|
||||
uint8_t *mem[SRC_BUFS];
|
||||
uint32_t len[SRC_BUFS];
|
||||
int held; /* index of the dequeued (newest) buffer we keep, -1 = none yet */
|
||||
int fresh; /* the held picture has not been encoded yet */
|
||||
};
|
||||
|
||||
struct enc {
|
||||
int fd, stride, hpad;
|
||||
uint32_t out_size, cap_size;
|
||||
uint8_t *out_mem[ENC_BUFS], *cap_mem[ENC_BUFS];
|
||||
uint32_t out_len[ENC_BUFS], cap_len[ENC_BUFS];
|
||||
int out_free[ENC_BUFS];
|
||||
long out_pic[ENC_BUFS]; /* which picture each OUTPUT buffer holds (0 = black, -1 = none): a repeat that finds
|
||||
* its picture already in the buffer skips the conversion (standby, still scenes) */
|
||||
};
|
||||
|
||||
static int src_open(struct src *s, const char *path)
|
||||
{
|
||||
s->held = -1, s->fresh = 0;
|
||||
s->fd = sys_open(path, O_RDWR | O_NONBLOCK | O_CLOEXEC);
|
||||
if (s->fd < 0) return fail(3, "open source", s->fd);
|
||||
uint32_t c = v4l2_caps(s->fd);
|
||||
if (!(c & V4L2_CAP_VIDEO_CAPTURE) || !(c & V4L2_CAP_STREAMING)) return fail(3, "source capabilities", -EINVAL);
|
||||
struct v4l2_format f;
|
||||
memset(&f, 0, sizeof f);
|
||||
f.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
int r = sys_ioctl(s->fd, VIDIOC_G_FMT, &f);
|
||||
if (r < 0) return fail(3, "source VIDIOC_G_FMT", r);
|
||||
if (f.fmt.pix.pixelformat != V4L2_PIX_FMT_RGB24) {
|
||||
msg("source pixel format is not RGB24");
|
||||
return 4;
|
||||
}
|
||||
s->w = (int)f.fmt.pix.width, s->h = (int)f.fmt.pix.height;
|
||||
s->stride = f.fmt.pix.bytesperline ? (int)f.fmt.pix.bytesperline : s->w * 3;
|
||||
if (s->w < 2 || s->h < 2 || s->stride < s->w * 3) return fail(4, "source size", -EINVAL);
|
||||
struct v4l2_requestbuffers rb;
|
||||
memset(&rb, 0, sizeof rb);
|
||||
rb.count = SRC_BUFS, rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE, rb.memory = V4L2_MEMORY_MMAP;
|
||||
r = sys_ioctl(s->fd, VIDIOC_REQBUFS, &rb);
|
||||
/* The driver may grant fewer (the Frame's v4l2loopback has max_buffers=2); two are enough: one held, one filling. */
|
||||
if (r < 0 || rb.count < 2) return fail(3, "source VIDIOC_REQBUFS", r < 0 ? r : -ENOMEM);
|
||||
if (rb.count > SRC_BUFS) rb.count = SRC_BUFS;
|
||||
for (int i = 0; i < (int)rb.count; i++) {
|
||||
struct v4l2_buffer b;
|
||||
memset(&b, 0, sizeof b);
|
||||
b.index = (uint32_t)i, b.type = V4L2_BUF_TYPE_VIDEO_CAPTURE, b.memory = V4L2_MEMORY_MMAP;
|
||||
r = sys_ioctl(s->fd, VIDIOC_QUERYBUF, &b);
|
||||
if (r < 0) return fail(3, "source VIDIOC_QUERYBUF", r);
|
||||
if (b.length < (uint32_t)(s->stride * (s->h - 1) + s->w * 3)) return fail(3, "source buffer size", -EINVAL);
|
||||
s->mem[i] = sys_mmap(0, b.length, PROT_READ, MAP_SHARED, s->fd, b.m.offset);
|
||||
if (mmap_failed(s->mem[i])) return fail(3, "source mmap", (long)s->mem[i]);
|
||||
s->len[i] = b.length;
|
||||
r = sys_ioctl(s->fd, VIDIOC_QBUF, &b);
|
||||
if (r < 0) return fail(3, "source VIDIOC_QBUF", r);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Drain every ready source buffer, keeping only the newest one. */
|
||||
static void src_drain(struct src *s)
|
||||
{
|
||||
for (;;) {
|
||||
struct v4l2_buffer b;
|
||||
memset(&b, 0, sizeof b);
|
||||
b.type = V4L2_BUF_TYPE_VIDEO_CAPTURE, b.memory = V4L2_MEMORY_MMAP;
|
||||
if (sys_ioctl(s->fd, VIDIOC_DQBUF, &b) < 0) return;
|
||||
if (b.flags & V4L2_BUF_FLAG_ERROR) {
|
||||
sys_ioctl(s->fd, VIDIOC_QBUF, &b);
|
||||
continue;
|
||||
}
|
||||
if (s->held >= 0) {
|
||||
struct v4l2_buffer q;
|
||||
memset(&q, 0, sizeof q);
|
||||
q.index = (uint32_t)s->held, q.type = V4L2_BUF_TYPE_VIDEO_CAPTURE, q.memory = V4L2_MEMORY_MMAP;
|
||||
sys_ioctl(s->fd, VIDIOC_QBUF, &q);
|
||||
}
|
||||
s->held = (int)b.index;
|
||||
s->fresh = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ts_us: OUTPUT buffers carry their slot time (the encoder copies it to the coded buffer; rate control may use it). */
|
||||
static int enc_queue_buf(struct enc *e, uint32_t type, int i, uint32_t used, int64_t ts_us)
|
||||
{
|
||||
struct v4l2_plane p;
|
||||
struct v4l2_buffer b;
|
||||
memset(&p, 0, sizeof p);
|
||||
memset(&b, 0, sizeof b);
|
||||
b.index = (uint32_t)i, b.type = type, b.memory = V4L2_MEMORY_MMAP, b.field = V4L2_FIELD_NONE;
|
||||
b.m.planes = &p, b.length = 1;
|
||||
b.timestamp.tv_sec = (long)(ts_us / 1000000), b.timestamp.tv_usec = (long)(ts_us % 1000000);
|
||||
p.bytesused = used;
|
||||
p.length = type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ? e->out_len[i] : e->cap_len[i];
|
||||
return sys_ioctl(e->fd, VIDIOC_QBUF, &b);
|
||||
}
|
||||
|
||||
static int enc_open(struct enc *e, const char *path, int w, int h, int fps, const struct opts *o)
|
||||
{
|
||||
e->fd = sys_open(path, O_RDWR | O_NONBLOCK | O_CLOEXEC);
|
||||
if (e->fd < 0) return fail(4, "open encoder", e->fd);
|
||||
if (!enc_caps_ok(v4l2_caps(e->fd))) return fail(4, "encoder capabilities", -EINVAL);
|
||||
|
||||
/* dev-encoder.rst "Initialization": the coded format first, then the raw format. */
|
||||
struct v4l2_format f;
|
||||
memset(&f, 0, sizeof f);
|
||||
f.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
|
||||
f.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_H264;
|
||||
f.fmt.pix_mp.width = (uint32_t)w, f.fmt.pix_mp.height = (uint32_t)h, f.fmt.pix_mp.num_planes = 1;
|
||||
int r = sys_ioctl(e->fd, VIDIOC_S_FMT, &f);
|
||||
if (r < 0) return fail(4, "encoder VIDIOC_S_FMT (H264)", r);
|
||||
if (f.fmt.pix_mp.pixelformat != V4L2_PIX_FMT_H264) {
|
||||
msg("encoder refused H264");
|
||||
return 4;
|
||||
}
|
||||
e->cap_size = f.fmt.pix_mp.plane_fmt[0].sizeimage;
|
||||
|
||||
memset(&f, 0, sizeof f);
|
||||
f.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
|
||||
f.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_NV12;
|
||||
f.fmt.pix_mp.width = (uint32_t)w, f.fmt.pix_mp.height = (uint32_t)h, f.fmt.pix_mp.num_planes = 1;
|
||||
f.fmt.pix_mp.field = V4L2_FIELD_NONE;
|
||||
f.fmt.pix_mp.colorspace = V4L2_COLORSPACE_REC709, f.fmt.pix_mp.ycbcr_enc = V4L2_YCBCR_ENC_709;
|
||||
f.fmt.pix_mp.quantization = V4L2_QUANTIZATION_LIM_RANGE, f.fmt.pix_mp.xfer_func = V4L2_XFER_FUNC_709;
|
||||
r = sys_ioctl(e->fd, VIDIOC_S_FMT, &f);
|
||||
if (r < 0) return fail(4, "encoder VIDIOC_S_FMT (NV12)", r);
|
||||
if (f.fmt.pix_mp.pixelformat != V4L2_PIX_FMT_NV12 || f.fmt.pix_mp.num_planes != 1)
|
||||
{
|
||||
msg("encoder refused single-plane NV12");
|
||||
return 4;
|
||||
}
|
||||
e->stride = (int)f.fmt.pix_mp.plane_fmt[0].bytesperline;
|
||||
e->hpad = (int)f.fmt.pix_mp.height;
|
||||
e->out_size = f.fmt.pix_mp.plane_fmt[0].sizeimage;
|
||||
if (e->stride < w || e->hpad < h || (uint64_t)e->stride * e->hpad * 3 / 2 > e->out_size)
|
||||
return fail(4, "encoder NV12 layout", -EINVAL);
|
||||
|
||||
/* Visible rectangle (the padded height is not picture). The selection API takes the single-planar type. */
|
||||
struct v4l2_selection sel;
|
||||
memset(&sel, 0, sizeof sel);
|
||||
sel.type = V4L2_BUF_TYPE_VIDEO_OUTPUT, sel.target = V4L2_SEL_TGT_CROP;
|
||||
sel.r.width = (uint32_t)w, sel.r.height = (uint32_t)h;
|
||||
r = sys_ioctl(e->fd, VIDIOC_S_SELECTION, &sel);
|
||||
if (r < 0) {
|
||||
sel.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
|
||||
sel.r.left = sel.r.top = 0, sel.r.width = (uint32_t)w, sel.r.height = (uint32_t)h;
|
||||
r = sys_ioctl(e->fd, VIDIOC_S_SELECTION, &sel);
|
||||
}
|
||||
if (r < 0) {
|
||||
memset(&sel, 0, sizeof sel);
|
||||
sel.type = V4L2_BUF_TYPE_VIDEO_OUTPUT, sel.target = V4L2_SEL_TGT_CROP;
|
||||
int g = sys_ioctl(e->fd, VIDIOC_G_SELECTION, &sel);
|
||||
if (g < 0 || sel.r.left || sel.r.top || sel.r.width != (uint32_t)w || sel.r.height != (uint32_t)h)
|
||||
return fail(4, "encoder VIDIOC_S_SELECTION", r);
|
||||
msg_err("warning: VIDIOC_S_SELECTION (crop already right)", r);
|
||||
}
|
||||
|
||||
struct v4l2_streamparm parm;
|
||||
memset(&parm, 0, sizeof parm);
|
||||
parm.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
|
||||
parm.parm.output.timeperframe.numerator = 1, parm.parm.output.timeperframe.denominator = (uint32_t)fps;
|
||||
r = sys_ioctl(e->fd, VIDIOC_S_PARM, &parm);
|
||||
if (r < 0) msg_err("warning: VIDIOC_S_PARM", r);
|
||||
|
||||
set_ctrl(e->fd, V4L2_CID_MPEG_VIDEO_H264_PROFILE, V4L2_MPEG_VIDEO_H264_PROFILE_HIGH, "H264_PROFILE", 0);
|
||||
/* --peak above the bitrate = VBR up to that peak (head turns get the bits they need; CBR blurred them), else CBR */
|
||||
long peak = o->peak > o->bitrate ? o->peak : o->bitrate;
|
||||
set_ctrl(e->fd, V4L2_CID_MPEG_VIDEO_H264_LEVEL, pick_level(w, h, fps, peak), "H264_LEVEL", 0);
|
||||
set_ctrl(e->fd, V4L2_CID_MPEG_VIDEO_BITRATE_MODE,
|
||||
peak > o->bitrate ? V4L2_MPEG_VIDEO_BITRATE_MODE_VBR : V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, "BITRATE_MODE", 0);
|
||||
set_ctrl(e->fd, V4L2_CID_MPEG_VIDEO_BITRATE, (int32_t)o->bitrate, "BITRATE", 0);
|
||||
set_ctrl(e->fd, V4L2_CID_MPEG_VIDEO_BITRATE_PEAK, (int32_t)peak, "BITRATE_PEAK", 0);
|
||||
set_ctrl(e->fd, V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE, 1, "FRAME_RC_ENABLE", 0);
|
||||
set_ctrl(e->fd, V4L2_CID_MPEG_VIDEO_B_FRAMES, 0, "B_FRAMES", 0);
|
||||
set_ctrl(e->fd, V4L2_CID_MPEG_VIDEO_GOP_SIZE, (int32_t)(fps * o->gop_seconds), "GOP_SIZE", 0);
|
||||
set_ctrl(e->fd, V4L2_CID_MPEG_VIDEO_HEADER_MODE, V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME, "HEADER_MODE", 0);
|
||||
set_ctrl(e->fd, V4L2_CID_MPEG_VIDEO_PREPEND_SPSPPS_TO_IDR, 1, "PREPEND_SPSPPS_TO_IDR", 0);
|
||||
set_ctrl(e->fd, V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE, V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED, "FRAME_SKIP_MODE", 0);
|
||||
|
||||
for (int q = 0; q < 2; q++) {
|
||||
uint32_t type = q ? V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
|
||||
struct v4l2_requestbuffers rb;
|
||||
memset(&rb, 0, sizeof rb);
|
||||
rb.count = ENC_BUFS, rb.type = type, rb.memory = V4L2_MEMORY_MMAP;
|
||||
r = sys_ioctl(e->fd, VIDIOC_REQBUFS, &rb);
|
||||
if (r < 0 || rb.count < ENC_BUFS) return fail(4, "encoder VIDIOC_REQBUFS", r < 0 ? r : -ENOMEM);
|
||||
for (int i = 0; i < ENC_BUFS; i++) {
|
||||
struct v4l2_plane p;
|
||||
struct v4l2_buffer b;
|
||||
memset(&p, 0, sizeof p);
|
||||
memset(&b, 0, sizeof b);
|
||||
b.index = (uint32_t)i, b.type = type, b.memory = V4L2_MEMORY_MMAP, b.m.planes = &p, b.length = 1;
|
||||
r = sys_ioctl(e->fd, VIDIOC_QUERYBUF, &b);
|
||||
if (r < 0) return fail(4, "encoder VIDIOC_QUERYBUF", r);
|
||||
uint8_t *m = sys_mmap(0, p.length, q ? PROT_READ : PROT_READ | PROT_WRITE, MAP_SHARED, e->fd, p.m.mem_offset);
|
||||
if (mmap_failed(m)) return fail(4, "encoder mmap", (long)m);
|
||||
if (q) {
|
||||
e->cap_mem[i] = m, e->cap_len[i] = p.length;
|
||||
} else {
|
||||
if (p.length < e->out_size) return fail(4, "encoder OUTPUT buffer size", -EINVAL);
|
||||
e->out_mem[i] = m, e->out_len[i] = p.length, e->out_free[i] = 1;
|
||||
/* Black, including the padding rows the encoder may read. */
|
||||
memset(m, 16, (size_t)e->stride * e->hpad);
|
||||
memset(m + (size_t)e->stride * e->hpad, 128, (size_t)e->stride * e->hpad / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- streaming */
|
||||
|
||||
/* Counters since the start; the timing part (per stats window, reset after each line) says where a slow loop's time
|
||||
* goes: converting pictures, writing coded frames to stdout (ffmpeg not draining the pipe), or waiting for the
|
||||
* encoder to free an OUTPUT buffer. */
|
||||
struct stats {
|
||||
long frames, repeats, late, skipped, errors;
|
||||
uint64_t bytes;
|
||||
int64_t conv_ns, conv_max, write_ns, write_max;
|
||||
long convs, writes, nobuf;
|
||||
};
|
||||
|
||||
/* Dequeue finished OUTPUT buffers (free again) and coded CAPTURE buffers (written to stdout, re-queued).
|
||||
* Returns 1 when the encoder signalled the last buffer, -1 when stdout is gone, else 0. */
|
||||
static int enc_reap(struct enc *e, struct stats *st)
|
||||
{
|
||||
for (;;) {
|
||||
struct v4l2_plane p;
|
||||
struct v4l2_buffer b;
|
||||
memset(&p, 0, sizeof p);
|
||||
memset(&b, 0, sizeof b);
|
||||
b.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, b.memory = V4L2_MEMORY_MMAP, b.m.planes = &p, b.length = 1;
|
||||
if (sys_ioctl(e->fd, VIDIOC_DQBUF, &b) < 0) break;
|
||||
if (b.index < ENC_BUFS) e->out_free[b.index] = 1;
|
||||
}
|
||||
for (;;) {
|
||||
struct v4l2_plane p;
|
||||
struct v4l2_buffer b;
|
||||
memset(&p, 0, sizeof p);
|
||||
memset(&b, 0, sizeof b);
|
||||
b.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, b.memory = V4L2_MEMORY_MMAP, b.m.planes = &p, b.length = 1;
|
||||
int r = sys_ioctl(e->fd, VIDIOC_DQBUF, &b);
|
||||
if (r == -EPIPE) return 1; /* the last buffer was already dequeued (dev-encoder.rst "Drain") */
|
||||
if (r < 0 || b.index >= ENC_BUFS) return 0;
|
||||
int last = (b.flags & V4L2_BUF_FLAG_LAST) != 0;
|
||||
if (b.flags & V4L2_BUF_FLAG_ERROR) {
|
||||
st->errors++;
|
||||
} else if (p.bytesused > p.data_offset && p.bytesused <= e->cap_len[b.index]) {
|
||||
uint32_t n = p.bytesused - p.data_offset;
|
||||
int64_t tw = now_ns();
|
||||
if (out_all(e->cap_mem[b.index] + p.data_offset, n) < 0) return -1;
|
||||
tw = now_ns() - tw;
|
||||
st->write_ns += tw, st->writes++;
|
||||
if (tw > st->write_max) st->write_max = tw;
|
||||
st->bytes += n;
|
||||
}
|
||||
if (last) return 1;
|
||||
enc_queue_buf(e, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, (int)b.index, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void drain_and_close(struct enc *e, struct src *s, struct stats *st)
|
||||
{
|
||||
struct v4l2_encoder_cmd cmd;
|
||||
memset(&cmd, 0, sizeof cmd);
|
||||
cmd.cmd = V4L2_ENC_CMD_STOP;
|
||||
if (sys_ioctl(e->fd, VIDIOC_ENCODER_CMD, &cmd) == 0) {
|
||||
int64_t end = now_ns() + 1000000000;
|
||||
for (;;) {
|
||||
if (enc_reap(e, st) != 0) break;
|
||||
int64_t left = end - now_ns();
|
||||
if (left <= 0) break;
|
||||
struct timespec ts = {left / 1000000000, left % 1000000000};
|
||||
struct pollfd_k f = {e->fd, POLLIN, 0};
|
||||
sys_ppoll(&f, 1, &ts);
|
||||
}
|
||||
}
|
||||
uint32_t t = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
|
||||
sys_ioctl(e->fd, VIDIOC_STREAMOFF, &t);
|
||||
t = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
|
||||
sys_ioctl(e->fd, VIDIOC_STREAMOFF, &t);
|
||||
t = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
sys_ioctl(s->fd, VIDIOC_STREAMOFF, &t);
|
||||
sys_close(e->fd);
|
||||
sys_close(s->fd);
|
||||
}
|
||||
|
||||
static void info_json(struct line *l, const char *enc, const char *srcp, const struct src *s, int ow, int oh,
|
||||
int refresh, int fps, long bitrate)
|
||||
{
|
||||
ls(l, "{\"encoder\":\""), ls(l, enc), ls(l, "\",\"source\":\""), ls(l, srcp);
|
||||
ls(l, "\",\"src\":["), ln(l, s->w), ls(l, ","), ln(l, s->h), ls(l, "],\"out\":["), ln(l, ow), ls(l, ","), ln(l, oh);
|
||||
ls(l, "],\"refresh\":"), ln(l, refresh), ls(l, ",\"fps\":"), ln(l, fps), ls(l, ",\"bitrate\":"), ln(l, bitrate);
|
||||
ls(l, "}\n");
|
||||
}
|
||||
|
||||
static void stats_line(struct stats *st, int64_t elapsed)
|
||||
{
|
||||
struct line l = {.n = 0};
|
||||
ls(&l, TAG "stats frames="), ln(&l, st->frames), ls(&l, " repeats="), ln(&l, st->repeats);
|
||||
ls(&l, " late="), ln(&l, st->late), ls(&l, " skipped="), ln(&l, st->skipped);
|
||||
ls(&l, " kbps="), ln(&l, elapsed > 0 ? (long)(st->bytes * 8 * 1000000 / (uint64_t)elapsed) : 0);
|
||||
if (st->errors) ls(&l, " errors="), ln(&l, st->errors);
|
||||
/* this window: average/max ms per conversion and per stdout write, slots that found no free OUTPUT buffer */
|
||||
ls(&l, " convert_ms="), lms(&l, st->convs ? st->conv_ns / st->convs : 0), ls(&l, "/"), lms(&l, st->conv_max);
|
||||
ls(&l, " write_ms="), lms(&l, st->writes ? st->write_ns / st->writes : 0), ls(&l, "/"), lms(&l, st->write_max);
|
||||
ls(&l, " no_buffer="), ln(&l, st->nobuf);
|
||||
ls(&l, "\n");
|
||||
write_all(2, l.b, (size_t)l.n);
|
||||
st->conv_ns = st->conv_max = st->write_ns = st->write_max = 0;
|
||||
st->convs = st->writes = st->nobuf = 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
struct opts o;
|
||||
if (!parse_args(argc, argv, &o)) {
|
||||
msg("usage: fp_venc [--height N] [--bitrate BPS] [--peak BPS] [--fps N] [--max-fps N] [--gop-seconds N] "
|
||||
"[--source PATH] [--encoder PATH] [--probe | --selftest]");
|
||||
return 2;
|
||||
}
|
||||
if (o.selftest) return selftest();
|
||||
const char *dis = getenv_(envp, "FP_VENC_DISABLE");
|
||||
if (dis && str_eq(dis, "1")) {
|
||||
msg("hardware encoder disabled (FP_VENC_DISABLE=1)");
|
||||
return 4;
|
||||
}
|
||||
|
||||
char src_path[256], enc_path[256];
|
||||
if (o.source) {
|
||||
if (str_len(o.source) >= sizeof src_path) return 2;
|
||||
memcpy(src_path, o.source, str_len(o.source) + 1);
|
||||
} else if (!find_source(src_path)) {
|
||||
msg("no SteamVR headset view device (/sys/class/video4linux/*/name == SteamVR)");
|
||||
return 3;
|
||||
}
|
||||
struct src s;
|
||||
int r = src_open(&s, src_path);
|
||||
if (r) return r;
|
||||
|
||||
if (o.encoder) {
|
||||
if (str_len(o.encoder) >= sizeof enc_path) return 2;
|
||||
memcpy(enc_path, o.encoder, str_len(o.encoder) + 1);
|
||||
} else if (!find_encoder(enc_path)) {
|
||||
msg("no V4L2 hardware encoder found");
|
||||
return 4;
|
||||
}
|
||||
|
||||
int ow, oh;
|
||||
fp_out_size(s.w, s.h, (int)o.height, &ow, &oh);
|
||||
int refresh = panel_refresh();
|
||||
int fps = (int)o.fps;
|
||||
if (!fps) {
|
||||
if (refresh > 0) {
|
||||
int d = (refresh + (int)o.max_fps - 1) / (int)o.max_fps;
|
||||
fps = (refresh + d / 2) / d;
|
||||
} else {
|
||||
fps = 30;
|
||||
}
|
||||
}
|
||||
|
||||
struct enc e;
|
||||
memset(&e, 0, sizeof e);
|
||||
r = enc_open(&e, enc_path, ow, oh, fps, &o);
|
||||
if (r) return r;
|
||||
|
||||
struct line info = {.n = 0};
|
||||
info_json(&info, enc_path, src_path, &s, ow, oh, refresh, fps, o.bitrate);
|
||||
if (o.probe) {
|
||||
write_all(1, info.b, (size_t)info.n);
|
||||
sys_close(e.fd);
|
||||
sys_close(s.fd);
|
||||
return 0;
|
||||
}
|
||||
struct line il = {.n = 0};
|
||||
ls(&il, TAG "info "), ls(&il, info.b);
|
||||
write_all(2, il.b, (size_t)il.n);
|
||||
|
||||
void *scratch = alloc(fp_scratch_size(s.w, s.h, ow, oh));
|
||||
if (!scratch) return fail(4, "scratch memory", -ENOMEM);
|
||||
|
||||
/* Ignore SIGPIPE: a closed stdout becomes EPIPE from write() and we stop quietly. */
|
||||
struct { void *handler; unsigned long flags; void *restorer; uint64_t mask; } sa = {(void *)1, 0, 0, 0};
|
||||
sys6(__NR_rt_sigaction, 13 /* SIGPIPE */, (long)&sa, 0, 8, 0, 0);
|
||||
|
||||
for (int i = 0; i < ENC_BUFS; i++)
|
||||
if ((r = enc_queue_buf(&e, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, i, 0, 0)) < 0) return fail(4, "encoder QBUF", r);
|
||||
uint32_t t = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
|
||||
if ((r = sys_ioctl(e.fd, VIDIOC_STREAMON, &t)) < 0) return fail(4, "encoder STREAMON (OUTPUT)", r);
|
||||
t = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
|
||||
if ((r = sys_ioctl(e.fd, VIDIOC_STREAMON, &t)) < 0) return fail(4, "encoder STREAMON (CAPTURE)", r);
|
||||
t = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
if ((r = sys_ioctl(s.fd, VIDIOC_STREAMON, &t)) < 0) return fail(3, "source STREAMON", r);
|
||||
|
||||
struct stats st = {0};
|
||||
const int64_t t0 = now_ns(), period = 1000000000 / fps;
|
||||
int64_t next_stats = t0 + 10000000000LL, quiet_src = 0, quiet_enc = 0;
|
||||
long slot = 0; /* next slot to submit; due at t0 + slot * 1e9 / fps */
|
||||
long pic = 0; /* current picture: 0 = black (no source frame yet), +1 per new source frame */
|
||||
for (int i = 0; i < ENC_BUFS; i++) e.out_pic[i] = -1;
|
||||
int want_key = 0, stdin_open = 1, sent_any = 0, rc = 0;
|
||||
|
||||
for (;;) {
|
||||
int64_t now = now_ns();
|
||||
long due_upto = (long)((now - t0) * fps / 1000000000); /* last slot whose time has come */
|
||||
if (due_upto - slot + 1 > fps) { /* > 1 s behind (e.g. SIGSTOP): don't replay it all */
|
||||
say("fell behind; skipping slots: ", 0, due_upto - slot, 1);
|
||||
st.skipped += due_upto - slot;
|
||||
slot = due_upto;
|
||||
}
|
||||
/* Submit every due slot for which an OUTPUT buffer is free. */
|
||||
while (slot <= due_upto) {
|
||||
int i = 0;
|
||||
while (i < ENC_BUFS && !e.out_free[i]) i++;
|
||||
if (i == ENC_BUFS) {
|
||||
st.nobuf++;
|
||||
break;
|
||||
}
|
||||
uint8_t *m = e.out_mem[i];
|
||||
if (s.held >= 0 && s.fresh) pic++;
|
||||
if (e.out_pic[i] != pic) {
|
||||
if (s.held >= 0) {
|
||||
int64_t tc = now_ns();
|
||||
fp_convert(s.mem[s.held], s.w, s.h, s.stride, m, e.stride, m + (size_t)e.stride * e.hpad,
|
||||
e.stride, ow, oh, scratch);
|
||||
tc = now_ns() - tc;
|
||||
st.conv_ns += tc, st.convs++;
|
||||
if (tc > st.conv_max) st.conv_max = tc;
|
||||
} else { /* no source frame yet: black */
|
||||
memset(m, 16, (size_t)e.stride * oh);
|
||||
memset(m + (size_t)e.stride * e.hpad, 128, (size_t)e.stride * oh / 2);
|
||||
}
|
||||
e.out_pic[i] = pic;
|
||||
}
|
||||
if (!s.fresh && sent_any) st.repeats++;
|
||||
s.fresh = 0;
|
||||
if (want_key) set_ctrl(e.fd, V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME, 1, "FORCE_KEY_FRAME", 0), want_key = 0;
|
||||
if ((r = enc_queue_buf(&e, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, i, e.out_size, slot * 1000000 / fps)) < 0) {
|
||||
rc = fail(1, "encoder QBUF (OUTPUT)", r);
|
||||
goto stop;
|
||||
}
|
||||
e.out_free[i] = 0;
|
||||
if (now_ns() >= t0 + (slot + 1) * 1000000000 / fps) st.late++;
|
||||
st.frames++, slot++, sent_any = 1;
|
||||
}
|
||||
if (now >= next_stats) {
|
||||
stats_line(&st, now - t0);
|
||||
next_stats += 10000000000LL;
|
||||
}
|
||||
|
||||
/* Wait for the next slot, a source frame, encoder progress or a stdin command. If a slot is already due we
|
||||
* are waiting for a free OUTPUT buffer: the encoder fd's POLLOUT wakes us. */
|
||||
int64_t wait = slot <= due_upto ? period : t0 + slot * 1000000000 / fps - now;
|
||||
if (wait < 0) wait = 0;
|
||||
struct pollfd_k f[3];
|
||||
int nf = 0, isrc = -1, ienc = -1, iin = -1;
|
||||
if (now >= quiet_src) isrc = nf, f[nf++] = (struct pollfd_k){s.fd, POLLIN, 0};
|
||||
if (now >= quiet_enc) ienc = nf, f[nf++] = (struct pollfd_k){e.fd, POLLIN | POLLOUT, 0};
|
||||
if (stdin_open) iin = nf, f[nf++] = (struct pollfd_k){0, POLLIN, 0};
|
||||
/* An fd left out after an error comes back when its quiet time ends. */
|
||||
if (now < quiet_src && quiet_src - now < wait) wait = quiet_src - now;
|
||||
if (now < quiet_enc && quiet_enc - now < wait) wait = quiet_enc - now;
|
||||
struct timespec ts = {wait / 1000000000, wait % 1000000000};
|
||||
int n = sys_ppoll(f, (unsigned)nf, &ts);
|
||||
if (n < 0 && n != -EINTR) {
|
||||
rc = fail(1, "ppoll", n);
|
||||
goto stop;
|
||||
}
|
||||
if (n <= 0) continue;
|
||||
if (isrc >= 0 && f[isrc].revents) {
|
||||
int had = s.held;
|
||||
int was_fresh = s.fresh;
|
||||
src_drain(&s);
|
||||
/* POLLERR without a frame (e.g. the writer is gone): don't spin on it, look again in 100 ms. */
|
||||
if ((f[isrc].revents & (POLLERR | POLLHUP | POLLNVAL)) && s.held == had && s.fresh == was_fresh)
|
||||
quiet_src = now + 100000000;
|
||||
}
|
||||
if (ienc >= 0 && f[ienc].revents) {
|
||||
int k = enc_reap(&e, &st);
|
||||
if (k < 0) goto stop_quiet;
|
||||
if (k > 0) {
|
||||
rc = fail(1, "encoder stopped unexpectedly", -EIO);
|
||||
goto stop;
|
||||
}
|
||||
if (f[ienc].revents & (POLLERR | POLLNVAL)) quiet_enc = now + 2000000;
|
||||
}
|
||||
if (iin >= 0 && f[iin].revents) {
|
||||
if (f[iin].revents & POLLNVAL) {
|
||||
stdin_open = 0;
|
||||
} else {
|
||||
char cmd[64];
|
||||
long got = sys_read(0, cmd, sizeof cmd);
|
||||
if (got == 0) goto stop; /* EOF: the PC side closed the channel */
|
||||
for (long k = 0; k < got; k++) {
|
||||
if (cmd[k] == 'k') want_key = 1;
|
||||
if (cmd[k] == 'q') goto stop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stop:
|
||||
drain_and_close(&e, &s, &st);
|
||||
stats_line(&st, now_ns() - t0);
|
||||
return rc;
|
||||
stop_quiet: /* stdout is gone: nothing left to drain into */
|
||||
{
|
||||
uint32_t ty = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
|
||||
sys_ioctl(e.fd, VIDIOC_STREAMOFF, &ty);
|
||||
ty = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
|
||||
sys_ioctl(e.fd, VIDIOC_STREAMOFF, &ty);
|
||||
sys_close(e.fd);
|
||||
sys_close(s.fd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/* Minimal stand-in for libc's <sys/time.h>: linux/videodev2.h includes it for struct timeval (v4l2_buffer) and
|
||||
* struct timespec (v4l2_event). There is no libc at build time (fp_venc is freestanding), so the two structs are
|
||||
* declared here with the aarch64 Linux layout (two 64-bit longs each). */
|
||||
#ifndef FP_VENC_SYS_TIME_H
|
||||
#define FP_VENC_SYS_TIME_H
|
||||
|
||||
struct timeval {
|
||||
long tv_sec;
|
||||
long tv_usec;
|
||||
};
|
||||
|
||||
struct timespec {
|
||||
long tv_sec;
|
||||
long tv_nsec;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,131 @@
|
||||
/* Process entry and the few libc pieces fp_venc needs (see sys.h). */
|
||||
#include "sys.h"
|
||||
|
||||
/* The kernel starts us with sp -> argc, argv[0..argc-1], NULL, envp..., NULL (16-byte aligned). Clear the frame
|
||||
* pointer and link register so backtraces end here, then hand sp to C. */
|
||||
__asm__(".text\n"
|
||||
".global _start\n"
|
||||
".type _start,%function\n"
|
||||
"_start:\n"
|
||||
" mov x29, #0\n"
|
||||
" mov x30, #0\n"
|
||||
" mov x0, sp\n"
|
||||
" bl start_c\n"
|
||||
" brk #0\n");
|
||||
|
||||
__attribute__((noreturn, used)) void start_c(long *sp)
|
||||
{
|
||||
int argc = (int)sp[0];
|
||||
char **argv = (char **)(sp + 1);
|
||||
char **envp = argv + argc + 1;
|
||||
sys_exit(main(argc, argv, envp));
|
||||
}
|
||||
|
||||
/* The compiler may emit calls to these for struct copies/zeroing. Byte loops are enough: the hot paths (picture
|
||||
* conversion) never use them. -ffreestanding/-fno-builtin keep clang from turning these loops back into calls. */
|
||||
void *memcpy(void *d, const void *s, size_t n)
|
||||
{
|
||||
unsigned char *dp = d;
|
||||
const unsigned char *sp = s;
|
||||
while (n--) *dp++ = *sp++;
|
||||
return d;
|
||||
}
|
||||
|
||||
void *memset(void *d, int c, size_t n)
|
||||
{
|
||||
unsigned char *dp = d;
|
||||
while (n--) *dp++ = (unsigned char)c;
|
||||
return d;
|
||||
}
|
||||
|
||||
void *memmove(void *d, const void *s, size_t n)
|
||||
{
|
||||
unsigned char *dp = d;
|
||||
const unsigned char *sp = s;
|
||||
if (dp < sp) {
|
||||
while (n--) *dp++ = *sp++;
|
||||
} else {
|
||||
while (n--) dp[n] = sp[n];
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
size_t str_len(const char *s)
|
||||
{
|
||||
size_t n = 0;
|
||||
while (s[n]) n++;
|
||||
return n;
|
||||
}
|
||||
|
||||
int str_eq(const char *a, const char *b)
|
||||
{
|
||||
while (*a && *a == *b) a++, b++;
|
||||
return *a == *b;
|
||||
}
|
||||
|
||||
int str_contains(const char *hay, const char *needle)
|
||||
{
|
||||
size_t n = str_len(needle);
|
||||
for (; *hay; hay++) {
|
||||
size_t i = 0;
|
||||
while (i < n && hay[i] == needle[i]) i++;
|
||||
if (i == n) return 1;
|
||||
}
|
||||
return n == 0;
|
||||
}
|
||||
|
||||
int parse_uint(const char *s, long *out)
|
||||
{
|
||||
long v = 0;
|
||||
if (!s || !*s) return 0;
|
||||
for (; *s; s++) {
|
||||
if (*s < '0' || *s > '9') return 0;
|
||||
v = v * 10 + (*s - '0');
|
||||
if (v > 0x7fffffffL) return 0;
|
||||
}
|
||||
*out = v;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int64_t now_ns(void)
|
||||
{
|
||||
struct timespec ts = {0, 0};
|
||||
sys_clock_gettime(1 /* CLOCK_MONOTONIC */, &ts);
|
||||
return (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec;
|
||||
}
|
||||
|
||||
void write_all(int fd, const void *b, size_t n)
|
||||
{
|
||||
const char *p = b;
|
||||
while (n) {
|
||||
long r = sys_write(fd, p, n);
|
||||
if (r == -EINTR || r == -EAGAIN) continue;
|
||||
if (r <= 0) return;
|
||||
p += r;
|
||||
n -= (size_t)r;
|
||||
}
|
||||
}
|
||||
|
||||
void ls(struct line *l, const char *s)
|
||||
{
|
||||
while (*s && l->n < (int)sizeof(l->b) - 1) l->b[l->n++] = *s++;
|
||||
}
|
||||
|
||||
void ln(struct line *l, long v)
|
||||
{
|
||||
char t[24];
|
||||
int i = 0;
|
||||
unsigned long u = v < 0 ? 0UL - (unsigned long)v : (unsigned long)v;
|
||||
if (v < 0) ls(l, "-");
|
||||
do t[i++] = (char)('0' + u % 10); while ((u /= 10) && i < 23);
|
||||
while (i && l->n < (int)sizeof(l->b) - 1) l->b[l->n++] = t[--i];
|
||||
}
|
||||
|
||||
void lms(struct line *l, int64_t ns)
|
||||
{
|
||||
int64_t us = ns / 1000;
|
||||
ln(l, (long)(us / 1000));
|
||||
ls(l, ".");
|
||||
ls(l, us % 1000 < 100 ? (us % 1000 < 10 ? "00" : "0") : "");
|
||||
ln(l, (long)(us % 1000));
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/* fp_venc's whole "libc": raw aarch64 Linux syscalls plus a few helpers. The program is fully static and
|
||||
* freestanding (no libc exists at build time), so everything it needs from the kernel goes through svc #0 here. */
|
||||
#ifndef FP_VENC_SYS_H
|
||||
#define FP_VENC_SYS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/time.h> /* our stub: struct timespec */
|
||||
#include <asm/unistd.h> /* syscall numbers (asm-generic table) */
|
||||
#include <asm/errno.h>
|
||||
|
||||
/* open flags (asm-generic values, used by aarch64). Bionic's copy of linux/fcntl.h pulls in libc's bits/ headers, so
|
||||
* the few we need are spelled out here. */
|
||||
#define O_RDONLY 00
|
||||
#define O_RDWR 02
|
||||
#define O_NONBLOCK 04000
|
||||
#define O_CLOEXEC 02000000
|
||||
#define AT_FDCWD (-100)
|
||||
#include <linux/mman.h> /* PROT_*, MAP_* */
|
||||
#include <linux/poll.h> /* POLL* */
|
||||
|
||||
/* Syscalls return the kernel's value: >= 0 success, -errno failure. */
|
||||
static inline long sys6(long n, long a, long b, long c, long d, long e, long f)
|
||||
{
|
||||
register long x8 __asm__("x8") = n;
|
||||
register long x0 __asm__("x0") = a;
|
||||
register long x1 __asm__("x1") = b;
|
||||
register long x2 __asm__("x2") = c;
|
||||
register long x3 __asm__("x3") = d;
|
||||
register long x4 __asm__("x4") = e;
|
||||
register long x5 __asm__("x5") = f;
|
||||
__asm__ volatile("svc #0" : "+r"(x0) : "r"(x8), "r"(x1), "r"(x2), "r"(x3), "r"(x4), "r"(x5) : "memory", "cc");
|
||||
return x0;
|
||||
}
|
||||
|
||||
struct pollfd_k { int fd; short events; short revents; }; /* struct pollfd (not in the UAPI headers) */
|
||||
|
||||
static inline long sys_read(int fd, void *b, size_t n) { return sys6(__NR_read, fd, (long)b, (long)n, 0, 0, 0); }
|
||||
static inline long sys_write(int fd, const void *b, size_t n) { return sys6(__NR_write, fd, (long)b, (long)n, 0, 0, 0); }
|
||||
static inline int sys_open(const char *p, int flags) { return (int)sys6(__NR_openat, AT_FDCWD, (long)p, flags, 0, 0, 0); }
|
||||
static inline int sys_close(int fd) { return (int)sys6(__NR_close, fd, 0, 0, 0, 0, 0); }
|
||||
static inline int sys_ioctl(int fd, unsigned long req, void *arg) { return (int)sys6(__NR_ioctl, fd, (long)req, (long)arg, 0, 0, 0); }
|
||||
static inline long sys_readlink(const char *p, char *b, size_t n) { return sys6(__NR_readlinkat, AT_FDCWD, (long)p, (long)b, (long)n, 0, 0); }
|
||||
static inline void *sys_mmap(void *a, size_t len, int prot, int flags, int fd, long off)
|
||||
{
|
||||
return (void *)sys6(__NR_mmap, (long)a, (long)len, prot, flags, fd, off);
|
||||
}
|
||||
static inline int sys_munmap(void *a, size_t len) { return (int)sys6(__NR_munmap, (long)a, (long)len, 0, 0, 0, 0); }
|
||||
static inline int sys_ppoll(struct pollfd_k *f, unsigned n, const struct timespec *ts)
|
||||
{
|
||||
return (int)sys6(__NR_ppoll, (long)f, n, (long)ts, 0, 8, 0);
|
||||
}
|
||||
static inline int sys_clock_gettime(int clk, struct timespec *ts) { return (int)sys6(__NR_clock_gettime, clk, (long)ts, 0, 0, 0, 0); }
|
||||
__attribute__((noreturn)) static inline void sys_exit(int code)
|
||||
{
|
||||
for (;;) sys6(__NR_exit_group, code, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* mmap returns -errno in the pointer on failure. */
|
||||
static inline int mmap_failed(void *p) { return (unsigned long)p > (unsigned long)-4096; }
|
||||
|
||||
/* Helpers (sys.c). */
|
||||
void *memcpy(void *d, const void *s, size_t n);
|
||||
void *memset(void *d, int c, size_t n);
|
||||
void *memmove(void *d, const void *s, size_t n);
|
||||
size_t str_len(const char *s);
|
||||
int str_eq(const char *a, const char *b);
|
||||
int str_contains(const char *hay, const char *needle);
|
||||
int parse_uint(const char *s, long *out); /* plain decimal, 0..2^31-1; 1 = ok */
|
||||
int64_t now_ns(void); /* CLOCK_MONOTONIC */
|
||||
void write_all(int fd, const void *b, size_t n); /* best effort (stderr) */
|
||||
|
||||
/* A small line builder for stderr/JSON output: no printf here. */
|
||||
struct line { char b[600]; int n; };
|
||||
void ls(struct line *l, const char *s);
|
||||
void ln(struct line *l, long v);
|
||||
void lms(struct line *l, int64_t ns); /* nanoseconds as "<ms>.<3 digits>" */
|
||||
|
||||
int main(int argc, char **argv, char **envp);
|
||||
|
||||
#endif
|
||||
@@ -11,8 +11,10 @@
|
||||
// Haptics (GitHub #9, found by Klownicle in Lucky's Tale): overport's dispatcher converts an
|
||||
// XrHapticAmplitudeEnvelopeVibrationFB with its nanosecond duration taken as seconds, so one vibration allocates an
|
||||
// enormous sample buffer and the Frame runs out of memory and freezes. The shim hands OVRPlugin its own
|
||||
// xrApplyHapticFeedback, which turns such an envelope into a plain XrHapticVibration (same duration, its peak
|
||||
// amplitude) before the dispatcher sees it. Everything else passes through unchanged.
|
||||
// xrApplyHapticFeedback, which turns such an envelope into a plain XrHapticVibration (same duration, its RMS
|
||||
// amplitude) before the dispatcher sees it; PCM vibrations (XrHapticPcmVibrationFB) are converted the same way.
|
||||
// Everything else passes through unchanged.
|
||||
// Upstream: ovrport/app#73; tracked in FramePort GitHub #74.
|
||||
#include <openxr/openxr.h>
|
||||
#include <android/log.h>
|
||||
#include <dlfcn.h>
|
||||
@@ -68,6 +70,23 @@ static XRAPI_ATTR XrResult XRAPI_CALL apply_haptic_feedback(XrSession session, c
|
||||
"vibration %.2f", env->amplitudeCount, (long long)env->duration, plain.amplitude);
|
||||
return overport_haptics(session, info, (const XrHapticBaseHeader *)&plain);
|
||||
}
|
||||
if (feedback && feedback->type == XR_TYPE_HAPTIC_PCM_VIBRATION_FB) {
|
||||
// the other buffered form goes through the same conversion: a plain vibration as long as the samples (all
|
||||
// consumed), with their RMS
|
||||
const XrHapticPcmVibrationFB *pcm = (const XrHapticPcmVibrationFB *)feedback;
|
||||
double sum = 0.0;
|
||||
for (uint32_t i = 0; pcm->buffer && i < pcm->bufferSize; ++i)
|
||||
sum += (double)pcm->buffer[i] * pcm->buffer[i];
|
||||
float rms = pcm->bufferSize ? (float)sqrt(sum / pcm->bufferSize) : 0.0f;
|
||||
XrDuration duration = pcm->sampleRate > 0 ? (XrDuration)(pcm->bufferSize / pcm->sampleRate * 1e9) : 0;
|
||||
XrHapticVibration plain = {XR_TYPE_HAPTIC_VIBRATION, NULL, duration > 0 ? duration : XR_MIN_HAPTIC_DURATION,
|
||||
XR_FREQUENCY_UNSPECIFIED, rms > 1.0f ? 1.0f : rms};
|
||||
if (pcm->samplesConsumed) *pcm->samplesConsumed = pcm->bufferSize;
|
||||
if (haptics_logged++ < 3)
|
||||
__android_log_print(ANDROID_LOG_INFO, TAG, "extension shim: haptic PCM (%u samples at %.0f Hz) -> "
|
||||
"vibration %.2f", pcm->bufferSize, pcm->sampleRate, plain.amplitude);
|
||||
return overport_haptics(session, info, (const XrHapticBaseHeader *)&plain);
|
||||
}
|
||||
return overport_haptics(session, info, feedback);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,10 @@ dependencies = [
|
||||
"flet>=1.0",
|
||||
"flet-desktop>=1.0",
|
||||
"flet-dropzone>=0.4.0", # drag-and-drop uploads in the Files tab (packaged app only; Apache-2.0)
|
||||
# the live view inside the window (media_kit/libmpv; Apache-2.0). Not on Linux: there the plugin links libmpv.so.1
|
||||
# and a bundle with it wouldn't start without that library (Linux plays in an mpv window or the browser instead).
|
||||
# flet-video pins flet exactly: keep it at the installed flet's version.
|
||||
"flet-video==1.0.2; sys_platform != 'linux'",
|
||||
"paramiko>=3.4",
|
||||
"zeroconf>=0.132",
|
||||
"psutil>=5.9",
|
||||
|
||||
@@ -35,7 +35,7 @@ def render() -> str:
|
||||
rows.append(f"| {e.title} | {platform} | {STATUS[e.status]} | {note} |")
|
||||
return ("# Tested games\n\n"
|
||||
"Games tested on the Steam Frame with FramePort's recipes. Games not listed here may work too: FramePort "
|
||||
"suggests patches for them, and a working config can be shared from the app (**Share working config…**).\n"
|
||||
"suggests patches for them, and a working recipe can be shared from the app (**Share working recipe…**).\n"
|
||||
f"Tested a game? [Share a working config]({SHARE}) or [report a problem]({REPORT}) (in the app: the game's "
|
||||
"**…** menu does both and fills in the details).\n"
|
||||
"Generated from [catalog/games](../catalog/games) by `scripts/compat_list.py`.\n\n"
|
||||
|
||||
@@ -69,6 +69,9 @@ def main() -> int:
|
||||
"--add-data", f"{DATA}{sep}frameport/_data",
|
||||
# translations (data files PyInstaller doesn't pick up from the imports)
|
||||
"--add-data", f"{ROOT / 'src/frameport/locales'}{sep}frameport/locales",
|
||||
# the logo and the GUI's own glyphs (SVG)
|
||||
"--add-data", f"{ROOT / 'src/frameport/ui/icons'}{sep}frameport/ui/icons",
|
||||
"--icon", str(ROOT / "src/assets/icon.png"),
|
||||
"--distpath", str(ROOT / "dist"), "--yes"]
|
||||
if TARGET == "linux":
|
||||
cmd.append("--onedir") # a folder: the bundle check sees the agent source, the archive the app
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build the demo library (docs/showcase/demo-library.yaml + demo-analyses.json) into a fresh, isolated data dir for
|
||||
docs screenshots and the demo tour. No personal data: the games are catalog games, their analyses were exported
|
||||
without paths, local paths are made up (D:/Games/…), and the art + store details come from the same public sources
|
||||
the app uses (Meta/OculusDB, Steam), cached in ~/.cache/frameport-showcase so later builds (and CI) are offline and
|
||||
identical. A game whose art can't be fetched keeps FramePort's own placeholder art; the build never fails over art.
|
||||
|
||||
python scripts/showcase/demo_home.py build <dir> [--offline] [--refresh]
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
import zlib
|
||||
from pathlib import Path
|
||||
|
||||
REPO = Path(__file__).resolve().parents[2]
|
||||
FIXTURE = REPO / "docs" / "showcase" / "demo-library.yaml"
|
||||
ANALYSES = REPO / "docs" / "showcase" / "demo-analyses.json"
|
||||
CACHE = Path(os.environ.get("FRAMEPORT_SHOWCASE_CACHE") or Path.home() / ".cache" / "frameport-showcase")
|
||||
DAY = 86400.0
|
||||
FETCHED = 1790000000.0 # the "fetched" time stored with cached details (fixed: builds are identical)
|
||||
|
||||
|
||||
def real_data_dir() -> Path:
|
||||
"""The user's own FramePort data dir (never written by the showcase; not even created by asking)."""
|
||||
from frameport.core import paths
|
||||
|
||||
saved = os.environ.pop("FRAMEPORT_HOME", None)
|
||||
removed = paths._removed.is_set()
|
||||
paths._removed.set() # (user_data_dir creates the folder unless FramePort is being removed)
|
||||
try:
|
||||
return paths.user_data_dir().resolve()
|
||||
finally:
|
||||
if not removed:
|
||||
paths._removed.clear()
|
||||
if saved is not None:
|
||||
os.environ["FRAMEPORT_HOME"] = saved
|
||||
|
||||
|
||||
def load_fixture(path: Path = FIXTURE) -> dict:
|
||||
import yaml
|
||||
|
||||
data = yaml.safe_load(path.read_text())
|
||||
games = data.get("games") or []
|
||||
seen = set()
|
||||
for g in games:
|
||||
if not isinstance(g, dict) or not g.get("package"):
|
||||
raise ValueError(f"{path.name}: every game needs a package: {g!r}")
|
||||
if g["package"] in seen:
|
||||
raise ValueError(f"{path.name}: {g['package']} is listed twice")
|
||||
seen.add(g["package"])
|
||||
unknown = set(g) - {"package", "frame", "played", "added", "tested", "tags", "title", "art"}
|
||||
if unknown:
|
||||
raise ValueError(f"{path.name}: {g['package']}: unknown field(s) {sorted(unknown)}")
|
||||
if g.get("frame") not in (None, "internal", "sd", "outdated"):
|
||||
raise ValueError(f"{path.name}: {g['package']}: frame must be internal, sd or outdated")
|
||||
if (data.get("frame") or {}).get("running") not in (None, *seen):
|
||||
raise ValueError(f"{path.name}: frame.running isn't one of the games")
|
||||
return data
|
||||
|
||||
|
||||
def fake_sha(package: str, salt: str = "") -> str:
|
||||
import hashlib
|
||||
|
||||
return hashlib.sha1(f"showcase:{package}:{salt}".encode()).hexdigest()
|
||||
|
||||
|
||||
def steam_appid(package: str, title: str) -> int:
|
||||
return (zlib.crc32(f'"/home/steamos/Applications/quest-frame/{package}/launch.sh"{title}'.encode())
|
||||
| 0x80000000) & 0xFFFFFFFF
|
||||
|
||||
|
||||
def _entry(spec: dict, tech: dict, now: float) -> dict:
|
||||
"""The library fields of one demo game, made the way pipeline.add_game / add_rift_game make them."""
|
||||
from frameport.analysis.detect import ANALYSIS_VERSION
|
||||
from frameport.core import library
|
||||
from frameport.patches.base import recipe_fingerprint
|
||||
from frameport.recommend import catalog, engine
|
||||
|
||||
pkg = spec["package"]
|
||||
a = library.analysis_from_dict(dict(tech["analysis"], package=pkg))
|
||||
rift = pkg.startswith("rift.")
|
||||
if not rift:
|
||||
a.extra["analysis_version"] = ANALYSIS_VERSION
|
||||
recipe = engine.suggest(a)
|
||||
title = spec.get("title") or recipe.title or a.label or pkg
|
||||
rdict = library.recipe_to_dict(recipe)
|
||||
fields = dict(title=title, name=title, data_bytes=tech.get("data_bytes") or 0, analysis=a.to_dict(),
|
||||
recipe=rdict, suggested=rdict, status=recipe.status, added=now - DAY * spec.get("added", 30),
|
||||
build={"sha256": fake_sha(pkg), "ok": True, "recipe_fp": recipe_fingerprint(rdict),
|
||||
"applied": sorted(p for p in rdict.get("patches") or {} if "." in p)})
|
||||
if rift:
|
||||
folder = f"D:/Games/PC VR/{title}"
|
||||
exe = tech.get("exe_rel") or tech.get("exe") or "Game.exe"
|
||||
entry = catalog.lookup(pkg)
|
||||
fields.update(kind="rift", apk=None, game_dir=folder, exe=exe.split("/", 1)[-1] if "/" in exe else exe,
|
||||
exe_confirmed=True, origin="D:/Games/PC VR", quest_package=entry.quest_package if entry
|
||||
else None, art_source="oculusdb")
|
||||
fields["build"].update(kind="rift", revive="3.2.0")
|
||||
else:
|
||||
folder = f"D:/Games/Quest/{title}"
|
||||
fields.update(apk=f"{folder}/{pkg}.apk", data_dir=f"{folder}/{pkg}" if tech.get("data_bytes") else None,
|
||||
origin="D:/Games/Quest")
|
||||
if spec.get("tags"):
|
||||
fields["tags"] = list(spec["tags"])
|
||||
if spec.get("played") is not None:
|
||||
fields["last_played"] = now - DAY * spec["played"]
|
||||
installed = spec.get("frame") is not None
|
||||
if installed:
|
||||
t = now - DAY * (spec.get("played", 3) + 0.4)
|
||||
fields["installs"] = {"frame": {"result": {"ok": True, "appid": steam_appid(pkg, title)}, "time": t}}
|
||||
if spec.get("tested", installed):
|
||||
fields["last_test"] = {"state": "RUNNING", "verdict": "pass",
|
||||
"milestone": "Game window created" if rift else "Submitting frames",
|
||||
"fps": None if rift else 72.0, "findings": [], "suggestions": [],
|
||||
"time": now - DAY * (spec.get("played", 3) + 0.39), "target": "frame"}
|
||||
return fields
|
||||
|
||||
|
||||
def _art(pkg: str, refresh: bool, offline: bool, log, pick: bool = False) -> str:
|
||||
"""Art + store details for one game: from the showcase cache, else fetched (and cached). Returns its source."""
|
||||
from frameport import pipeline
|
||||
from frameport.artwork import fetch
|
||||
from frameport.core import library
|
||||
|
||||
cached = CACHE / "games" / (pkg + ("@pick" if pick else ""))
|
||||
dest = fetch.artwork_dir(pkg)
|
||||
if cached.is_dir() and not refresh:
|
||||
for f in cached.iterdir():
|
||||
if f.is_file() and f.name != "details.json":
|
||||
shutil.copy2(f, dest / f.name)
|
||||
details = cached / "details.json"
|
||||
if details.exists():
|
||||
library.upsert_game(pkg, details=json.loads(details.read_text()))
|
||||
return "cache"
|
||||
if offline:
|
||||
return "none"
|
||||
entry = library.game(pkg)
|
||||
try:
|
||||
if entry.get("kind") == "rift":
|
||||
pipeline._rift_art(entry)
|
||||
elif pick: # what a user does when the store's art is a placeholder: the picker's Meta (OculusDB) result
|
||||
from frameport.artwork import sources
|
||||
|
||||
choice = next((c for c in sources.search(entry.get("title") or pkg) if c.get("package") == pkg), None)
|
||||
if not (choice and sources.apply_choice(pkg, choice)):
|
||||
log(f" {pkg}: the picker had no Meta result, store art instead")
|
||||
fetch.fetch(pkg, None, refresh=True)
|
||||
else:
|
||||
fetch.fetch(pkg, None, refresh=True)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
log(f" {pkg}: no art ({exc})")
|
||||
d = pipeline.fetch_details(pkg)
|
||||
d["fetched"] = FETCHED
|
||||
library.upsert_game(pkg, details=d)
|
||||
have = [f for f in dest.iterdir() if f.is_file() and not f.name.startswith("t_")] # (not thumbnails)
|
||||
if not have:
|
||||
return "none"
|
||||
if cached.exists():
|
||||
shutil.rmtree(cached)
|
||||
cached.mkdir(parents=True)
|
||||
for f in have:
|
||||
shutil.copy2(f, cached / f.name)
|
||||
(cached / "details.json").write_text(json.dumps(d, indent=1, sort_keys=True))
|
||||
return "fetched"
|
||||
|
||||
|
||||
PROFILES = ("demo", "fresh")
|
||||
SCAN_FILE = "showcase-scan.json" # the fresh profile's games, found by the pretend folder scan (fakes.scan_job)
|
||||
|
||||
|
||||
def build(home: Path, offline: bool = False, refresh: bool = False, log=print, profile: str = "demo") -> dict:
|
||||
"""Write the demo library into `home` (emptied first). Sets FRAMEPORT_HOME for this process.
|
||||
|
||||
profile "demo": the library in use (games installed on the pretend Frame, one running). "fresh": FramePort's
|
||||
first start (the install tutorial): an empty library, the welcome screen, a Frame with nothing installed and no
|
||||
game running; the demo games (art and store details already in place) wait in showcase-scan.json for the
|
||||
pretend folder scan, as a scan would find them (no install or play history)."""
|
||||
if profile not in PROFILES:
|
||||
raise ValueError(f"unknown profile {profile!r} ({', '.join(PROFILES)})")
|
||||
home = Path(home).resolve()
|
||||
if home == real_data_dir() or real_data_dir() in home.parents:
|
||||
raise SystemExit(f"refusing to build the demo library in FramePort's own data dir ({home})")
|
||||
if home.exists():
|
||||
shutil.rmtree(home)
|
||||
home.mkdir(parents=True)
|
||||
os.environ["FRAMEPORT_HOME"] = str(home)
|
||||
for var in ("FRAMEPORT_NO_UPDATE_CHECK", "FRAMEPORT_NO_CATALOG_UPDATE", "FRAMEPORT_NO_LINK_HANDLER"):
|
||||
os.environ[var] = "1"
|
||||
from frameport.artwork import thumbs
|
||||
from frameport.core import library
|
||||
|
||||
fixture = load_fixture()
|
||||
tech = json.loads(ANALYSES.read_text())
|
||||
now = time.time()
|
||||
missing = [g["package"] for g in fixture["games"] if g["package"] not in tech]
|
||||
if missing:
|
||||
raise SystemExit(f"demo-analyses.json has no analysis for {missing}")
|
||||
for spec in fixture["games"]:
|
||||
library.upsert_game(spec["package"], **_entry(spec, tech[spec["package"]], now))
|
||||
# settings: what a first start would set (no welcome, no migrations or catalog refresh, no update nags)
|
||||
from frameport import __version__
|
||||
|
||||
with library.edit() as data:
|
||||
s = data.setdefault("settings", {})
|
||||
# (ui.easter_eggs off: no holiday badge or milestone confetti in the docs; the hook easter_eggs turns them on)
|
||||
s.update({"ui.theme": "portal", "ui.scale": 1.0, "ui.reduce_motion": False, "ui.welcome_done": True,
|
||||
"ui.easter_eggs": False,
|
||||
"ui.language": "en",
|
||||
"catalog.auto_update": False, "update.auto_check": False, "recipes.app_version": __version__,
|
||||
"update.last_seen_version": __version__})
|
||||
# the pretend Frame
|
||||
installed = []
|
||||
for spec in fixture["games"]:
|
||||
where = spec.get("frame")
|
||||
if where:
|
||||
installed.append({"package": spec["package"], "drive": "sd" if where == "sd" else "internal",
|
||||
**({"sha256": fake_sha(spec["package"], "older")} if where == "outdated" else {})})
|
||||
state = {"installed": installed, **{k: v for k, v in (fixture.get("frame") or {}).items()}}
|
||||
(home / "showcase-frame.json").write_text(json.dumps(state, indent=1))
|
||||
# art + store details
|
||||
sources: dict[str, list[str]] = {}
|
||||
for spec in fixture["games"]:
|
||||
src = _art(spec["package"], refresh, offline, log, pick=spec.get("art") == "pick")
|
||||
sources.setdefault(src, []).append(spec["package"])
|
||||
try:
|
||||
thumbs.prewarm(spec["package"])
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
# the managed tools are "installed" (no download toast in pictures): stand-in files
|
||||
tools = home / "showcase-tools"
|
||||
tools.mkdir()
|
||||
for var, name in (("FRAMEPORT_JAVA", "java"), ("FRAMEPORT_OVERPORT_JAR", "overport.jar"),
|
||||
("FRAMEPORT_APKSIGNER_JAR", "apksigner.jar")):
|
||||
(tools / name).write_bytes(b"")
|
||||
os.environ[var] = str(tools / name)
|
||||
if profile == "fresh":
|
||||
history = ("installs", "last_test", "last_played", "tags", "build")
|
||||
found = [{k: v for k, v in g.items() if k not in history} for g in library.games()]
|
||||
(home / SCAN_FILE).write_text(json.dumps(found))
|
||||
with library.edit() as data:
|
||||
data["games"] = {}
|
||||
data["settings"]["ui.welcome_done"] = False
|
||||
(home / "showcase-frame.json").write_text(json.dumps({"installed": [], "running": None,
|
||||
"battery": state.get("battery", 95)}, indent=1))
|
||||
log(f"demo library ({profile}): {len(fixture['games'])} games in {home} (art: "
|
||||
+ ", ".join(f"{k} {len(v)}" for k, v in sorted(sources.items())) + ")")
|
||||
if sources.get("none"):
|
||||
log(f" without art (placeholders): {', '.join(sources['none'])}")
|
||||
return {"home": str(home), "games": len(fixture["games"]), "art": sources}
|
||||
|
||||
|
||||
def build_for_render(home: Path, offline: bool = False, allow_missing_art: bool = False,
|
||||
profile: str = "demo") -> dict:
|
||||
"""build(), but a render must not go on with placeholder art (a store that didn't answer would otherwise put
|
||||
placeholders into the docs and the video): exits 4 unless allowed."""
|
||||
result = build(home, offline=offline, profile=profile)
|
||||
if result["art"].get("none") and not allow_missing_art:
|
||||
raise SystemExit(f"no art for {', '.join(result['art']['none'])} (a store didn't answer?): not rendering. "
|
||||
"Try again later, or pass --allow-missing-art")
|
||||
return result
|
||||
|
||||
|
||||
def tool_env(home: Path) -> dict:
|
||||
"""The environment variables a render needs for a built demo home (also for child processes)."""
|
||||
tools = Path(home) / "showcase-tools"
|
||||
return {"FRAMEPORT_HOME": str(home), "FRAMEPORT_NO_UPDATE_CHECK": "1", "FRAMEPORT_NO_CATALOG_UPDATE": "1",
|
||||
"FRAMEPORT_NO_LINK_HANDLER": "1", "FRAMEPORT_JAVA": str(tools / "java"),
|
||||
"FRAMEPORT_OVERPORT_JAR": str(tools / "overport.jar"),
|
||||
"FRAMEPORT_APKSIGNER_JAR": str(tools / "apksigner.jar")}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
sys.path.insert(0, str(REPO / "src"))
|
||||
ap = argparse.ArgumentParser()
|
||||
sub = ap.add_subparsers(dest="cmd", required=True)
|
||||
b = sub.add_parser("build")
|
||||
b.add_argument("home", type=Path)
|
||||
b.add_argument("--offline", action="store_true", help="only cached art (no network)")
|
||||
b.add_argument("--refresh", action="store_true", help="fetch art + details again (updates the cache)")
|
||||
b.add_argument("--profile", choices=PROFILES, default="demo", help="demo (in use) or fresh (first start)")
|
||||
args = ap.parse_args()
|
||||
build(args.home, offline=args.offline, refresh=args.refresh, profile=args.profile)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,686 @@
|
||||
"""Pretend Frame for GUI renders (ui_smoke, docs screenshots, the demo tour): its files, screenshots, games, drives,
|
||||
monitor stream and Type on Frame, with no network and no device. Shared by scripts/ui_smoke.py and scripts/showcase/.
|
||||
|
||||
The demo library (scripts/showcase/demo_home.py) writes `showcase-frame.json` into the data dir: which games the
|
||||
pretend Frame has installed (and on which drive), the running game and its battery; without it the library's working
|
||||
Quest builds are "installed" (the 8 largest).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import threading
|
||||
import time
|
||||
|
||||
from frameport.core import library
|
||||
from frameport.core.paths import user_data_dir
|
||||
from frameport.ui.app import FramePortApp
|
||||
|
||||
FRAME_STATE = "showcase-frame.json"
|
||||
SHOTS_AT = time.mktime((2026, 10, 4, 21, 40, 0, 0, 0, -1)) # the newest sample screenshot (local time)
|
||||
|
||||
|
||||
def frame_state() -> dict:
|
||||
"""The demo library's pretend Frame ({installed: [{package, drive, sha256?}], running, battery}), else {}."""
|
||||
try:
|
||||
return json.loads((user_data_dir() / FRAME_STATE).read_text())
|
||||
except (OSError, ValueError):
|
||||
return {}
|
||||
|
||||
|
||||
class FakeFS:
|
||||
"""--fake-frame's file system for the Files tab: a temp folder with sample files, served like SFTP."""
|
||||
|
||||
def __init__(self):
|
||||
import tempfile
|
||||
|
||||
self.home = tempfile.mkdtemp(prefix="fp-fake-frame-")
|
||||
samples = {"Videos": ["Earth from orbit (360).mp4", "Mars landing (VR180).mkv", "Concert 8K 3D.mp4"],
|
||||
"Downloads": ["Mods/", "readme.txt"], "Documents": ["Saves/", "Notes.pdf"]}
|
||||
sizes = {".mp4": 2_400_000_000, ".mkv": 1_100_000_000}
|
||||
for folder, names in samples.items():
|
||||
base = os.path.join(self.home, folder)
|
||||
os.makedirs(os.path.join(base, "Trips"), exist_ok=True)
|
||||
for n in names:
|
||||
if n.endswith("/"):
|
||||
os.makedirs(os.path.join(base, n), exist_ok=True)
|
||||
else:
|
||||
with open(os.path.join(base, n), "wb") as f:
|
||||
f.truncate(sizes.get(os.path.splitext(n)[1], 48_000)) # sparse: no real disk use
|
||||
# fixed dates (the Files tab shows them): a few days before the newest screenshot, a different one each
|
||||
for i, (root, dirs, files) in enumerate(sorted(os.walk(self.home), reverse=True)):
|
||||
for j, name in enumerate(sorted(dirs + files)):
|
||||
t = SHOTS_AT - 86400 * (2 + (i + j) % 5) - 3600 * ((i * 7 + j * 3) % 11)
|
||||
os.utime(os.path.join(root, name), (t, t))
|
||||
self.shots = self._screenshots()
|
||||
|
||||
def _screenshots(self) -> list[dict]:
|
||||
"""Sample Steam screenshots for the Screenshots tab, two days, a few games + SteamVR. They are the games' own
|
||||
in-game store screenshots (shot_*.jpg from the store details), never cover art: games installed on the
|
||||
pretend Frame first, the running one leading (Take screenshot adds one of it); SteamVR's own shots (taken in
|
||||
a game FramePort didn't install) come from another game's. Only a library without any store screenshots falls
|
||||
back to hero/wide art, else colour gradients."""
|
||||
from frameport.artwork import fetch
|
||||
|
||||
folder = os.path.join(self.home, "shots")
|
||||
os.makedirs(folder, exist_ok=True)
|
||||
state = frame_state()
|
||||
on_frame = {i["package"] for i in state.get("installed") or []}
|
||||
running = state.get("running")
|
||||
real, covers = [], []
|
||||
for g in library.games():
|
||||
if g.get("kind") == "rift":
|
||||
continue
|
||||
shots_art = sorted(fetch.artwork_dir(g["package"]).glob("shot_*.jpg"))
|
||||
if shots_art:
|
||||
real.append((g, shots_art))
|
||||
else:
|
||||
covers.append((g, [p for p in fetch.files(g["package"]) if p.stem in ("hero", "landscape")]))
|
||||
games = real or covers
|
||||
games.sort(key=lambda ga: (ga[0]["package"] != running, ga[0]["package"] not in on_frame, -len(ga[1]),
|
||||
ga[0]["package"]))
|
||||
self.owners = [(g["package"], g.get("title") or g["package"], arts) for g, arts in games[:3]]
|
||||
rest = [arts for g, arts in games[3:] if g["package"] not in on_frame] or [arts for _g, arts in games[3:4]]
|
||||
self.owners.append((None, "SteamVR", rest[0] if rest else []))
|
||||
self._used = [0] * len(self.owners) # the next screenshot of each owner (no picture shown twice)
|
||||
# fixed dates (renders don't change from one day to the next): 6 shots on the first day, 4 on the one before
|
||||
# (--gestures drags across the first row)
|
||||
shots = []
|
||||
for i in range(10):
|
||||
t = SHOTS_AT - i * 2400 - (86400 if i >= 6 else 0)
|
||||
shots.append(self._shot(t, i, i % len(self.owners)))
|
||||
return shots
|
||||
|
||||
def _shot(self, t: float, i: int, owner: int) -> dict:
|
||||
"""One Steam screenshot: the owner's next store screenshot, whole (scaled to 1280x720)."""
|
||||
from PIL import Image, ImageOps
|
||||
|
||||
pkg, title, arts = self.owners[owner]
|
||||
name = time.strftime("%Y%m%d%H%M%S", time.localtime(t)) + "_1.jpg"
|
||||
path = os.path.join(self.home, "shots", name)
|
||||
if arts:
|
||||
n = self._used[owner]
|
||||
self._used[owner] += 1
|
||||
with Image.open(arts[n % len(arts)]) as src:
|
||||
im = ImageOps.fit(src.convert("RGB"), (1280, 720))
|
||||
else:
|
||||
im = Image.linear_gradient("L").resize((640, 360)).convert("RGB")
|
||||
im = Image.merge("RGB", (im.getchannel(0).point(lambda v, i=i: (v + 40 * i) % 256),
|
||||
im.getchannel(1).point(lambda v: 255 - v), im.getchannel(2)))
|
||||
im.save(path, "JPEG", quality=85)
|
||||
return {"path": path, "thumb": None, "time": int(t), "width": 1920, "height": 1080,
|
||||
"size": os.path.getsize(path), "account": "1", "appid": "250820", "package": pkg, "title": title}
|
||||
|
||||
def take_screenshot(self) -> dict:
|
||||
"""Take screenshot: a new shot of the running game (its next store screenshot), newest of all."""
|
||||
time.sleep(1.2) # SteamVR captures, Steam saves
|
||||
t = max(s["time"] for s in self.shots) + 600
|
||||
shot = self._shot(t, len(self.shots) + 1, 0)
|
||||
self.shots.insert(0, shot)
|
||||
return {"taken": True, "path": shot["path"], "reason": None, "hmd": "Normal"}
|
||||
|
||||
def agent(self, command, **args):
|
||||
if command == "storage_targets":
|
||||
return {"targets": [{"id": n.lower(), "path": os.path.join(self.home, n), "android": a, "shared": True}
|
||||
for n, a in (("Videos", "/sdcard/Movies"), ("Downloads", "/sdcard/Download"),
|
||||
("Documents", "/sdcard/Documents"))]}
|
||||
if command == "list_screenshots":
|
||||
want = args.get("package")
|
||||
shots = [s for s in self.shots if want is None or (s["package"] or "") == want]
|
||||
games = {}
|
||||
for s in self.shots:
|
||||
games.setdefault(s["package"] or "", {"package": s["package"], "title": s["title"], "count": 0})
|
||||
games[s["package"] or ""]["count"] += 1
|
||||
return {"shots": shots, "total": len(shots), "games": list(games.values())}
|
||||
if command == "take_screenshot": # the Screenshots tab's button: a new shot of the running game
|
||||
return self.take_screenshot()
|
||||
raise RuntimeError(f"fake Frame: {command} not available")
|
||||
|
||||
@property
|
||||
def sftp(self):
|
||||
import paramiko
|
||||
|
||||
class SFTP:
|
||||
def listdir_attr(self, path):
|
||||
out = []
|
||||
for name in sorted(os.listdir(path)):
|
||||
a = paramiko.SFTPAttributes.from_stat(os.lstat(os.path.join(path, name)))
|
||||
a.filename = name
|
||||
out.append(a)
|
||||
return out
|
||||
|
||||
def stat(self, path):
|
||||
return paramiko.SFTPAttributes.from_stat(os.stat(path))
|
||||
|
||||
def get(self, remote, local, callback=None):
|
||||
import shutil
|
||||
|
||||
shutil.copyfile(remote, local)
|
||||
return SFTP()
|
||||
|
||||
|
||||
class FakeTarget:
|
||||
"""--fake-frame: a pretend Steam Frame with the library's working Quest builds installed (no network, no device),
|
||||
for documentation screenshots."""
|
||||
|
||||
def __init__(self, count: int = 8):
|
||||
from frameport.frame.connection import parse_target
|
||||
|
||||
self.label = "steamframe"
|
||||
self.frame = FakeFS()
|
||||
self.target = parse_target("steamos@steamframe.local")
|
||||
state = frame_state()
|
||||
if state.get("installed"): # the demo library says what's on the Frame
|
||||
sd_games = {i["package"] for i in state["installed"] if i.get("drive") == "sd"}
|
||||
self.games = [self._record(g, i.get("sha256")) for i in state["installed"]
|
||||
if (g := library.game(i["package"]))]
|
||||
else:
|
||||
works = [g for g in library.games() if g.get("kind") != "rift" and (g.get("build") or {}).get("sha256")
|
||||
and (g.get("recipe") or {}).get("status") in ("works", "issues")]
|
||||
works.sort(key=lambda g: -(g.get("data_bytes") or 0))
|
||||
self.games = [self._record(g) for g in works[:count]]
|
||||
sd_games = {self.games[1]["package"]} if len(self.games) > 1 else set()
|
||||
# --linux: the AppImage is on the Frame, but SteamOS lacks one of its libraries
|
||||
self.games += [{"package": g["package"], "kind": "linux", "title": g.get("title"), "apk_size": 2**26,
|
||||
"apk_present": True, "recipe": None, "exe": g.get("exe"),
|
||||
"missing_libraries": ["libwebkit2gtk-4.1.so.0"]}
|
||||
for g in library.games() if g.get("kind") == "linux" and g["package"] == LINUX_APPIMAGE]
|
||||
# GitHub #90: most games on internal storage, some on a microSD card
|
||||
sd = {"internal": False, "path": "/run/media/steamos/SD Card", "label": "SD Card"}
|
||||
for g in self.games:
|
||||
g["drive"] = sd if g["package"] in sd_games else \
|
||||
{"internal": True, "path": "/home/steamos", "label": "Internal storage"}
|
||||
g["drive_missing"] = False
|
||||
|
||||
@staticmethod
|
||||
def _record(g: dict, sha256: str | None = None) -> dict:
|
||||
"""The agent's list_installed record of a library game (sha256: a different build = "Update on Frame")."""
|
||||
rift = g.get("kind") == "rift"
|
||||
return {"package": g["package"], "kind": "rift" if rift else "quest", "title": g.get("title"),
|
||||
"apk_size": (g.get("data_bytes") or 0) + (0 if rift else 2**28),
|
||||
"sha256": sha256 or (g.get("build") or {}).get("sha256"),
|
||||
"recipe": {"patches": list((g.get("recipe") or {}).get("patches", []))}}
|
||||
|
||||
def launch(self, pkg: str) -> dict:
|
||||
"""Play: Steam on the pretend Frame starts the game (the "Starting … put the headset on" toast)."""
|
||||
return {"via": "shortcut", "steam": {"result": "started", "lines": []}}
|
||||
|
||||
def drives(self) -> list[dict]:
|
||||
sd_games = sum(1 for g in self.games if not g["drive"]["internal"])
|
||||
return [{"id": "internal", "path": "/home/steamos", "install_dir": "/home/steamos/Applications/quest-frame",
|
||||
"label": "Internal storage", "fstype": "ext4", "internal": True, "removable": False,
|
||||
"free_bytes": 312 * 2**30, "total_bytes": 460 * 2**30, "usable": True, "reason": "",
|
||||
"games": len(self.games) - sd_games},
|
||||
{"id": "/run/media/steamos/SD Card", "path": "/run/media/steamos/SD Card",
|
||||
"install_dir": "/run/media/steamos/SD Card/FramePort", "label": "SD Card", "fstype": "ext4",
|
||||
"internal": False, "removable": True, "free_bytes": 187 * 2**30, "total_bytes": 238 * 2**30,
|
||||
"usable": True, "reason": "", "games": sd_games},
|
||||
{"id": "/run/media/steamos/USB", "path": "/run/media/steamos/USB", "install_dir":
|
||||
"/run/media/steamos/USB/FramePort", "label": "USB", "fstype": "exfat", "internal": False,
|
||||
"removable": True, "free_bytes": 50 * 2**30, "total_bytes": 64 * 2**30, "usable": False,
|
||||
"reason": "exfat can't hold game data (no Unix permissions or symlinks); format the drive in "
|
||||
"SteamOS to install games on it", "games": 0}]
|
||||
|
||||
def move(self, package, dest, reporter) -> dict:
|
||||
reporter.stage("Move game files")
|
||||
for i in range(5):
|
||||
reporter.progress(i / 4, f"Copying {i / 2:.1f}/2.0 GiB")
|
||||
time.sleep(0.5)
|
||||
return {"state": "done", "package": package}
|
||||
|
||||
def set_desktop_entry(self, package, enabled) -> dict:
|
||||
for g in self.games:
|
||||
if g["package"] == package:
|
||||
g["desktop_entry"] = enabled
|
||||
return {"enabled": enabled}
|
||||
|
||||
def describe(self) -> dict:
|
||||
return {"hostname": "steamframe", "os": "SteamOS", "os_version": "3.8", "build_id": "20260922",
|
||||
"free_bytes": 312 * 2**30, "installed": self.games, "lepton": True,
|
||||
"proton": {"ready": {"display_name": "Proton 11 (ARM64)"}, "openxr": {"name": "SteamVR"}},
|
||||
"kernel_keys": {"keys": 31, "max_keys": 200},
|
||||
"battery": {"percent": frame_state().get("battery", 95), "status": "Discharging"}}
|
||||
|
||||
def installed(self) -> list[dict]:
|
||||
return self.games
|
||||
|
||||
def close(self) -> None:
|
||||
pass
|
||||
|
||||
|
||||
class FakeKeyboardSession:
|
||||
"""--fake-frame: Type on Frame connects at once (nothing is sent anywhere)."""
|
||||
|
||||
def __init__(self, frame):
|
||||
self.closed = False
|
||||
|
||||
def key(self, name, action="down"):
|
||||
return True
|
||||
|
||||
def text(self, text):
|
||||
return ""
|
||||
|
||||
def close(self):
|
||||
self.closed = True
|
||||
|
||||
|
||||
class FakeMonitorSession:
|
||||
"""--fake-frame: the Monitor tab's stream as synthetic samples, one per second, shaped like a real Quest game on
|
||||
the dev Frame (2026-10-07): 72 fps, the game's Android container, SteamVR/Steam as context. Two minutes are sent
|
||||
at once first, so the charts are full in screenshots. GAME = --game (else the library's first game)."""
|
||||
|
||||
GAME: str | None = None
|
||||
DIP: tuple[float, float] | None = None # (until, fps): steps hook fps_dip
|
||||
PERFECT = 0.0 # until (time.time()): right on 72 fps (steps hook perfect_pacing)
|
||||
BATTERY: dict | None = None # the battery from now on (steps hook battery)
|
||||
BACKFILL = 120
|
||||
# (name, group, CPU %, GPU %, memory); "GAME" = the game's package
|
||||
PROCS = [("GAME", "game", 9.8, 44.0, 1_350_000_000), ("vrcompositor", "steamvr", 1.4, 9.0, 80_000_000),
|
||||
("system_server", "game", 1.1, 0.0, 296_000_000), ("XRServiceLoopTh", "steamvr", 0.5, 0.0, 433_000_000),
|
||||
("steamwebhelper", "steam", 0.4, 0.0, 350_000_000), ("com.android.systemui", "game", 0.1, 0.0,
|
||||
229_000_000),
|
||||
("surfaceflinger", "game", 0.1, 0.4, 96_000_000), ("audioserver", "game", 0.1, 0.0, 31_000_000),
|
||||
("com.android.providers.media.module", "game", 0.1, 0.0, 130_000_000),
|
||||
("com.android.launcher3", "game", 0.0, 0.0, 194_000_000), ("main", "game", 0.0, 0.0, 178_000_000),
|
||||
("com.android.settings", "game", 0.0, 0.0, 172_000_000),
|
||||
("com.android.networkstack.process", "game", 0.0, 0.0, 130_000_000),
|
||||
("android.ext.services", "game", 0.0, 0.0, 111_000_000)] + \
|
||||
[("vrwebhelper", "steamvr", 0.3, 0.0, 160_000_000 + i * 9_000_000) for i in range(4)]
|
||||
|
||||
def __init__(self, frame, on_sample, on_end=None):
|
||||
import math
|
||||
|
||||
self.math, self.closed, self.on_sample = math, False, on_sample
|
||||
self.static = {"agent": 62, "cores": 8, "gpu_max_mhz": 903, "mem_total": 16 * 1024 ** 3, "fan": True,
|
||||
"clusters": [{"cpus": [0, 1], "max_mhz": 2265}, {"cpus": [2, 3, 4], "max_mhz": 3148},
|
||||
{"cpus": [5, 6], "max_mhz": 2956}, {"cpus": [7], "max_mhz": 3052}],
|
||||
"temp_groups": ["CPU", "GPU", "Memory", "Battery", "NPU", "Power ICs", "Modem", "Camera"]}
|
||||
self.t = 0
|
||||
threading.Thread(target=self._run, daemon=True).start()
|
||||
|
||||
def _sample(self) -> dict:
|
||||
m, t = self.math, self.t
|
||||
wave = lambda a, p, o=0: a * (1 + m.sin(t / p + o)) / 2 # noqa: E731
|
||||
state = frame_state()
|
||||
idle = not self.GAME and "running" in state and state["running"] is None # (a fresh Frame: no game)
|
||||
running = self.GAME or state.get("running")
|
||||
g = library.game(running) if running else (library.games() or [None])[0]
|
||||
game = g or {"package": "com.example.game", "title": "Example Game"}
|
||||
pkg = game["package"]
|
||||
procs = [{"pid": 570799 + i * 37, "ppid": 1, "name": pkg if n == "GAME" else n,
|
||||
"group": f"game:{pkg}" if grp == "game" else grp, "game": pkg if grp == "game" else None,
|
||||
"cpu": round(c * (0.85 + wave(0.3, 3, i)), 1), "gpu": round(gp * (0.9 + wave(0.2, 5, i)), 1),
|
||||
"rss": r, "age": 1500 + t, "uid": 1000, "critical": grp in ("steamvr", "steam"), "locked": False,
|
||||
"context": grp != "game"}
|
||||
for i, (n, grp, c, gp, r) in enumerate(self.PROCS) if not (idle and grp == "game")]
|
||||
return {
|
||||
"t": time.time() - max(0, self.BACKFILL - t), "dt": 1.0, "self_ms": 11.5,
|
||||
"cpu": {"total": round(15 + wave(4, 4), 1), "cores": [round(4 + wave(30, 3 + i, i), 1) for i in range(8)],
|
||||
"mhz": [2265, 1996, 1920, 518]},
|
||||
"gpu": {"busy": round(52 + wave(8, 5), 1), "mhz": 903},
|
||||
"mem": {"total": 15.3 * 1024 ** 3, "avail": int((8.3 - wave(0.15, 9)) * 1024 ** 3),
|
||||
"swap_total": 7.6 * 1024 ** 3, "swap_free": 7.4 * 1024 ** 3},
|
||||
"psi": {"cpu": 1.0, "memory": 0.0, "io": 0.1},
|
||||
"temps": {"CPU": round(48 + wave(1.5, 11), 1), "GPU": round(46.5 + wave(1, 13), 1), "Memory": 47.1,
|
||||
"Battery": 27.7, "NPU": 47.3, "Power ICs": 37.0, "Modem": 44.2, "Camera": 46.3},
|
||||
"zones": {"CPU": {"cpu7-top": 48.4, "cpu0": 44.0}, "GPU": {"gpuss-0": 46.5}},
|
||||
"fan": 8500 + int(wave(300, 7)),
|
||||
"power": {"system": round(7.3 + wave(0.6, 4), 2), "cpu": 0.85, "gpu": round(1.0 + wave(0.3, 5), 2),
|
||||
"npu": 0.1},
|
||||
"battery": {"percent": frame_state().get("battery", 95), "status": "Discharging", "plugged": False,
|
||||
"draining": True, "watts": -1.96, "empty_s": 22440},
|
||||
"net": {"wlan0": [int(2000 + wave(4000, 3)), 1000], "wlanap": [0, 0], "usb0": [0, 0]},
|
||||
"games": [{"package": pkg, "title": game.get("title") or pkg, "kind": "quest", "appid": 1,
|
||||
"elapsed": 1500 + t, "cpu": 9.4, "gpu": round(44 + wave(6, 5), 1), "mem": 3_390_000_000,
|
||||
"processes": 87, "fps": round(71.6 + wave(0.6, 2) - (9 if t % 41 == 30 else 0), 1),
|
||||
"frame_ms": 0.0}] if not idle else [],
|
||||
"procs": procs, "filter": "game"}
|
||||
|
||||
def _run(self) -> None:
|
||||
self.t = 0
|
||||
while not self.closed and self.t < 100000:
|
||||
self.on_sample(self._sample())
|
||||
if self.t >= self.BACKFILL: # the first two minutes at once (full charts), then one per second
|
||||
time.sleep(1)
|
||||
self.t += 1
|
||||
|
||||
def set_modules(self, m):
|
||||
# the hub asks for everything when the Monitor tab subscribes (the Frame card started the stream): send the
|
||||
# two minutes again so its charts are full in screenshots too
|
||||
if m == "all":
|
||||
self.t = 0
|
||||
return True
|
||||
|
||||
def set_interval(self, s): pass # noqa: E704
|
||||
def set_filter(self, w): pass # noqa: E704
|
||||
def pause(self, p): pass # noqa: E704
|
||||
|
||||
def kill(self, pid, sig="TERM", force=False):
|
||||
return {"ended": True, "pid": pid}
|
||||
|
||||
def end_game(self, package):
|
||||
return {"ended": True, "via": "steam"}
|
||||
|
||||
def close(self):
|
||||
self.closed = True
|
||||
|
||||
|
||||
FAKE_INSTALL_STAGES = ["Patching the game", "OVRPort (primary)", "Frame fixes (primary)", "sign (primary)",
|
||||
"validate (primary)", "Prepare Frame", "Upload APK"]
|
||||
|
||||
|
||||
def start_fake_install(app: FramePortApp, package: str) -> None:
|
||||
"""A running install job of `package` that reports the real stage names up to the upload (62 %) and then waits
|
||||
(it never ends: the smoke run exits with it)."""
|
||||
from frameport.ui.jobs import Job
|
||||
|
||||
hold, reached = threading.Event(), threading.Event()
|
||||
|
||||
def run(job):
|
||||
for stage in FAKE_INSTALL_STAGES:
|
||||
job.reporter.stage(stage)
|
||||
time.sleep(0.3) # past the job queue's notification throttle
|
||||
job.reporter.progress(0.62, "com.example.apk", speed="36.4 MB/s · ~1 min left")
|
||||
reached.set()
|
||||
hold.wait()
|
||||
|
||||
app.jobs.submit(Job(f"Install {app._title(package)} on Frame", run, package, "install"))
|
||||
reached.wait(10)
|
||||
|
||||
|
||||
def open_type_tab(app: FramePortApp) -> None:
|
||||
"""The Type on Frame tab, with one key 'pressed' so the screenshot shows it working."""
|
||||
app.type_on_frame()
|
||||
time.sleep(1.5)
|
||||
app.keyboard_view.press("Enter")
|
||||
|
||||
|
||||
def fake_live_stream(app: FramePortApp) -> None:
|
||||
"""The Live view while streaming: a local ffmpeg test picture through the real relay (no Frame needed). Web mode
|
||||
has no in-window player, so it's shown as playing in the browser (the bar's streaming layout)."""
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
from frameport.install.livestream import LiveStream
|
||||
|
||||
view = app.live_view
|
||||
if view is None or shutil.which("ffmpeg") is None:
|
||||
return
|
||||
src = ["ffmpeg", "-loglevel", "error", "-re", "-f", "lavfi", "-i", "testsrc2=size=1280x720:rate=30",
|
||||
"-f", "lavfi", "-i", "sine=frequency=440:sample_rate=48000", "-c:v", "libx264", "-preset", "ultrafast",
|
||||
"-g", "30", "-pix_fmt", "yuv420p", "-c:a", "aac", "-f", "mp4",
|
||||
"-movflags", "empty_moov+default_base_moof+frag_keyframe", "-frag_duration", "100000", "-"]
|
||||
proc = subprocess.Popen(src, stdout=subprocess.PIPE)
|
||||
view.live = LiveStream(lambda: proc.stdout, proc.terminate).start()
|
||||
view.mode = "browser"
|
||||
view._refresh()
|
||||
|
||||
|
||||
def stop_fake_live(app: FramePortApp) -> None:
|
||||
if app.live_view is not None and app.live_view.live is not None:
|
||||
app.live_view.stop()
|
||||
|
||||
|
||||
def open_monitor_details(app: FramePortApp) -> None:
|
||||
"""The Monitor with its details row open."""
|
||||
app.go("monitor")
|
||||
time.sleep(2)
|
||||
if not app.monitor_view.details.visible:
|
||||
app.monitor_view.toggle_details()
|
||||
|
||||
|
||||
LINUX_APPIMAGE = "linux.venera" # --linux's packages
|
||||
LINUX_FOLDER = "linux.matineevr"
|
||||
|
||||
|
||||
def _elf(machine: int = 183, appimage: bool = False, extra: bytes = b"") -> bytes:
|
||||
"""A minimal ELF header (183 = aarch64): enough for FramePort's Linux app detection."""
|
||||
head = bytearray(64)
|
||||
head[:4], head[4], head[5] = b"\x7fELF", 2, 1
|
||||
if appimage:
|
||||
head[8:11] = b"AI\x02"
|
||||
head[18:20] = machine.to_bytes(2, "little")
|
||||
return bytes(head) + extra
|
||||
|
||||
|
||||
def add_fake_linux_apps() -> None:
|
||||
"""--linux: an AppImage and a VR app folder (with a helper program, so "Change program…" shows) in the library."""
|
||||
from frameport import pipeline
|
||||
|
||||
base = user_data_dir() / "smoke-linux"
|
||||
app = base / "MatineeVR"
|
||||
(app / "lib").mkdir(parents=True, exist_ok=True)
|
||||
(base / "Venera-2.4.2-aarch64.AppImage").write_bytes(_elf(appimage=True, extra=b"\0" * 4096))
|
||||
(app / "MatineeVR").write_bytes(_elf(extra=b"\0" * 8192))
|
||||
(app / "crashpad_handler").write_bytes(_elf())
|
||||
(app / "lib" / "libopenxr_loader.so.1").write_bytes(_elf(extra=b"xrCreateInstance"))
|
||||
pipeline.add_linux_app(base / "Venera-2.4.2-aarch64.AppImage")
|
||||
pipeline.add_linux_app(app)
|
||||
|
||||
|
||||
def install_fakes(game: str | None, monitor_session=None) -> None:
|
||||
"""--fake-frame: never reach a real Frame (start-up auto-connect, discovery, the 30 s poll); Type on Frame and
|
||||
the Monitor stream are fakes. `game` = the Monitor's game card (with its artwork)."""
|
||||
from frameport.frame import keyboard, monitor
|
||||
|
||||
keyboard.KeyboardSession = FakeKeyboardSession
|
||||
monitor.MonitorSession = monitor_session or FakeMonitorSession
|
||||
FakeMonitorSession.GAME = game
|
||||
FramePortApp.connect = lambda self, *a, **k: None
|
||||
FramePortApp.refresh_frame = lambda self, *a, **k: None
|
||||
install_first_run_fakes()
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ first run (the install tutorial)
|
||||
# The setup command shows placeholders for the address and code (each PC has its own; never this PC's real address).
|
||||
PAIR_HOST, PAIR_PORT, PAIR_CODE = "<your-PC-address>", 8765, "<one-time-code>"
|
||||
TOOLS = {"ready": True} # False: the managed tools look missing until the (pretend) download finishes
|
||||
|
||||
|
||||
class FakePairingServer:
|
||||
"""The Frame page's setup command without a server: nothing listens and no firewall rule is touched. The
|
||||
`pairing_done` step hook plays the Frame running the command (on_paired → the pretend Frame connects)."""
|
||||
|
||||
def __init__(self, on_paired=None, host: str = "", **_kw):
|
||||
# host stays as given ("" = over the network; the Frame page words a set host as the USB-cable setup)
|
||||
self.on_paired, self.host = on_paired, host
|
||||
self.port, self.code = PAIR_PORT, PAIR_CODE
|
||||
self.requests, self.failures, self.paired, self.hint = 1, 0, [], "" # (requests: no firewall hint)
|
||||
self.running = False
|
||||
|
||||
@property
|
||||
def url(self) -> str:
|
||||
return f"http://{self.host or PAIR_HOST}:{self.port}"
|
||||
|
||||
@property
|
||||
def one_liner(self) -> str:
|
||||
return f"curl -fsS {self.host or PAIR_HOST}:{self.port}/{self.code} | bash"
|
||||
|
||||
def start(self):
|
||||
self.running = True
|
||||
return self
|
||||
|
||||
def stop_soon(self) -> None:
|
||||
self.running = False
|
||||
|
||||
def stop(self) -> None:
|
||||
self.running = False
|
||||
|
||||
|
||||
def install_first_run_fakes() -> None:
|
||||
"""Fakes for a first start: no Frame discovery on the real network (a recording must not show a real device),
|
||||
the pretend setup command, and the managed tools' state (TOOLS)."""
|
||||
from frameport.frame import discovery, pairing
|
||||
from frameport.tools import toolchain
|
||||
|
||||
discovery.browse = lambda *a, **k: []
|
||||
pairing.PairingServer = FakePairingServer
|
||||
pairing.ensure_reachable = lambda server: "ok"
|
||||
if not getattr(toolchain.status, "_showcase", False):
|
||||
real_status = toolchain.status
|
||||
|
||||
def status(*a, **k):
|
||||
out = real_status(*a, **k)
|
||||
if not TOOLS["ready"]:
|
||||
for s in out:
|
||||
s.installed, s.version = False, None
|
||||
return out
|
||||
status._showcase = True
|
||||
toolchain.status = status
|
||||
|
||||
|
||||
def tools_job(app, pace: float = 1.0, delay: float = 0.0):
|
||||
"""The welcome screen's "Getting FramePort ready": a pretend download of Java, OVRPort and apksigner through the
|
||||
real job queue (app.update_tools while TOOLS["ready"] is False). `delay`: seconds at 0 % first."""
|
||||
from frameport.ui.jobs import Job
|
||||
|
||||
def run(job):
|
||||
rep = job.reporter
|
||||
rep.stage("Downloading tools")
|
||||
time.sleep(delay)
|
||||
parts = [("Java runtime (Temurin 21)", 48.0), ("OVRPort CLI", 21.0), ("apksigner", 1.6)]
|
||||
total = sum(mb for _n, mb in parts)
|
||||
done = 0.0
|
||||
for name, mb in parts:
|
||||
rep.stage(f"Downloading {name}")
|
||||
steps = max(3, int(mb / 4))
|
||||
for i in range(1, steps + 1):
|
||||
got = done + mb * i / steps
|
||||
rep.progress(got / total, f"{name}: {mb * i / steps:.1f} of {mb:.1f} MB")
|
||||
time.sleep(0.12 * pace)
|
||||
done += mb
|
||||
TOOLS["ready"] = True
|
||||
return "FramePort is ready"
|
||||
job = app.jobs.submit(Job("Download tools", run, None, "tools"))
|
||||
return job
|
||||
|
||||
|
||||
def scan_job(app, folder: str, entries: list[dict], pace: float = 1.0):
|
||||
"""Scan a folder: the demo games appear one by one through the real job queue (the folder picker is a native
|
||||
dialog a script can't drive; `entries` = the demo library saved aside by demo_home's "fresh" profile)."""
|
||||
from frameport.artwork import thumbs
|
||||
|
||||
def run(job):
|
||||
rep = job.reporter
|
||||
rep.stage("Looking for games")
|
||||
for i, e in enumerate(entries, 1):
|
||||
rep.progress(i / len(entries), e.get("title") or e["package"])
|
||||
library.upsert_game(e["package"], **{k: v for k, v in e.items() if k != "package"})
|
||||
try:
|
||||
thumbs.prewarm(e["package"])
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
time.sleep(0.12 * pace)
|
||||
library.set_setting("scan.roots", [folder])
|
||||
if app.route[0] == "welcome":
|
||||
library.set_setting("ui.welcome_done", True)
|
||||
return f"{len(entries)} games found in {folder}"
|
||||
return app.submit(f"Scan {folder.rstrip('/').rsplit('/', 1)[-1]}", run, None, "scan")
|
||||
|
||||
|
||||
def attach_fake_frame(app: FramePortApp, monitor_session=None) -> None:
|
||||
"""Connect `app` to a FakeTarget (the shared monitor stream, used by the Monitor tab and the Frame card, too)."""
|
||||
app.monitor_hub.session_factory = monitor_session or FakeMonitorSession
|
||||
app.target = FakeTarget()
|
||||
app.frame_info, app.frame_state = app.target.describe(), "connected"
|
||||
|
||||
|
||||
class FrozenMonitorSession(FakeMonitorSession):
|
||||
"""The fake stream for still pictures: the two minutes of history, then nothing new (every render of a page shows
|
||||
the same numbers, whenever the screenshot is taken)."""
|
||||
|
||||
def _run(self) -> None:
|
||||
self.t = 0
|
||||
while not self.closed:
|
||||
if self.t <= self.BACKFILL:
|
||||
self.on_sample(self._sample())
|
||||
self.t += 1
|
||||
else:
|
||||
time.sleep(0.2)
|
||||
|
||||
|
||||
class LiveMonitorSession(FakeMonitorSession):
|
||||
"""The fake stream, livelier for videos: a sample every 0.6 s and a steady frame rate with a short, shallow dip
|
||||
now and then (also in the two minutes sent first), so the card's sparkline (5 s points) has a shape and visibly
|
||||
moves without the game looking like it struggles. Seeded: every recording gets the same curve."""
|
||||
|
||||
def _sample(self) -> dict:
|
||||
s = super()._sample()
|
||||
t = self.t
|
||||
rnd = random.Random(t)
|
||||
fps = 72 - abs(rnd.gauss(0, 0.6))
|
||||
if t % 45 in (20, 21, 22): # a short, shallow dip now and then
|
||||
fps = 66 + 2 * abs(t % 45 - 21) + rnd.uniform(-0.8, 0.8)
|
||||
if self.DIP and time.time() < self.DIP[0]: # (the step hook fps_dip: a stutter on cue)
|
||||
fps = self.DIP[1] + rnd.uniform(-0.8, 0.8)
|
||||
if time.time() < self.PERFECT: # (the step hook perfect_pacing: right on target)
|
||||
fps = 72 - rnd.uniform(0, 0.2)
|
||||
for g in s["games"]:
|
||||
g["fps"] = round(fps, 1)
|
||||
if self.BATTERY:
|
||||
s["battery"] = dict(self.BATTERY)
|
||||
return s
|
||||
|
||||
def _run(self) -> None:
|
||||
self.t = 0
|
||||
while not self.closed and self.t < 100000:
|
||||
self.on_sample(self._sample())
|
||||
if self.t >= self.BACKFILL:
|
||||
time.sleep(0.6)
|
||||
self.t += 1
|
||||
|
||||
def set_modules(self, m):
|
||||
"""Opening the Monitor tab adds modules: on film the stream just goes on, as the real one does (the tab's
|
||||
charts start there and grow live). Replaying the two minutes, as the stills' stream does, showed the charts
|
||||
racing to catch up."""
|
||||
return True
|
||||
|
||||
|
||||
def install_job(package: str, pace: float = 1.0):
|
||||
"""A pretend install of `package` for the real JobManager (app.submit): every stage the real one reports, an
|
||||
upload ticking at a plausible speed, the launch test passing. pace < 1 = faster."""
|
||||
def run(job):
|
||||
rep = job.reporter
|
||||
g = library.game(package) or {}
|
||||
title = g.get("title") or package
|
||||
rnd = random.Random(7)
|
||||
|
||||
def stage(name, secs, logs=()):
|
||||
rep.stage(name)
|
||||
for line in logs:
|
||||
rep.log(line)
|
||||
time.sleep(secs * pace)
|
||||
if g.get("kind") == "rift":
|
||||
stage("Prepare the game", 1.0)
|
||||
else:
|
||||
stage("Patching the game", 0.9)
|
||||
stage("OVRPort (primary)", 1.2, ["overport patch --version=latest"])
|
||||
stage("Frame fixes (primary)", 1.0, list((g.get("recipe") or {}).get("patches") or [])[-3:])
|
||||
stage("sign (primary)", 0.7)
|
||||
rep.stage("validate (primary)")
|
||||
for name in ("APK signature", "64-bit libraries", "OpenXR loader"):
|
||||
rep.check(name, True)
|
||||
time.sleep(0.25 * pace)
|
||||
stage("Prepare Frame", 0.7)
|
||||
total = max(g.get("data_bytes") or 0, 1.4e9)
|
||||
first, steps = 0.42, 14
|
||||
for name, file, lo, hi in (("Upload APK", f"{package}.apk", 0.0, first),
|
||||
("Upload data (3 files)", f"main.1.{package}.obb", first, 1.0)):
|
||||
rep.stage(name)
|
||||
for i in range(1, steps + 1):
|
||||
f = lo + (hi - lo) * i / steps
|
||||
speed = 34.0 + rnd.uniform(0, 4)
|
||||
left = (1 - f) * total / (speed * 1e6)
|
||||
rep.progress(f, file, speed=f"{speed:.1f} MB/s · ~{left:.0f} s left" if f < 1 else f"{speed:.1f} MB/s")
|
||||
time.sleep(0.22 * pace)
|
||||
stage("Artwork for the Steam library", 0.8)
|
||||
stage("Finalize install", 0.9)
|
||||
stage("Add to Steam library", 0.8)
|
||||
stage("Launch test (headless)", 1.8, ["process alive", "OpenXR session created", "frames paced: 72 fps"])
|
||||
job.summary = {"verdict": "pass", "findings": []}
|
||||
rep.stage("Launch test: passed")
|
||||
time.sleep(0.5 * pace)
|
||||
return f"{title} is ready on your Frame: put the headset on and launch it from your Steam library"
|
||||
return run
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
"""Post-production for the demo tour, with ffmpeg only: screencast frames → a constant-frame-rate video, one clip per
|
||||
scene with its caption faded in, title and end cards, crossfades between everything, then the final MP4, a poster and
|
||||
the short looping WebP teaser for the README.
|
||||
|
||||
The filter graphs are built by pure functions (tested without ffmpeg); `run` executes a command and fails loudly.
|
||||
Cards and captions are small HTML pages rendered by the same Chromium (render_card), in the app's own colours.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import html
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
FFMPEG = shutil.which("ffmpeg") or "ffmpeg"
|
||||
FPS = 30
|
||||
SIZE = (1920, 1080)
|
||||
|
||||
|
||||
def run(args: list[str]) -> None:
|
||||
cmd = [FFMPEG, "-y", "-hide_banner", "-loglevel", "error", *map(str, args)]
|
||||
r = subprocess.run(cmd, capture_output=True, text=True)
|
||||
if r.returncode != 0:
|
||||
raise RuntimeError(f"ffmpeg failed ({r.returncode}): {' '.join(cmd)}\n{r.stderr[-3000:]}")
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ frames → video
|
||||
|
||||
def concat_list(frames: list[tuple[float, str]], end: float | None = None, min_frame: float = 1 / 120) -> str:
|
||||
"""An ffconcat script showing each screencast frame until the next one came (Chrome sends frames only on
|
||||
changes); the last one until `end` (wall-clock), else for one frame time."""
|
||||
lines = ["ffconcat version 1.0"]
|
||||
for i, (t, name) in enumerate(frames):
|
||||
nxt = frames[i + 1][0] if i + 1 < len(frames) else (end if end is not None else t + 1 / FPS)
|
||||
lines += [f"file '{name}'", f"duration {max(min_frame, nxt - t):.6f}"]
|
||||
if frames:
|
||||
lines.append(f"file '{frames[-1][1]}'") # ffconcat: the last entry's duration needs a following file
|
||||
return "\n".join(lines) + "\n"
|
||||
|
||||
|
||||
def frames_to_video(folder: Path, out: Path, end: float | None = None, size: tuple[int, int] = SIZE) -> float:
|
||||
"""The screencast (folder/frames.json + JPEGs) as a constant-frame-rate H.264 file (high quality, an
|
||||
intermediate). Returns the wall-clock time of its first frame (scene times are relative to it)."""
|
||||
frames = [tuple(f) for f in json.loads((folder / "frames.json").read_text())]
|
||||
if not frames:
|
||||
raise RuntimeError("the screencast has no frames")
|
||||
(folder / "frames.ffconcat").write_text(concat_list(frames, end))
|
||||
w, h = size
|
||||
run(["-f", "concat", "-safe", "0", "-i", folder / "frames.ffconcat",
|
||||
"-vf", f"fps={FPS},scale={w}:{h}:flags=lanczos:force_original_aspect_ratio=decrease,"
|
||||
f"pad={w}:{h}:(ow-iw)/2:(oh-ih)/2,format=yuv420p",
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "12", out])
|
||||
return frames[0][0]
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ scenes
|
||||
|
||||
def caption_window(duration: float, show: float = 4.2, fade: float = 0.45, lead: float = 0.35) -> tuple[float, float]:
|
||||
"""When a scene's caption is on screen: from `lead` s in, for `show` s (shorter scenes: until 0.6 s before
|
||||
their end), fading `fade` s in and out. Returns (start, end)."""
|
||||
start = min(lead, max(0.0, duration / 4))
|
||||
end = min(start + show, max(start + 2 * fade, duration - 0.6))
|
||||
return start, end
|
||||
|
||||
|
||||
def scene_filter(duration: float, fade: float = 0.45, size: tuple[int, int] = SIZE) -> str:
|
||||
"""The filter graph laying a caption (input 1, a still RGBA PNG looped) over a scene (input 0)."""
|
||||
start, end = caption_window(duration, fade=fade)
|
||||
return (f"[1:v]scale={size[0]}:{size[1]}:flags=lanczos,format=rgba,fade=t=in:st={start:.3f}:d={fade}:alpha=1,"
|
||||
f"fade=t=out:st={end - fade:.3f}:d={fade}:alpha=1[cap];"
|
||||
f"[0:v][cap]overlay=0:0:format=auto:shortest=1,format=yuv420p[v]")
|
||||
|
||||
|
||||
def cut_scene(raw: Path, start: float, duration: float, caption: Path | None, out: Path,
|
||||
size: tuple[int, int] = SIZE) -> None:
|
||||
"""One scene from the raw recording, with its caption."""
|
||||
if caption is None:
|
||||
run(["-ss", f"{start:.3f}", "-t", f"{duration:.3f}", "-i", raw, "-an",
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "12", "-pix_fmt", "yuv420p", out])
|
||||
return
|
||||
run(["-ss", f"{start:.3f}", "-t", f"{duration:.3f}", "-i", raw,
|
||||
"-loop", "1", "-t", f"{duration:.3f}", "-i", caption,
|
||||
"-filter_complex", scene_filter(duration, size=size), "-map", "[v]", "-an", "-r", FPS,
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "12", out])
|
||||
|
||||
|
||||
def card_clip(image: Path, duration: float, out: Path, zoom: float = 0.03) -> None:
|
||||
"""A title/end card: the still, slowly zooming in by `zoom` over its duration (alive, not frozen)."""
|
||||
frames = max(1, int(duration * FPS))
|
||||
w, h = SIZE
|
||||
run(["-loop", "1", "-t", f"{duration:.3f}", "-i", image,
|
||||
"-vf", f"scale={w * 2}:{h * 2},zoompan=z='1+{zoom}*on/{frames}':x='iw/2-(iw/zoom/2)':"
|
||||
f"y='ih/2-(ih/zoom/2)':d={frames}:s={w}x{h}:fps={FPS},format=yuv420p",
|
||||
"-frames:v", frames, "-c:v", "libx264", "-preset", "veryfast", "-crf", "12", out])
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ joining
|
||||
|
||||
def xfade_offsets(durations: list[float], transition: float) -> list[float]:
|
||||
"""Where each crossfade starts on the joined timeline: clip k+1 begins `transition` s before clip k ends."""
|
||||
offsets, total = [], 0.0
|
||||
for d in durations[:-1]:
|
||||
total += d - transition
|
||||
offsets.append(round(total, 3))
|
||||
return offsets
|
||||
|
||||
|
||||
def xfade_graph(durations: list[float], transition: float, size: tuple[int, int] = SIZE) -> tuple[str, str]:
|
||||
"""(filter graph, output label) crossfading inputs 0..n-1 in order. Every input is brought to the same size,
|
||||
frame rate, timebase and pixel format first (xfade refuses anything else)."""
|
||||
w, h = size
|
||||
parts = [f"[{k}:v]fps={FPS},scale={w}:{h}:flags=lanczos,setsar=1,format=yuv420p,settb=AVTB[n{k}]"
|
||||
for k in range(len(durations))]
|
||||
prev = "[n0]"
|
||||
for k, off in enumerate(xfade_offsets(durations, transition), start=1):
|
||||
label = f"[x{k}]"
|
||||
parts.append(f"{prev}[n{k}]xfade=transition=fade:duration={transition}:offset={off}{label}")
|
||||
prev = label
|
||||
parts.append(f"{prev}format=yuv420p[vout]")
|
||||
return ";".join(parts), "[vout]"
|
||||
|
||||
|
||||
def joined_length(durations: list[float], transition: float) -> float:
|
||||
return sum(durations) - transition * (len(durations) - 1)
|
||||
|
||||
|
||||
def join(clips: list[Path], durations: list[float], out: Path, transition: float = 0.5, crf: int = 23,
|
||||
size: tuple[int, int] = SIZE, extra: list[str] | None = None) -> None:
|
||||
graph, label = xfade_graph(durations, transition, size)
|
||||
args = []
|
||||
for c in clips:
|
||||
args += ["-i", c]
|
||||
run([*args, "-filter_complex", graph, "-map", label, "-an", "-r", FPS, "-c:v", "libx264", "-preset", "slow",
|
||||
"-crf", crf, "-pix_fmt", "yuv420p", "-movflags", "+faststart", *(extra or []), out])
|
||||
|
||||
|
||||
def encode_within(clips: list[Path], durations: list[float], out: Path, budget_mb: float, transition: float = 0.5,
|
||||
crf: int = 22, max_crf: int = 32) -> int:
|
||||
"""The final MP4 at the best quality (lowest CRF) that fits `budget_mb`. Returns the CRF used."""
|
||||
while True:
|
||||
join(clips, durations, out, transition, crf)
|
||||
if out.stat().st_size <= budget_mb * 1e6 or crf >= max_crf:
|
||||
return crf
|
||||
crf += 2
|
||||
|
||||
|
||||
def poster(video: Path, at: float, out: Path) -> None:
|
||||
run(["-ss", f"{at:.2f}", "-i", video, "-frames:v", "1", "-q:v", "2", out])
|
||||
|
||||
|
||||
def teaser_webp(clips: list[Path], durations: list[float], out: Path, width: int = 960, fps: int = 15,
|
||||
budget_mb: float = 4.0, transition: float = 0.35) -> int:
|
||||
"""A looping animated WebP of the highlight clips (README: plays inline where an MP4 wouldn't). Lowers the
|
||||
quality until it fits `budget_mb`. Returns the quality used."""
|
||||
graph, label = xfade_graph(durations, transition)
|
||||
graph = graph.replace("format=yuv420p[vout]", f"fps={fps},scale={width}:-2:flags=lanczos[vout]")
|
||||
args = []
|
||||
for c in clips:
|
||||
args += ["-i", c]
|
||||
quality = 72
|
||||
while True:
|
||||
run([*args, "-filter_complex", graph, "-map", label, "-an", "-c:v", "libwebp_anim", "-lossless", "0",
|
||||
"-quality", quality, "-compression_level", "6", "-loop", "0", out])
|
||||
if out.stat().st_size <= budget_mb * 1e6 or quality <= 30:
|
||||
return quality
|
||||
quality -= 8
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ cards and captions
|
||||
|
||||
def theme_colors(name: str = "portal") -> dict:
|
||||
from frameport.ui import theme as T
|
||||
|
||||
T.set_theme(name)
|
||||
return {k: getattr(T, k) for k in ("BG", "SURFACE", "SURFACE_2", "BORDER", "TEXT", "TEXT_2", "TEXT_3", "ACCENT",
|
||||
"SECONDARY")}
|
||||
|
||||
|
||||
FONT_CSS = ('<link rel="preconnect" href="https://fonts.gstatic.com">'
|
||||
'<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;900&display=block" '
|
||||
'rel="stylesheet">')
|
||||
FONT = "'Roboto', 'Segoe UI', system-ui, sans-serif"
|
||||
|
||||
|
||||
def caption_html(title: str, subtitle: str, c: dict, left: int = 372, bottom: int = 56) -> str:
|
||||
"""A lower third: a dark glass panel with a blue→orange edge (the logo's two portals), title + one line."""
|
||||
e = html.escape
|
||||
return f"""<!doctype html><html><head><meta charset="utf-8">{FONT_CSS}<style>
|
||||
html,body{{margin:0;width:{SIZE[0]}px;height:{SIZE[1]}px;background:transparent;font-family:{FONT}}}
|
||||
.cap{{position:absolute;left:{left}px;bottom:{bottom}px;max-width:1180px;padding:26px 40px 28px 44px;
|
||||
border-radius:22px;background:rgba(12,14,20,.86);box-shadow:0 18px 50px rgba(0,0,0,.55),
|
||||
inset 0 0 0 1px rgba(255,255,255,.08);overflow:hidden}}
|
||||
.cap:before{{content:"";position:absolute;left:0;top:0;bottom:0;width:8px;
|
||||
background:linear-gradient(180deg,{c['SECONDARY']},{c['ACCENT']})}}
|
||||
h1{{margin:0;font-size:46px;font-weight:700;color:{c['TEXT']};letter-spacing:-.3px}}
|
||||
p{{margin:10px 0 0;font-size:28px;font-weight:400;color:{c['TEXT_2']}}}
|
||||
</style></head><body><div class="cap"><h1>{e(title)}</h1>{f'<p>{e(subtitle)}</p>' if subtitle else ''}</div>
|
||||
</body></html>"""
|
||||
|
||||
|
||||
def card_html(title: str, subtitle: str, footer: str, logo_svg: str, c: dict) -> str:
|
||||
"""A full-screen card: the logo, the two-colour wordmark, a line, a footer; a soft portal glow behind."""
|
||||
e = html.escape
|
||||
word = ('<span style="color:{a}">Frame</span><span style="color:{b}">Port</span>'
|
||||
.format(a=c["ACCENT"], b=c["SECONDARY"])) if title == "FramePort" else e(title)
|
||||
return f"""<!doctype html><html><head><meta charset="utf-8">{FONT_CSS}<style>
|
||||
html,body{{margin:0;width:{SIZE[0]}px;height:{SIZE[1]}px;background:{c['BG']};font-family:{FONT};overflow:hidden}}
|
||||
.glow{{position:absolute;inset:0;
|
||||
background:radial-gradient(ellipse 46% 52% at 42% 50%,{c['SECONDARY']}33,transparent 70%),
|
||||
radial-gradient(ellipse 46% 52% at 58% 50%,{c['ACCENT']}2e,transparent 70%)}}
|
||||
.wrap{{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center}}
|
||||
.logo{{width:220px;height:220px;filter:drop-shadow(0 18px 40px rgba(0,0,0,.6))}}
|
||||
.logo svg{{width:100%;height:100%}}
|
||||
h1{{margin:34px 0 0;font-size:112px;font-weight:900;letter-spacing:-2px;color:{c['TEXT']}}}
|
||||
p{{margin:18px 0 0;font-size:38px;color:{c['TEXT_2']};font-weight:400}}
|
||||
.foot{{position:absolute;bottom:64px;left:0;right:0;text-align:center;font-size:26px;color:{c['TEXT_3']}}}
|
||||
</style></head><body><div class="glow"></div><div class="wrap"><div class="logo">{logo_svg}</div>
|
||||
<h1>{word}</h1><p>{e(subtitle)}</p></div><div class="foot">{e(footer)}</div></body></html>"""
|
||||
|
||||
|
||||
def step_card_html(card: dict, c: dict) -> str:
|
||||
"""An instruction card for what happens outside FramePort (a download, a command on the Frame): an eyebrow
|
||||
(where you are), a heading, numbered steps, an optional command in a terminal box and a note. Steps and the note
|
||||
may mark words **bold** (a button or menu name)."""
|
||||
e = html.escape
|
||||
|
||||
def rich(text: str) -> str:
|
||||
return re.sub(r"\*\*(.+?)\*\*", r"<b>\1</b>", e(text))
|
||||
steps = "".join(f'<li><span class="n">{i}</span><span>{rich(s)}</span></li>'
|
||||
for i, s in enumerate(card.get("steps") or [], 1))
|
||||
code = (f'<div class="code"><span class="prompt">$</span>{e(card["code"])}</div>' if card.get("code") else "")
|
||||
return f"""<!doctype html><html><head><meta charset="utf-8">{FONT_CSS}<style>
|
||||
html,body{{margin:0;width:{SIZE[0]}px;height:{SIZE[1]}px;background:{c['BG']};font-family:{FONT};overflow:hidden}}
|
||||
.glow{{position:absolute;inset:0;
|
||||
background:radial-gradient(ellipse 40% 55% at 12% 30%,{c['SECONDARY']}26,transparent 70%),
|
||||
radial-gradient(ellipse 45% 55% at 92% 80%,{c['ACCENT']}22,transparent 70%)}}
|
||||
.wrap{{position:absolute;left:180px;right:180px;top:0;bottom:0;display:flex;flex-direction:column;
|
||||
justify-content:center;gap:30px}}
|
||||
.eyebrow{{font:600 26px/1 'Roboto Mono','Consolas',monospace;letter-spacing:3px;text-transform:uppercase;
|
||||
color:{c['ACCENT']}}}
|
||||
h1{{margin:0;font-size:76px;font-weight:700;letter-spacing:-1px;color:{c['TEXT']};line-height:1.08}}
|
||||
.line{{margin:0;font-size:34px;color:{c['TEXT_2']};max-width:1400px;line-height:1.35}}
|
||||
ol{{list-style:none;margin:8px 0 0;padding:0;display:flex;flex-direction:column;gap:22px}}
|
||||
li{{display:flex;gap:26px;align-items:baseline;font-size:36px;color:{c['TEXT']};line-height:1.35}}
|
||||
li b{{color:{c['ACCENT']};font-weight:700}}
|
||||
.n{{flex:none;width:56px;height:56px;border-radius:50%;display:inline-flex;align-items:center;
|
||||
justify-content:center;font-weight:700;font-size:28px;color:{c['TEXT']};position:relative;top:-4px;
|
||||
background:linear-gradient(135deg,{c['SECONDARY']}66,{c['ACCENT']}88)}}
|
||||
.code{{margin-top:6px;align-self:flex-start;max-width:100%;padding:26px 36px;border-radius:18px;
|
||||
background:#05060A;border:2px solid {c['BORDER']};font:500 40px/1.3 'Roboto Mono','Consolas',monospace;
|
||||
color:#E8F1FF;box-shadow:0 20px 60px rgba(0,0,0,.5)}}
|
||||
.prompt{{color:{c['SECONDARY']};margin-right:22px}}
|
||||
.note{{margin:0;font-size:26px;color:{c['TEXT_3']};max-width:1400px}}
|
||||
.note b{{color:{c['TEXT_2']}}}
|
||||
.brand{{position:absolute;left:180px;bottom:54px;font-size:26px;font-weight:900;letter-spacing:-.3px}}
|
||||
</style></head><body><div class="glow"></div><div class="wrap">
|
||||
{f'<div class="eyebrow">{e(card["eyebrow"])}</div>' if card.get("eyebrow") else ''}
|
||||
<h1>{e(card["heading"])}</h1>
|
||||
{f'<p class="line">{rich(card["line"])}</p>' if card.get("line") else ''}
|
||||
{f'<ol>{steps}</ol>' if steps else ''}{code}
|
||||
{f'<p class="note">{rich(card["note"])}</p>' if card.get("note") else ''}
|
||||
</div><div class="brand"><span style="color:{c['ACCENT']}">Frame</span><span style="color:{c['SECONDARY']}">Port</span>
|
||||
</div></body></html>"""
|
||||
|
||||
|
||||
def render_card(playwright, page_html: str, out: Path, transparent: bool = False) -> Path:
|
||||
"""Render an HTML card to a PNG at the video size (fonts loaded first)."""
|
||||
browser = playwright.chromium.launch()
|
||||
try:
|
||||
page = browser.new_page(viewport={"width": SIZE[0], "height": SIZE[1]})
|
||||
page.set_content(page_html, wait_until="networkidle")
|
||||
page.evaluate("document.fonts.ready")
|
||||
page.screenshot(path=str(out), omit_background=transparent)
|
||||
finally:
|
||||
browser.close()
|
||||
return out
|
||||
@@ -0,0 +1,337 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Record the showcase videos (docs/showcase/videos/<name>.yaml): the real GUI on the demo library with a pretend
|
||||
Frame, driven like a person would (a drawn pointer on eased paths), filmed with Chrome's screencast; then each scene
|
||||
captioned, instruction cards rendered for what happens outside FramePort (a download, a command on the Frame), title
|
||||
and end cards added and everything joined with crossfades.
|
||||
|
||||
python scripts/showcase/record_video.py # every video
|
||||
python scripts/showcase/record_video.py tour install # some
|
||||
python scripts/showcase/record_video.py install --draft # quick 720p check of a storyboard edit (work dir only)
|
||||
python scripts/showcase/record_video.py /tmp/my-demo.yaml # a storyboard file anywhere (its output may
|
||||
# be any .mp4 path: demos, not docs)
|
||||
python scripts/showcase/record_video.py --changed-since <git rev> # the ones whose storyboard (or this code)
|
||||
# changed since then (CI)
|
||||
|
||||
Each video writes its `output` MP4 (+ .jpg poster) and, when it has `teaser` parts, its teaser WebP; a video.json
|
||||
timeline goes next to the work files (--work). --names prints what can be clicked after each scene, --scenes records
|
||||
only some scenes (with --draft). SHOWCASE_DEBUG=1 prints every step with its start time. See docs/SHOWCASE.md.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
REPO = HERE.parents[1]
|
||||
sys.path[:0] = [str(HERE.parent), str(REPO / "src")]
|
||||
|
||||
from showcase import demo_home # noqa: E402
|
||||
|
||||
VIDEOS = REPO / "docs" / "showcase" / "videos"
|
||||
VIDEO_KEYS = {"output", "teaser", "budget_mb", "poster_at", "start", "setup", "vars", "title", "end", "scenes"}
|
||||
START_KEYS = {"profile", "frame", "stream", "route"}
|
||||
SCENE_KEYS = {"name", "caption", "teaser", "hold", "steps", "card", "seconds"}
|
||||
CARD_KEYS = {"eyebrow", "heading", "line", "steps", "code", "note"}
|
||||
VIEWPORT = (1440, 810) # the layout size; filmed at 4/3 device pixels = 1920x1080
|
||||
TEASER_MB = 4.0
|
||||
|
||||
|
||||
def video_names() -> list[str]:
|
||||
return sorted(p.stem for p in VIDEOS.glob("*.yaml"))
|
||||
|
||||
|
||||
def load_video(name: str) -> dict:
|
||||
"""A storyboard, checked (StepError for anything malformed: before a recording starts, and in the tests)."""
|
||||
import yaml
|
||||
|
||||
from showcase import steps
|
||||
|
||||
path = Path(name) if name.endswith(".yaml") else VIDEOS / f"{name}.yaml" # (or a storyboard file anywhere)
|
||||
where = path.name if name.endswith(".yaml") else f"videos/{name}.yaml"
|
||||
data = yaml.safe_load(path.read_text())
|
||||
unknown = set(data) - VIDEO_KEYS
|
||||
if unknown:
|
||||
raise steps.StepError(f"{where}: unknown key(s) {sorted(unknown)}")
|
||||
if not str(data.get("output") or "").endswith(".mp4"):
|
||||
raise steps.StepError(f"{where}: output must be an .mp4 path")
|
||||
if data.get("teaser") is not None and not str(data["teaser"]).endswith(".webp"):
|
||||
raise steps.StepError(f"{where}: teaser must be a .webp path")
|
||||
start = data.get("start") or {}
|
||||
if set(start) - START_KEYS:
|
||||
raise steps.StepError(f"{where}: start: unknown key(s) {sorted(set(start) - START_KEYS)}")
|
||||
if start.get("profile", "demo") not in demo_home.PROFILES:
|
||||
raise steps.StepError(f"{where}: start.profile is one of {', '.join(demo_home.PROFILES)}")
|
||||
if start.get("frame", "connected") not in ("connected", "disconnected"):
|
||||
raise steps.StepError(f"{where}: start.frame is connected or disconnected")
|
||||
if start.get("stream", "live") not in ("live", "frozen"):
|
||||
raise steps.StepError(f"{where}: start.stream is live or frozen")
|
||||
steps.validate(data.get("setup") or [], f"{where} setup")
|
||||
seen = set()
|
||||
for sc in data.get("scenes") or []:
|
||||
name_ = sc.get("name")
|
||||
if not name_ or name_ in seen:
|
||||
raise steps.StepError(f"{where}: missing or repeated scene name {name_!r}")
|
||||
seen.add(name_)
|
||||
if set(sc) - SCENE_KEYS:
|
||||
raise steps.StepError(f"{where}: {name_}: unknown key(s) {sorted(set(sc) - SCENE_KEYS)}")
|
||||
if "card" in sc: # an instruction card: rendered, not filmed
|
||||
card = sc["card"]
|
||||
if not isinstance(card, dict) or not card.get("heading") or set(card) - CARD_KEYS:
|
||||
raise steps.StepError(f"{where}: {name_}: card needs a heading (keys: {', '.join(sorted(CARD_KEYS))})")
|
||||
if "steps" in sc or "caption" in sc or "teaser" in sc:
|
||||
raise steps.StepError(f"{where}: {name_}: a card scene has no steps, caption or teaser")
|
||||
if not isinstance(sc.get("seconds", 5), (int, float)) or sc.get("seconds", 5) <= 0:
|
||||
raise steps.StepError(f"{where}: {name_}: seconds must be positive")
|
||||
continue
|
||||
cap = sc.get("caption")
|
||||
if cap is not None and not (isinstance(cap, list) and 1 <= len(cap) <= 2):
|
||||
raise steps.StepError(f"{where}: {name_}: caption is [title] or [title, line]")
|
||||
teaser = sc.get("teaser")
|
||||
if teaser is not None and not (isinstance(teaser, list) and len(teaser) == 2 and teaser[1] > 0):
|
||||
raise steps.StepError(f"{where}: {name_}: teaser is [from, seconds]")
|
||||
steps.validate(sc.get("steps") or [], f"{where} {name_}")
|
||||
if not seen:
|
||||
raise steps.StepError(f"{where}: no scenes")
|
||||
for card in ("title", "end"):
|
||||
if not (data.get(card) or {}).get("heading"):
|
||||
raise steps.StepError(f"{where}: {card} needs a heading")
|
||||
return data
|
||||
|
||||
|
||||
def changed_videos(since: str) -> list[str]:
|
||||
"""The videos to record again after the commits since `since`: all when the recorder or the step language
|
||||
changed, else the ones whose storyboard changed."""
|
||||
out = subprocess.run(["git", "diff", "--name-only", since, "HEAD"], cwd=REPO, capture_output=True, text=True)
|
||||
if out.returncode != 0:
|
||||
return video_names() # (unknown base, e.g. a new branch): everything
|
||||
files = out.stdout.split()
|
||||
if any(f.startswith("scripts/showcase/") for f in files):
|
||||
return video_names()
|
||||
return sorted({Path(f).stem for f in files if f.startswith("docs/showcase/videos/") and f.endswith(".yaml")}
|
||||
& set(video_names()))
|
||||
|
||||
|
||||
def video_installs(session, pace: float = 0.5) -> None:
|
||||
"""Installs in a video run the scripted job (every real stage, nothing built or sent) through the real queue,
|
||||
and leave the game installed on the pretend Frame."""
|
||||
from frameport.core import library
|
||||
from showcase import fakes
|
||||
|
||||
app = session.app
|
||||
|
||||
def submit(pkg: str, to: str = "frame"):
|
||||
script = fakes.install_job(pkg, pace)
|
||||
|
||||
def run(job):
|
||||
message = script(job)
|
||||
g = library.game(pkg)
|
||||
if app.target is not None and g:
|
||||
app.target.games.append(fakes.FakeTarget._record(g))
|
||||
app.frame_info = app.target.describe()
|
||||
now = time.time()
|
||||
library.upsert_game(pkg, installs={"frame": {"result": {"ok": True}, "time": now}},
|
||||
last_test={"state": "RUNNING", "verdict": "pass", "milestone": "Submitting frames",
|
||||
"fps": 72.0, "findings": [], "suggestions": [], "time": now,
|
||||
"target": "frame"})
|
||||
return message
|
||||
return app.submit(f"Install {app._title(pkg)} on Frame", run, pkg, "install", to="frame")
|
||||
app._submit_install = submit
|
||||
|
||||
|
||||
def print_names(session, scene: str) -> None:
|
||||
names = sorted({(n["label"] or n["text"] or n["all"].splitlines()[-1] if n["all"] else "")[:60]
|
||||
for n in session.nodes() if n["tappable"]} - {""})
|
||||
print(f"NAMES after {scene}: {names}", flush=True)
|
||||
|
||||
|
||||
def record(name: str, args) -> int:
|
||||
"""Record one video in this process."""
|
||||
video = load_video(name)
|
||||
start = video.get("start") or {}
|
||||
scenes = video["scenes"]
|
||||
if args.scenes:
|
||||
want = args.scenes.split(",")
|
||||
scenes = [s for s in scenes if s["name"] in want]
|
||||
stem = Path(name).stem
|
||||
work = (args.work / stem) if args.work else Path(tempfile.mkdtemp(prefix=f"fp-video-{stem}-"))
|
||||
work.mkdir(parents=True, exist_ok=True)
|
||||
home = (args.home / stem) if args.home else Path(tempfile.mkdtemp(prefix="fp-video-home-"))
|
||||
demo_home.build_for_render(home, offline=args.offline, allow_missing_art=args.allow_missing_art,
|
||||
profile=start.get("profile", "demo"))
|
||||
|
||||
from showcase import postprod, steps
|
||||
from showcase.fakes import FrozenMonitorSession, LiveMonitorSession
|
||||
from showcase.web import Screencast, Server
|
||||
|
||||
variables = video.get("vars") or {}
|
||||
started = time.monotonic()
|
||||
step_log = (lambda msg: print(f"{time.monotonic() - started:7.1f} {msg}", flush=True)) \
|
||||
if os.environ.get("SHOWCASE_DEBUG") else None
|
||||
|
||||
def script(server) -> int:
|
||||
scale = 1.0 if args.draft else 4 / 3
|
||||
s = server.session(VIEWPORT, cursor=True, device_scale=scale)
|
||||
video_installs(s)
|
||||
if start.get("frame") == "disconnected":
|
||||
steps.HOOKS["disconnect"](s)
|
||||
steps.run(s, video.get("setup") or [], variables, log=step_log) # before filming: a failure stops here
|
||||
s.app.go(start.get("route", "library"))
|
||||
s.sleep(2.5)
|
||||
s.park()
|
||||
cast = Screencast(s, work / "frames", quality=80 if args.draft else 92)
|
||||
cast.start()
|
||||
s.sleep(0.8)
|
||||
timeline = []
|
||||
for sc in scenes:
|
||||
if "card" in sc: # rendered later: nothing to film
|
||||
timeline.append({"name": sc["name"], "card": True, "seconds": sc.get("seconds", 5)})
|
||||
continue
|
||||
t0 = time.time()
|
||||
print(f"SCENE {sc['name']}", flush=True)
|
||||
try:
|
||||
steps.run(s, sc.get("steps") or [], variables, log=step_log)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
server.errors.append(f"scene {sc['name']}: {exc!r}")
|
||||
s.sleep(sc.get("hold", 0.6))
|
||||
timeline.append({"name": sc["name"], "start": t0, "end": time.time()})
|
||||
if args.names:
|
||||
print_names(s, sc["name"])
|
||||
cast.stop()
|
||||
cast.write_index()
|
||||
s.close()
|
||||
return produce(server, timeline)
|
||||
|
||||
def produce(server, timeline) -> int:
|
||||
size = (1280, 720) if args.draft else postprod.SIZE
|
||||
filmed = [t for t in timeline if not t.get("card")]
|
||||
raw = work / "raw.mp4"
|
||||
first = postprod.frames_to_video(work / "frames", raw, end=filmed[-1]["end"], size=size) if filmed else 0
|
||||
colors = postprod.theme_colors("portal")
|
||||
logo = (REPO / "src" / "frameport" / "ui" / "icons" / "logo.svg").read_text()
|
||||
cards = work / "cards"
|
||||
cards.mkdir(exist_ok=True)
|
||||
|
||||
def end_card(which: str) -> tuple[Path, float]:
|
||||
c = video[which]
|
||||
png = postprod.render_card(server.playwright, postprod.card_html(
|
||||
c["heading"], c.get("line", ""), c.get("footer", ""), logo, colors), cards / f"{which}.png")
|
||||
clip = work / f"{which}.mp4"
|
||||
postprod.card_clip(png, c.get("seconds", 3.0), clip)
|
||||
return clip, c.get("seconds", 3.0)
|
||||
|
||||
clip, secs = end_card("title")
|
||||
clips, durations, scene_clips = [clip], [secs], {}
|
||||
by_name = {sc["name"]: sc for sc in scenes}
|
||||
for item in timeline:
|
||||
sc = by_name[item["name"]]
|
||||
if item.get("card"):
|
||||
png = postprod.render_card(server.playwright, postprod.step_card_html(sc["card"], colors),
|
||||
cards / f"card-{sc['name']}.png")
|
||||
clip = work / f"card-{sc['name']}.mp4"
|
||||
postprod.card_clip(png, item["seconds"], clip, zoom=0.015)
|
||||
clips.append(clip)
|
||||
durations.append(item["seconds"])
|
||||
continue
|
||||
start_s, length = item["start"] - first, item["end"] - item["start"]
|
||||
cap = None
|
||||
if sc.get("caption"):
|
||||
title, line = (sc["caption"] + [""])[:2]
|
||||
cap = postprod.render_card(server.playwright, postprod.caption_html(title, line, colors),
|
||||
cards / f"cap-{sc['name']}.png", transparent=True)
|
||||
clip = work / f"scene-{sc['name']}.mp4"
|
||||
postprod.cut_scene(raw, max(0.0, start_s), length, cap, clip, size=size)
|
||||
clips.append(clip)
|
||||
durations.append(length)
|
||||
scene_clips[sc["name"]] = (clip, length)
|
||||
item.update(clip_start=round(start_s, 3), seconds=round(length, 3))
|
||||
clip, secs = end_card("end")
|
||||
clips.append(clip)
|
||||
durations.append(secs)
|
||||
transition = 0.25 if args.draft else 0.5
|
||||
if args.draft:
|
||||
out = work / f"{stem}-draft.mp4"
|
||||
postprod.join(clips, durations, out, transition=transition, crf=28, size=size)
|
||||
crf = 28
|
||||
else:
|
||||
out = REPO / video["output"]
|
||||
out.parent.mkdir(parents=True, exist_ok=True)
|
||||
crf = postprod.encode_within(clips, durations, out, float(video.get("budget_mb", 12)))
|
||||
postprod.poster(out, durations[0] + float(video.get("poster_at", 1.5)), out.with_suffix(".jpg"))
|
||||
parts, lengths = [], []
|
||||
for sc in scenes: # the teaser: each scene's `teaser` part (with its caption)
|
||||
if sc.get("teaser") and sc["name"] in scene_clips:
|
||||
frm, secs = sc["teaser"]
|
||||
part = work / f"teaser-{sc['name']}.mp4"
|
||||
postprod.run(["-ss", f"{frm:.2f}", "-t", f"{secs:.2f}", "-i", scene_clips[sc["name"]][0],
|
||||
"-an", "-c:v", "libx264", "-preset", "veryfast", "-crf", "14", part])
|
||||
parts.append(part)
|
||||
lengths.append(secs)
|
||||
if parts and video.get("teaser"):
|
||||
teaser = REPO / video["teaser"]
|
||||
teaser.parent.mkdir(parents=True, exist_ok=True)
|
||||
q = postprod.teaser_webp(parts, lengths, teaser, budget_mb=TEASER_MB)
|
||||
print(f"TEASER {teaser} ({teaser.stat().st_size / 1e6:.2f} MB, quality {q})", flush=True)
|
||||
# where each scene starts in the finished video (chapters)
|
||||
at = durations[0] - transition
|
||||
for item, d in zip(timeline, durations[1:-1], strict=True):
|
||||
item["at"] = round(at, 2)
|
||||
at += d - transition
|
||||
total = postprod.joined_length(durations, transition)
|
||||
(work / "video.json").write_text(json.dumps({"video": name, "scenes": timeline, "seconds": round(total, 2),
|
||||
"crf": crf, "output": str(out)}, indent=1))
|
||||
print(f"VIDEO {name}: {out} ({out.stat().st_size / 1e6:.2f} MB, {total:.1f} s, crf {crf}); work: {work}",
|
||||
flush=True)
|
||||
return 0
|
||||
|
||||
stream = FrozenMonitorSession if start.get("stream") == "frozen" else LiveMonitorSession
|
||||
return Server(monitor_session=stream).run(script)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
ap = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
|
||||
ap.add_argument("videos", nargs="*", help=f"video names (default: all of {', '.join(video_names())})")
|
||||
ap.add_argument("--changed-since", default=None, help="only videos whose storyboard (or the recorder) changed "
|
||||
"since this git revision")
|
||||
ap.add_argument("--scenes", default=None, help="comma-separated scene names (one video)")
|
||||
ap.add_argument("--draft", action="store_true", help="720p, quick, no teaser; nothing written to docs/")
|
||||
ap.add_argument("--names", action="store_true", help="print the clickable names after each scene")
|
||||
ap.add_argument("--work", type=Path, default=None, help="folder for frames and clips (<work>/<video>)")
|
||||
ap.add_argument("--home", type=Path, default=None, help="demo data dirs (<home>/<video>; default: temp)")
|
||||
ap.add_argument("--offline", action="store_true", help="use only cached art")
|
||||
ap.add_argument("--allow-missing-art", action="store_true", help="render even when a game got no art")
|
||||
args = ap.parse_args()
|
||||
names = args.videos or (changed_videos(args.changed_since) if args.changed_since else video_names())
|
||||
unknown = {n for n in names if not (n.endswith(".yaml") and Path(n).is_file())} - set(video_names())
|
||||
if unknown:
|
||||
print(f"unknown video(s): {sorted(unknown)} (known: {', '.join(video_names())})", file=sys.stderr)
|
||||
return 2
|
||||
for name in names:
|
||||
load_video(name) # every storyboard checked before anything is recorded
|
||||
if not names:
|
||||
print("no video to record", flush=True)
|
||||
return 0
|
||||
if len(names) == 1:
|
||||
return record(names[0], args)
|
||||
# one process per video: each builds its own demo data dir (the app reads it per process)
|
||||
failed = []
|
||||
passed = [*(["--draft"] if args.draft else []), *(["--names"] if args.names else []),
|
||||
*(["--offline"] if args.offline else []), *(["--allow-missing-art"] if args.allow_missing_art else []),
|
||||
*(["--work", str(args.work)] if args.work else []), *(["--home", str(args.home)] if args.home else [])]
|
||||
for name in names:
|
||||
cmd = [sys.executable, __file__, name, *passed]
|
||||
print(f"RECORD {name}", flush=True)
|
||||
if subprocess.run(cmd).returncode != 0:
|
||||
failed.append(name)
|
||||
if failed:
|
||||
print(f"failed: {', '.join(failed)}", file=sys.stderr)
|
||||
return 1 if failed else 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,262 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Render the docs screenshots (docs/showcase/shots.yaml) from the demo library with a pretend Frame, and write each
|
||||
into docs/images/ only when the picture really changed (anti-aliasing noise doesn't count).
|
||||
|
||||
python scripts/showcase/render_docs.py [--only library,game] [--check] [--out docs/images] [--offline]
|
||||
|
||||
--check renders into a temp folder and exits 1 if any docs image is out of date (CI). Needs the dev extras
|
||||
(flet-web, playwright + `playwright install chromium`). See docs/SHOWCASE.md.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
REPO = HERE.parents[1]
|
||||
sys.path[:0] = [str(HERE.parent), str(REPO / "src")]
|
||||
|
||||
from showcase import demo_home # noqa: E402
|
||||
|
||||
MANIFEST = REPO / "docs" / "showcase" / "shots.yaml"
|
||||
IMAGES = REPO / "docs" / "images"
|
||||
SHOT_KEYS = {"name", "docs", "steps", "viewport", "scale", "crop"}
|
||||
# a picture counts as changed when the mean difference per channel exceeds MEAN_LIMIT (0-255 scale) or more than
|
||||
# PIXEL_SHARE of its pixels differ by more than PIXEL_LIMIT in some channel. Measured: run-to-run noise (the live
|
||||
# card's sparkline) stays under 0.007 % of the pixels; the smallest real change seen (the sidebar card showing
|
||||
# another game) is 0.12 %
|
||||
MEAN_LIMIT, PIXEL_LIMIT, PIXEL_SHARE = 0.5, 24, 0.0004
|
||||
ATTEMPTS = 2 # a shot whose steps fail (e.g. the window never connected) is tried once more in a fresh window
|
||||
|
||||
|
||||
def load_manifest(path: Path = MANIFEST) -> dict:
|
||||
import yaml
|
||||
|
||||
from showcase import steps
|
||||
|
||||
data = yaml.safe_load(path.read_text())
|
||||
names = set()
|
||||
for shot in data.get("shots") or []:
|
||||
name = shot.get("name")
|
||||
if not name or not re.fullmatch(r"[a-z0-9-]+", name):
|
||||
raise steps.StepError(f"shots.yaml: bad shot name {name!r}")
|
||||
if name in names:
|
||||
raise steps.StepError(f"shots.yaml: {name} is listed twice")
|
||||
names.add(name)
|
||||
unknown = set(shot) - SHOT_KEYS
|
||||
if unknown:
|
||||
raise steps.StepError(f"shots.yaml: {name}: unknown key(s) {sorted(unknown)}")
|
||||
steps.validate(shot.get("steps") or [], f"shots.yaml {name}")
|
||||
crop = shot.get("crop")
|
||||
placed = "anchor" in (crop or {}) or {"x", "y"} <= set(crop or {})
|
||||
if crop and crop.get("dialog"):
|
||||
continue
|
||||
if crop is not None and not ({"width", "height"} <= set(crop) and placed):
|
||||
raise steps.StepError(f"shots.yaml: {name}: crop needs width, height and an anchor or x/y")
|
||||
return data
|
||||
|
||||
|
||||
def changed(old: Path, new: Path) -> bool:
|
||||
"""Whether `new` differs visibly from `old` (a missing or differently sized old picture counts as changed)."""
|
||||
from PIL import Image, ImageChops, ImageStat
|
||||
|
||||
if not old.exists():
|
||||
return True
|
||||
with Image.open(old) as a, Image.open(new) as b:
|
||||
if a.size != b.size:
|
||||
return True
|
||||
diff = ImageChops.difference(a.convert("RGB"), b.convert("RGB"))
|
||||
if max(ImageStat.Stat(diff).mean) > MEAN_LIMIT:
|
||||
return True
|
||||
strong = diff.convert("L").point(lambda v: 255 if v > PIXEL_LIMIT else 0)
|
||||
share = ImageStat.Stat(strong).mean[0] / 255
|
||||
return share > PIXEL_SHARE
|
||||
|
||||
|
||||
def optimise(path: Path) -> None:
|
||||
from PIL import Image
|
||||
|
||||
with Image.open(path) as im:
|
||||
im.load()
|
||||
im.convert("RGB").save(path, "PNG", optimize=True)
|
||||
|
||||
|
||||
def privacy_problems(home: Path) -> list[str]:
|
||||
"""Anything in the demo data dir that looks like someone's own data: this machine's home folder or user name, the
|
||||
real data dir, IP addresses (version numbers like 1.4.0.0 aside: only private/public ranges with a non-zero last
|
||||
part that aren't a known version are reported)."""
|
||||
needles = {str(Path.home()), str(demo_home.real_data_dir())}
|
||||
user = os.environ.get("USER") or os.environ.get("USERNAME")
|
||||
found = []
|
||||
ip = re.compile(r"(?<![\d.])(?:10|172|192|100)\.\d{1,3}\.\d{1,3}\.\d{1,3}(?![\d.])")
|
||||
for f in home.rglob("*"):
|
||||
if not f.is_file() or f.suffix.lower() not in (".json", ".txt", ".yaml", ".yml", ".conf", ".log", ""):
|
||||
continue
|
||||
try:
|
||||
text = f.read_text(errors="ignore")
|
||||
except OSError:
|
||||
continue
|
||||
rel = f.relative_to(home)
|
||||
for n in needles:
|
||||
if n and n in text.replace(str(home), ""):
|
||||
found.append(f"{rel}: contains {n}")
|
||||
if user and len(user) > 2 and re.search(rf"\b{re.escape(user)}\b", text.replace(str(home), "")):
|
||||
found.append(f"{rel}: contains the user name {user!r}")
|
||||
for m in ip.findall(text):
|
||||
found.append(f"{rel}: IP address {m}")
|
||||
return found
|
||||
|
||||
|
||||
def crop_box(session, crop: dict):
|
||||
from showcase.web import Box
|
||||
|
||||
if crop.get("dialog"):
|
||||
d, pad = session.dialog(), crop.get("pad", 0)
|
||||
return Box(d.x - pad, d.y - pad, d.w + 2 * pad, d.h + 2 * pad)
|
||||
if "anchor" in crop:
|
||||
a = session.find(crop["anchor"], timeout=10)
|
||||
return Box(a.x + crop.get("left", 0), a.y + crop.get("top", 0), crop["width"], crop["height"])
|
||||
return Box(crop["x"], crop["y"], crop["width"], crop["height"])
|
||||
|
||||
|
||||
def render(shots: list[dict], variables: dict, defaults: dict, out: Path, log=print, verify: bool = True):
|
||||
"""A script for web.Server.run: renders every shot into out/<name>.png."""
|
||||
from showcase import steps
|
||||
|
||||
def one(server, shot: dict, path: Path) -> None:
|
||||
"""Render one shot. Any failing step raises: no picture is taken of a page that didn't get where the steps
|
||||
lead (a window that never connected once produced an empty, unconnected Library)."""
|
||||
vw, vh = shot.get("viewport") or defaults.get("viewport") or (1280, 820)
|
||||
s = server.session((vw, vh))
|
||||
try:
|
||||
steps.run(s, shot.get("steps") or [], variables)
|
||||
s.park(away=True)
|
||||
box = crop_box(s, steps.substitute(shot["crop"], variables)) if shot.get("crop") else None
|
||||
s.shot(path, clip=box)
|
||||
finally:
|
||||
s.close()
|
||||
|
||||
def attempt(server, shot: dict, path: Path) -> bool:
|
||||
"""One render into `path` (a failing step: one more try in a fresh window). False when both failed."""
|
||||
for n in range(1, ATTEMPTS + 1):
|
||||
try:
|
||||
one(server, shot, path)
|
||||
return True
|
||||
except Exception as exc: # noqa: BLE001
|
||||
path.unlink(missing_ok=True)
|
||||
if n < ATTEMPTS:
|
||||
log(f"RETRY {shot['name']}: {exc!r}")
|
||||
else:
|
||||
server.errors.append(f"{shot['name']}: {exc!r}")
|
||||
return False
|
||||
|
||||
def script(server) -> int:
|
||||
"""Every shot is rendered twice, each in a fresh window, and kept only when both agree: the headless GPU
|
||||
now and then draws a glyph wrong ("7.θ W" for "7.30 W"), a fault the settling can't see. Disagreeing
|
||||
renders get a third: the one two of them match is kept."""
|
||||
failed = 0
|
||||
for shot in shots:
|
||||
t0 = time.monotonic()
|
||||
final = out / f"{shot['name']}.png"
|
||||
takes = []
|
||||
for k in range(3 if verify else 1):
|
||||
path = out / f".take{k}-{shot['name']}.png"
|
||||
if not attempt(server, shot, path):
|
||||
break
|
||||
takes.append(path)
|
||||
if not verify:
|
||||
path.replace(final)
|
||||
break
|
||||
agreed = next((a for i, a in enumerate(takes) for b in takes[i + 1:] if not changed(a, b)), None)
|
||||
if agreed is not None:
|
||||
agreed.replace(final)
|
||||
break
|
||||
else:
|
||||
server.errors.append(f"{shot['name']}: three renders, no two alike (an unstable page?)")
|
||||
for p in takes:
|
||||
p.unlink(missing_ok=True)
|
||||
if final.exists():
|
||||
log(f"SHOT {shot['name']} ({time.monotonic() - t0:.1f} s, {len(takes)} renders)")
|
||||
else:
|
||||
failed += 1
|
||||
return 1 if failed else 0
|
||||
return script
|
||||
|
||||
|
||||
def main() -> int:
|
||||
ap = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
|
||||
ap.add_argument("--only", default=None, help="comma-separated shot names")
|
||||
ap.add_argument("--out", type=Path, default=IMAGES, help="where the images go (default docs/images)")
|
||||
ap.add_argument("--check", action="store_true", help="only report out-of-date images (exit 1 if any)")
|
||||
ap.add_argument("--home", type=Path, default=None, help="demo data dir (default: a temp folder)")
|
||||
ap.add_argument("--offline", action="store_true", help="use only cached art")
|
||||
ap.add_argument("--allow-missing-art", action="store_true", help="render even when a game got no art")
|
||||
ap.add_argument("--keep", type=Path, default=None, help="also keep every raw render in this folder")
|
||||
ap.add_argument("--fast", action="store_true", help="render each shot once (no second render to catch a "
|
||||
"misdrawn glyph); for trying out a manifest edit")
|
||||
args = ap.parse_args()
|
||||
|
||||
manifest = load_manifest()
|
||||
shots = manifest["shots"]
|
||||
if args.only:
|
||||
want = args.only.split(",")
|
||||
unknown = set(want) - {s["name"] for s in shots}
|
||||
if unknown:
|
||||
print(f"unknown shot(s): {sorted(unknown)}", file=sys.stderr)
|
||||
return 2
|
||||
shots = [s for s in shots if s["name"] in want]
|
||||
home = args.home or Path(tempfile.mkdtemp(prefix="fp-showcase-home-"))
|
||||
demo_home.build_for_render(home, offline=args.offline, allow_missing_art=args.allow_missing_art)
|
||||
problems = privacy_problems(home)
|
||||
if problems:
|
||||
print("refusing to render, the demo data contains personal-looking data:\n " + "\n ".join(problems),
|
||||
file=sys.stderr)
|
||||
return 3
|
||||
renders = Path(tempfile.mkdtemp(prefix="fp-showcase-shots-"))
|
||||
status_file = renders / "status.json"
|
||||
|
||||
def finish(server_code: int) -> int:
|
||||
"""After rendering (still in the server's script thread): compare, write, report."""
|
||||
report = {"written": [], "unchanged": [], "missing": [], "changed": []}
|
||||
for shot in shots:
|
||||
new = renders / f"{shot['name']}.png"
|
||||
if not new.exists():
|
||||
report["missing"].append(shot["name"])
|
||||
continue
|
||||
optimise(new)
|
||||
old = args.out / new.name
|
||||
if changed(old, new):
|
||||
report["changed"].append(shot["name"])
|
||||
if not args.check:
|
||||
args.out.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(new, old)
|
||||
report["written"].append(shot["name"])
|
||||
else:
|
||||
report["unchanged"].append(shot["name"])
|
||||
if args.keep:
|
||||
args.keep.mkdir(parents=True, exist_ok=True)
|
||||
for f in renders.glob("*.png"):
|
||||
shutil.copyfile(f, args.keep / f.name)
|
||||
status_file.write_text(json.dumps(report))
|
||||
print("RESULT " + json.dumps(report), flush=True)
|
||||
if report["missing"] or server_code:
|
||||
return 1
|
||||
return 1 if args.check and report["changed"] else 0
|
||||
|
||||
from showcase.web import Server
|
||||
|
||||
script = render(shots, manifest.get("vars") or {}, manifest.get("defaults") or {}, renders, verify=not args.fast)
|
||||
from showcase.fakes import FrozenMonitorSession
|
||||
|
||||
return Server(monitor_session=FrozenMonitorSession).run(lambda server: finish(script(server)))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,390 @@
|
||||
"""The step language shared by the docs screenshots (docs/showcase/shots.yaml) and the demo tour (tour.yaml).
|
||||
|
||||
A step is a one-key mapping. App steps call the app the way its own handlers do; pointer steps move a real (drawn)
|
||||
mouse to things found by name (see web.Session.find); hooks run the pretend Frame's scripted events.
|
||||
|
||||
- go: monitor # a sidebar route (library, frame, files, screenshots, live, keyboard, …)
|
||||
- nav: "Monitor" # click that tab like a person (checked: the page really changed)
|
||||
- open_game: ${game} # or {package: …, advanced: true} = with Customize open
|
||||
- call: {fn: screenshots_view.viewer, args: [0]} # any app method (dotted path from the app)
|
||||
- pop_dialog: true # close the top dialog
|
||||
- theme: original # switch the colour theme live (what Settings → Appearance does)
|
||||
- hover: "Batman" # pointer: a name, {name, nth, dx, dy, exact} or [x, y]
|
||||
- click: "Monitor" # also right_click, double_click
|
||||
- drag: ["Videos", "Documents"] # press on the first target, move through the others, release
|
||||
- clicks: {at: [37, 42], times: 7, gap: 0.22} # quick clicks in one place
|
||||
- type: "arc" # keyboard; press: Escape
|
||||
- scroll: {dy: 600, at: "Patches"}
|
||||
- wait: 1.5 # seconds
|
||||
- wait_for: "Starting on Frame" # until something with that name shows (timeout 15 s)
|
||||
- settle: true # until the picture stops changing
|
||||
- park: true # pointer to a place that hovers nothing
|
||||
- hook: fake_install # or {name: fake_install, args: [${game}]}: see HOOKS
|
||||
|
||||
`${name}` in any string is replaced from the file's `vars:`.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
|
||||
from showcase import fakes
|
||||
|
||||
POINTER = {"hover", "move", "click", "right_click", "double_click"}
|
||||
ACTIONS = POINTER | {"clicks", "nav", "go", "open_game", "call", "pop_dialog", "theme", "drag", "type", "press",
|
||||
"scroll", "wait", "wait_for", "settle", "park", "hook"}
|
||||
|
||||
|
||||
class StepError(ValueError):
|
||||
pass
|
||||
|
||||
|
||||
def substitute(value, variables: dict):
|
||||
"""${name} → variables[name] in every string of a step (a whole-string reference keeps the value's type)."""
|
||||
if isinstance(value, str):
|
||||
m = re.fullmatch(r"\$\{(\w+)\}", value)
|
||||
if m:
|
||||
if m.group(1) not in variables:
|
||||
raise StepError(f"unknown variable ${{{m.group(1)}}}")
|
||||
return variables[m.group(1)]
|
||||
|
||||
def one(m):
|
||||
if m.group(1) not in variables:
|
||||
raise StepError(f"unknown variable ${{{m.group(1)}}}")
|
||||
return str(variables[m.group(1)])
|
||||
return re.sub(r"\$\{(\w+)\}", one, value)
|
||||
if isinstance(value, list):
|
||||
return [substitute(v, variables) for v in value]
|
||||
if isinstance(value, dict):
|
||||
return {k: substitute(v, variables) for k, v in value.items()}
|
||||
return value
|
||||
|
||||
|
||||
def validate(steps, where: str = "steps") -> None:
|
||||
"""Raises StepError for a malformed step list (checked before a render starts, and by the tests)."""
|
||||
if not isinstance(steps, list):
|
||||
raise StepError(f"{where}: a list of steps expected")
|
||||
for i, step in enumerate(steps):
|
||||
at = f"{where}[{i}]"
|
||||
if not isinstance(step, dict) or len(step) != 1:
|
||||
raise StepError(f"{at}: a step is a mapping with exactly one action, got {step!r}")
|
||||
(action, value), = step.items()
|
||||
if action not in ACTIONS:
|
||||
raise StepError(f"{at}: unknown action {action!r} (known: {', '.join(sorted(ACTIONS))})")
|
||||
if action == "hook":
|
||||
name = value.get("name") if isinstance(value, dict) else value
|
||||
if name not in HOOKS:
|
||||
raise StepError(f"{at}: unknown hook {name!r} (known: {', '.join(sorted(HOOKS))})")
|
||||
if action == "call" and not (isinstance(value, str) or isinstance(value, dict) and "fn" in value):
|
||||
raise StepError(f"{at}: call needs a method name or {{fn, args}}")
|
||||
if action == "drag" and not (isinstance(value, list) and len(value) >= 2):
|
||||
raise StepError(f"{at}: drag needs two or more targets")
|
||||
if action in ("wait",) and not isinstance(value, (int, float)):
|
||||
raise StepError(f"{at}: wait needs seconds")
|
||||
|
||||
|
||||
def _resolve(app, dotted: str):
|
||||
obj = app
|
||||
for part in dotted.split("."):
|
||||
obj = getattr(obj, part)
|
||||
return obj
|
||||
|
||||
|
||||
def run(session, steps: list, variables: dict | None = None, log=None) -> None:
|
||||
"""Run the steps on a web.Session. App calls run in this thread (the app serialises its own updates)."""
|
||||
app = session.app
|
||||
for step in substitute(steps, variables or {}):
|
||||
(action, v), = step.items()
|
||||
if log:
|
||||
log(f" {action}: {v}")
|
||||
if action == "go":
|
||||
app.go(v)
|
||||
elif action == "open_game":
|
||||
if isinstance(v, dict):
|
||||
app.open_game(v["package"], advanced=bool(v.get("advanced")))
|
||||
else:
|
||||
app.open_game(v)
|
||||
elif action == "call":
|
||||
fn, args = (v, []) if isinstance(v, str) else (v["fn"], v.get("args") or [])
|
||||
method = _resolve(app, fn)
|
||||
if asyncio.iscoroutinefunction(method): # (e.g. a FilePicker flow): the page's loop runs it
|
||||
app.page.run_task(method, *args)
|
||||
else:
|
||||
method(*args)
|
||||
elif action == "nav":
|
||||
_nav(session, v, log)
|
||||
elif action == "pop_dialog":
|
||||
app.page.pop_dialog()
|
||||
elif action == "theme":
|
||||
from frameport.core import library
|
||||
|
||||
library.set_setting("ui.theme", v)
|
||||
app.restyle(v)
|
||||
elif action in POINTER:
|
||||
if action in ("hover", "move"):
|
||||
session.move(v)
|
||||
elif action == "click":
|
||||
session.click(v)
|
||||
elif action == "right_click":
|
||||
session.click(v, button="right")
|
||||
else:
|
||||
session.click(v)
|
||||
session.sleep(0.08)
|
||||
session.page.mouse.down()
|
||||
session.page.mouse.up()
|
||||
elif action == "clicks": # quick clicks in one place (each shows the click ring)
|
||||
session.move(v["at"])
|
||||
for _ in range(int(v.get("times", 2))):
|
||||
session.sleep(float(v.get("gap", 0.22)))
|
||||
session.page.mouse.down()
|
||||
session.sleep(0.05)
|
||||
session.page.mouse.up()
|
||||
elif action == "drag":
|
||||
session.drag(v)
|
||||
elif action == "type":
|
||||
session.type(v)
|
||||
elif action == "press":
|
||||
session.press(v)
|
||||
elif action == "scroll":
|
||||
session.scroll(v.get("dy", 300), v.get("at"))
|
||||
elif action == "wait":
|
||||
session.sleep(float(v))
|
||||
elif action == "wait_for":
|
||||
session.find(v, timeout=15)
|
||||
elif action == "settle":
|
||||
session.settle(**({} if v is True else {k: w for k, w in v.items() if k in ("timeout",)}))
|
||||
elif action == "park":
|
||||
session.park()
|
||||
elif action == "hook":
|
||||
name, args = (v, []) if isinstance(v, str) else (v["name"], v.get("args") or [])
|
||||
HOOKS[name](session, *args)
|
||||
|
||||
|
||||
def _nav(session, label: str, log=None) -> None:
|
||||
"""Click a sidebar tab like a person, then make sure the page really changed: its heading shows in the content
|
||||
area. A click whose handler died would otherwise leave the old page in the picture for the rest of a recording
|
||||
(seen on CI before property writes took FLET_LOCK; kept as a safety net): then the route is opened directly and
|
||||
a WARN line printed."""
|
||||
from frameport.ui import app as app_module
|
||||
from showcase.web import Box, NotFound
|
||||
|
||||
keys = {str(lbl).casefold(): key for key, lbl, _icon in app_module.NAV}
|
||||
key = keys.get(label.casefold())
|
||||
if key is None:
|
||||
raise StepError(f"nav: {label!r} is not a sidebar tab ({', '.join(sorted(keys))})")
|
||||
session.click(label)
|
||||
vw, _vh = session.viewport
|
||||
content = Box(260, 0, vw - 260, 160) # right of the sidebar, the page's title row
|
||||
for _ in range(2):
|
||||
try:
|
||||
session.find(label, within=content, timeout=2.5)
|
||||
return
|
||||
except NotFound:
|
||||
print(f"WARN nav {label}: the page didn't change after the click, opening it directly", flush=True)
|
||||
session.app.go(key)
|
||||
session.find(label, within=content, timeout=2.5)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ hooks: the pretend Frame's scripted events
|
||||
|
||||
def _fake_install(session, package: str, pace: float = 1.0, wait: bool = False) -> None:
|
||||
"""Install `package` on the pretend Frame through the real job queue (every real stage, an upload, a passing
|
||||
launch test). wait: until it's done."""
|
||||
app = session.app
|
||||
app.submit(f"Install {app._title(package)} on Frame", fakes.install_job(package, pace), package, "install",
|
||||
to="frame")
|
||||
if wait:
|
||||
_wait_jobs(session)
|
||||
|
||||
|
||||
def _wait_jobs(session, timeout: float = 60) -> None:
|
||||
deadline = time.time() + timeout
|
||||
session.sleep(0.5)
|
||||
while time.time() < deadline and any(j.active for j in session.app.jobs.jobs):
|
||||
session.sleep(0.3)
|
||||
|
||||
|
||||
def _held_install(session, package: str, fraction: float = 0.62) -> None:
|
||||
"""An install held mid-upload: the transit in the sidebar, the game page and Activity. It stays there until the
|
||||
window closes (Session.close cancels it)."""
|
||||
from frameport.ui.jobs import Job
|
||||
|
||||
app, reached = session.app, threading.Event()
|
||||
|
||||
def run(job):
|
||||
rep = job.reporter
|
||||
for stage in fakes.FAKE_INSTALL_STAGES:
|
||||
rep.stage(stage)
|
||||
time.sleep(0.3) # past the job queue's notification throttle
|
||||
rep.progress(fraction, f"{package}.apk", speed="36.4 MB/s · ~1 min left")
|
||||
reached.set()
|
||||
while True:
|
||||
rep.check_cancel()
|
||||
time.sleep(0.2)
|
||||
|
||||
app.jobs.submit(Job(f"Install {app._title(package)} on Frame", run, package, "install"))
|
||||
reached.wait(10)
|
||||
|
||||
|
||||
def _live_stream(session) -> None:
|
||||
fakes.fake_live_stream(session.app)
|
||||
|
||||
|
||||
def _stop_live(session) -> None:
|
||||
fakes.stop_fake_live(session.app)
|
||||
|
||||
|
||||
def _monitor_details(session) -> None:
|
||||
fakes.open_monitor_details(session.app)
|
||||
|
||||
|
||||
def _type_tab(session) -> None:
|
||||
fakes.open_type_tab(session.app)
|
||||
|
||||
|
||||
def _select_files(session, first: int = 1, count: int = 2) -> None:
|
||||
v = session.app.files_view
|
||||
for e in v.entries[first:first + count]:
|
||||
v._toggle(e.path, True)
|
||||
|
||||
|
||||
def _disconnect(session) -> None:
|
||||
"""The sidebar as before connecting (the tour connects in front of the camera)."""
|
||||
app = session.app
|
||||
app.target, app.frame_info, app.frame_state = None, None, "none"
|
||||
app._refresh_sidebar()
|
||||
app.refresh_view()
|
||||
|
||||
|
||||
def _connect(session, delay: float = 1.0) -> None:
|
||||
"""Connecting… then connected to the pretend Frame (the live card starts streaming)."""
|
||||
app = session.app
|
||||
app.frame_state = "connecting"
|
||||
app._refresh_sidebar()
|
||||
session.sleep(delay)
|
||||
fakes.attach_fake_frame(app, session.server.monitor_session)
|
||||
app.refresh_view()
|
||||
app._refresh_sidebar()
|
||||
|
||||
|
||||
def _settings_section(session, key: str) -> None:
|
||||
"""Settings, scrolled to one section (its index entry)."""
|
||||
app = session.app
|
||||
app.go("settings")
|
||||
session.sleep(1.0) # mounted first: scrolling an unmounted column does nothing
|
||||
app.page.run_task(app.settings_view.show_section, key)
|
||||
|
||||
|
||||
def _first_run(session, folder: str = "D:/Games", pace: float = 1.0, tools_missing: bool = True,
|
||||
tools_delay: float = 4.0) -> None:
|
||||
"""FramePort's first start (the "fresh" demo profile): the welcome screen's tool download is the pretend one
|
||||
(fakes.tools_job; it waits `tools_delay` s so filming catches it from the start), and "Scan a folder…" scans
|
||||
`folder` at once instead of opening the native folder picker (a script can't drive it): the demo games appear
|
||||
one by one."""
|
||||
import json
|
||||
|
||||
from frameport.core.paths import user_data_dir
|
||||
|
||||
app = session.app
|
||||
fakes.TOOLS["ready"] = not tools_missing
|
||||
app.update_tools = lambda update=False, quiet=False: fakes.tools_job(app, pace, tools_delay)
|
||||
entries = json.loads((user_data_dir() / "showcase-scan.json").read_text())
|
||||
app.pick_folder = lambda e=None: fakes.scan_job(app, folder, entries, pace)
|
||||
app.welcome_started = False
|
||||
app.library_view = None # (a Library built already would keep the real folder picker)
|
||||
|
||||
|
||||
def _pairing_done(session, delay: float = 1.5) -> None:
|
||||
"""The Frame ran the setup command: FramePort hears from it and connects (the pretend Frame)."""
|
||||
app = session.app
|
||||
if app.pairing is not None:
|
||||
app.pairing.stop()
|
||||
_connect(session, delay)
|
||||
|
||||
|
||||
def _easter_eggs(session, on: bool = True, today: str = "", installs: int | None = None) -> None:
|
||||
"""The app's easter eggs (ui/easter.py) on or off (the demo library has them off). today: pretend this date
|
||||
(YYYY-MM-DD: the holiday badges); installs: the install count so far (the next install may be a milestone).
|
||||
The window's shell is rebuilt, so the sidebar logo picks it up."""
|
||||
import os
|
||||
|
||||
from frameport.core import library
|
||||
from frameport.ui import easter
|
||||
from frameport.ui import theme as T
|
||||
|
||||
library.set_setting(easter.SETTING, bool(on))
|
||||
if today:
|
||||
os.environ["FRAMEPORT_TODAY"] = today
|
||||
if installs is not None:
|
||||
before = [f"demo.installed.{i}" for i in range(int(installs))] # that many different games so far
|
||||
library.set_setting(easter.INSTALLS, before)
|
||||
library.set_setting(easter.SHOWN, [m for m in easter.MILESTONES if m <= len(before)])
|
||||
session.app.restyle(T.THEME)
|
||||
|
||||
|
||||
def _fps_dip(session, fps: float = 58.0, seconds: float = 6.0) -> None:
|
||||
"""The pretend game stutters: the stream reports `fps` for `seconds` (the Monitor's frame-rate moods)."""
|
||||
fakes.FakeMonitorSession.DIP = (time.time() + seconds, fps)
|
||||
|
||||
|
||||
def _perfect_pacing(session, needed: float = 6.0, seconds: float = 60.0) -> None:
|
||||
"""The pretend game runs right on target for `seconds`, and `needed` seconds of that count as the Monitor's
|
||||
"full minute" (the perfect-pacing easter egg on film)."""
|
||||
from frameport.ui import easter
|
||||
|
||||
easter.PERFECT_SECONDS = float(needed)
|
||||
fakes.FakeMonitorSession.PERFECT = time.time() + seconds
|
||||
|
||||
|
||||
def _battery(session, percent: int = 99, plugged: bool = True) -> None:
|
||||
"""The pretend Frame's battery from now on (the card's fully-charged sparkle: 99 then 100 on the charger)."""
|
||||
fakes.FakeMonitorSession.BATTERY = {"percent": int(percent), "status": "Charging" if plugged else "Discharging",
|
||||
"plugged": bool(plugged), "draining": not plugged,
|
||||
"watts": 6.5 if plugged else -1.96}
|
||||
|
||||
|
||||
def _long_upload(session, package: str, seconds: float = 30.0, after: float = 2.0, every: float = 3.5) -> None:
|
||||
"""An install whose upload runs `seconds` (progress ticking 4x a second); the transit's long-upload hop starts
|
||||
after `after` seconds instead of five minutes, every `every` seconds. It finishes like a real install."""
|
||||
from frameport.ui import easter
|
||||
from frameport.ui.jobs import Job
|
||||
|
||||
easter.HOP_AFTER, easter.HOP_EVERY = float(after), float(every)
|
||||
app = session.app
|
||||
|
||||
def run(job):
|
||||
rep = job.reporter
|
||||
for stage in fakes.FAKE_INSTALL_STAGES[:-1]:
|
||||
rep.stage(stage)
|
||||
time.sleep(0.15)
|
||||
rep.stage("Upload data (3 files)")
|
||||
steps = max(1, int(seconds * 4))
|
||||
for i in range(1, steps + 1):
|
||||
rep.check_cancel()
|
||||
f = i / steps
|
||||
left = (1 - f) * seconds * 60
|
||||
rep.progress(f, f"main.1.{package}.obb", speed=f"11.2 MB/s · ~{left / 60:.0f} min left")
|
||||
time.sleep(0.25)
|
||||
rep.stage("Finalize install")
|
||||
time.sleep(0.6)
|
||||
return "done"
|
||||
|
||||
app.jobs.submit(Job(f"Install {app._title(package)} on Frame", run, package, "install"))
|
||||
|
||||
|
||||
def _press_keys(session, text: str, gap: float = 0.28) -> None:
|
||||
"""Keys typed on the Type on Frame tab (the pretend keyboard), one by one."""
|
||||
view = session.app.keyboard_view
|
||||
for ch in text:
|
||||
view.press("Space" if ch == " " else ch.upper())
|
||||
session.sleep(gap)
|
||||
|
||||
|
||||
HOOKS = {"fake_install": _fake_install, "wait_jobs": _wait_jobs, "held_install": _held_install,
|
||||
"live_stream": _live_stream, "stop_live": _stop_live, "monitor_details": _monitor_details,
|
||||
"type_tab": _type_tab, "select_files": _select_files, "disconnect": _disconnect, "connect": _connect,
|
||||
"settings_section": _settings_section, "first_run": _first_run, "pairing_done": _pairing_done,
|
||||
"easter_eggs": _easter_eggs, "fps_dip": _fps_dip, "perfect_pacing": _perfect_pacing,
|
||||
"battery": _battery, "long_upload": _long_upload, "press_keys": _press_keys}
|
||||
@@ -0,0 +1,536 @@
|
||||
"""Serve the real GUI in web mode with a pretend Frame and drive it with headless Chromium (Playwright), for docs
|
||||
screenshots and the demo tour.
|
||||
|
||||
`Server(...).run(script)` owns the main thread (Flet's `ft.run` must) and runs `script(server)` in a thread; the
|
||||
script opens browser sessions with `server.session(...)`: one Playwright context + page and the FramePortApp that
|
||||
page started (one app per browser session). Elements are found by name through Flutter's semantics tree (the
|
||||
accessibility DOM Flutter web builds on request): visible text, a tooltip or a semantics label; the pointer events
|
||||
still go to Flutter's canvas, so hover effects and gestures behave as with a real mouse.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import queue
|
||||
import socket
|
||||
import threading
|
||||
import time
|
||||
import traceback
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
import flet as ft
|
||||
|
||||
from frameport.ui.app import FramePortApp
|
||||
from showcase import fakes
|
||||
|
||||
PORT = int(os.environ.get("FRAMEPORT_SHOWCASE_PORT", "8571"))
|
||||
CHROMIUM_ARGS = ["--use-gl=swiftshader", "--enable-unsafe-swiftshader", "--font-render-hinting=none"]
|
||||
REPO = Path(__file__).resolve().parents[2]
|
||||
|
||||
# Flutter builds its semantics DOM only once something asks for it (a screen reader): the placeholder button does.
|
||||
# The semantics nodes then sit above the canvas; with pointer-events off they don't take the mouse.
|
||||
_ENABLE_SEMANTICS = """() => {
|
||||
const p = document.querySelector('flt-semantics-placeholder');
|
||||
if (p) p.click();
|
||||
if (!document.getElementById('fp-sem-style')) {
|
||||
const s = document.createElement('style');
|
||||
s.id = 'fp-sem-style';
|
||||
s.textContent = 'flt-semantics-host, flt-semantics, flt-semantics * { pointer-events: none !important; }';
|
||||
document.head.appendChild(s);
|
||||
}
|
||||
return !!p;
|
||||
}"""
|
||||
|
||||
# every named node: its own text, aria-label or the text of its children, with its box on screen
|
||||
_NODES = """() => [...document.querySelectorAll('flt-semantics')].map(e => {
|
||||
const r = e.getBoundingClientRect();
|
||||
const own = [...e.childNodes].filter(n => n.nodeType === 3).map(n => n.textContent).join(' ').trim();
|
||||
return {label: (e.getAttribute('aria-label') || '').trim(), text: own, all: (e.innerText || '').trim(),
|
||||
role: e.getAttribute('role') || '', tappable: e.hasAttribute('flt-tappable'),
|
||||
x: r.x, y: r.y, w: r.width, h: r.height};
|
||||
}).filter(n => n.w > 0 && n.h > 0)"""
|
||||
|
||||
# the visible pointer for recordings (headless Chromium draws none): an arrow that follows the mouse, a ring on press
|
||||
CURSOR_JS = """(() => {
|
||||
if (window.__fpCursor) return;
|
||||
window.__fpCursor = true;
|
||||
const add = () => {
|
||||
const c = document.createElement('div');
|
||||
c.id = 'fp-cursor';
|
||||
c.innerHTML = '<svg width="28" height="28" viewBox="0 0 28 28"><path d="M4 2 L4 22 L9.5 17 L13 25 L16.5 23.5 ' +
|
||||
'L13 15.8 L20.5 15.8 Z" fill="#fff" stroke="#111" stroke-width="1.6" stroke-linejoin="round"/></svg>';
|
||||
Object.assign(c.style, {position: 'fixed', left: '-40px', top: '-40px', width: '28px', height: '28px',
|
||||
pointerEvents: 'none', zIndex: 2147483647, filter: 'drop-shadow(0 2px 3px rgba(0,0,0,.45))',
|
||||
transform: 'translate(-3px,-2px)'});
|
||||
document.documentElement.appendChild(c);
|
||||
const ring = (x, y) => {
|
||||
const r = document.createElement('div');
|
||||
Object.assign(r.style, {position: 'fixed', left: (x - 18) + 'px', top: (y - 18) + 'px', width: '36px',
|
||||
height: '36px', borderRadius: '50%', border: '3px solid rgba(255,140,40,.95)', pointerEvents: 'none',
|
||||
zIndex: 2147483646, transition: 'transform .45s ease-out, opacity .45s ease-out', transform: 'scale(.4)',
|
||||
opacity: '1'});
|
||||
document.documentElement.appendChild(r);
|
||||
requestAnimationFrame(() => { r.style.transform = 'scale(1.5)'; r.style.opacity = '0'; });
|
||||
setTimeout(() => r.remove(), 600);
|
||||
};
|
||||
const move = e => { c.style.left = e.clientX + 'px'; c.style.top = e.clientY + 'px'; };
|
||||
window.addEventListener('pointermove', move, true);
|
||||
window.addEventListener('mousemove', move, true);
|
||||
window.addEventListener('pointerdown', e => ring(e.clientX, e.clientY), true);
|
||||
};
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', add); else add();
|
||||
})();"""
|
||||
|
||||
|
||||
@dataclass
|
||||
class Box:
|
||||
x: float
|
||||
y: float
|
||||
w: float
|
||||
h: float
|
||||
|
||||
@property
|
||||
def center(self) -> tuple[float, float]:
|
||||
return self.x + self.w / 2, self.y + self.h / 2
|
||||
|
||||
|
||||
class NotFound(LookupError):
|
||||
pass
|
||||
|
||||
|
||||
def names_of(node: dict) -> list[str]:
|
||||
"""What a semantics node is called: its label (tooltip), its own text and each line of its children's text
|
||||
(a card reads "Click to open…\\nQuest\\nBatman: Arkham Shadow\\nWorks")."""
|
||||
out = [node.get("label") or "", node.get("text") or ""]
|
||||
for key in ("label", "text", "all"):
|
||||
out += (node.get(key) or "").splitlines()
|
||||
return [s.strip().casefold() for s in out if s and s.strip()]
|
||||
|
||||
|
||||
def _contains(outer: dict, inner: dict) -> bool:
|
||||
"""outer's box holds inner's centre and is bigger: a container of inner (a list around its row)."""
|
||||
cx, cy = inner["x"] + inner["w"] / 2, inner["y"] + inner["h"] / 2
|
||||
return (outer["x"] <= cx <= outer["x"] + outer["w"] and outer["y"] <= cy <= outer["y"] + outer["h"]
|
||||
and outer["w"] * outer["h"] > inner["w"] * inner["h"] * 1.2)
|
||||
|
||||
|
||||
def innermost(nodes: list[dict]) -> list[dict]:
|
||||
"""The nodes that don't contain another one of them (a list's text includes its rows': the row wins)."""
|
||||
return [n for n in nodes if not any(m is not n and _contains(n, m) for m in nodes)]
|
||||
|
||||
|
||||
def pick(nodes: list[dict], name: str, nth: int = 0, exact: bool | None = None) -> dict | None:
|
||||
"""The nth node called `name`: exact names first, then names starting with it, then containing it (unless
|
||||
exact). Tappable nodes (buttons, cards) win, top to bottom and left to right; else the plain text itself, i.e.
|
||||
the smallest node (the containers around it carry its text too)."""
|
||||
want = name.strip().casefold()
|
||||
tests = [lambda s: s == want]
|
||||
if not exact:
|
||||
tests += [lambda s: s.startswith(want), lambda s: want in s]
|
||||
for test in tests:
|
||||
hits = [n for n in nodes if any(test(s) for s in names_of(n))]
|
||||
tappable = innermost([n for n in hits if n.get("tappable")])
|
||||
if tappable:
|
||||
tappable.sort(key=lambda n: (round(n["y"]), round(n["x"]), n["w"] * n["h"]))
|
||||
return tappable[nth] if nth < len(tappable) else None
|
||||
if hits:
|
||||
hits.sort(key=lambda n: (n["w"] * n["h"], round(n["y"]), round(n["x"])))
|
||||
return hits[nth] if nth < len(hits) else None
|
||||
return None
|
||||
|
||||
|
||||
def ease(t: float) -> float:
|
||||
"""Ease-in-out (smoothstep of a smoothstep): slow start, fast middle, gentle landing."""
|
||||
t = max(0.0, min(1.0, t))
|
||||
t = t * t * (3 - 2 * t)
|
||||
return t * t * (3 - 2 * t)
|
||||
|
||||
|
||||
def human_path(start: tuple[float, float], end: tuple[float, float], steps: int, bend: float = 0.12
|
||||
) -> list[tuple[float, float]]:
|
||||
"""Points from start to end along a slight arc (a quadratic Bezier whose control point sits `bend` of the
|
||||
distance off the straight line), spaced by `ease`: the path a hand takes, not a ruler line."""
|
||||
(x0, y0), (x1, y1) = start, end
|
||||
dx, dy = x1 - x0, y1 - y0
|
||||
dist = math.hypot(dx, dy)
|
||||
cx, cy = (x0 + x1) / 2 - dy * bend, (y0 + y1) / 2 + dx * bend # perpendicular offset
|
||||
if dist < 1:
|
||||
return [end] * max(1, steps)
|
||||
out = []
|
||||
for i in range(1, steps + 1):
|
||||
t = ease(i / steps)
|
||||
out.append(((1 - t) ** 2 * x0 + 2 * (1 - t) * t * cx + t * t * x1,
|
||||
(1 - t) ** 2 * y0 + 2 * (1 - t) * t * cy + t * t * y1))
|
||||
return out
|
||||
|
||||
|
||||
def move_duration(dist: float) -> float:
|
||||
"""Seconds for a pointer hop of `dist` px: ~0.45 s for short hops, up to ~0.9 s across the window."""
|
||||
return max(0.35, min(0.9, 0.3 + dist / 1800))
|
||||
|
||||
|
||||
class Session:
|
||||
"""One browser page showing one FramePortApp."""
|
||||
|
||||
def __init__(self, server: Server, ctx, page, app: FramePortApp, cursor: bool):
|
||||
self.server, self.ctx, self.page, self.app = server, ctx, page, app
|
||||
self.mouse_at = (0.0, 0.0)
|
||||
self.cursor = cursor
|
||||
self.semantics = False
|
||||
self.browser = None
|
||||
self.park_at: tuple[float, float] | None = None
|
||||
|
||||
def sleep(self, seconds: float) -> None:
|
||||
"""Wait while the browser keeps going (Playwright's event loop runs, so a screencast keeps its frames)."""
|
||||
if seconds > 0:
|
||||
self.page.wait_for_timeout(seconds * 1000)
|
||||
|
||||
# ------------------------------------------------------------ finding things
|
||||
def enable_semantics(self) -> None:
|
||||
if not self.semantics:
|
||||
self.semantics = bool(self.page.evaluate(_ENABLE_SEMANTICS))
|
||||
self.sleep(0.5)
|
||||
|
||||
def nodes(self) -> list[dict]:
|
||||
self.enable_semantics()
|
||||
return self.page.evaluate(_NODES)
|
||||
|
||||
def find(self, name: str, within: Box | None = None, nth: int = 0, exact: bool | None = None,
|
||||
timeout: float = 8.0) -> Box:
|
||||
"""The box of the element called `name` (its text, tooltip or label; exact match first, then the start of
|
||||
the text, then anywhere in it), optionally inside `within`; the smallest tappable one wins ties. Waits up
|
||||
to `timeout` s for it to appear."""
|
||||
deadline = time.monotonic() + timeout
|
||||
while True:
|
||||
vw, vh = self.viewport
|
||||
nodes = [n for n in self.nodes() if 0 <= n["x"] + n["w"] / 2 <= vw and 0 <= n["y"] + n["h"] / 2 <= vh]
|
||||
if within:
|
||||
nodes = [n for n in nodes if within.x <= n["x"] + n["w"] / 2 <= within.x + within.w
|
||||
and within.y <= n["y"] + n["h"] / 2 <= within.y + within.h]
|
||||
hit = pick(nodes, name, nth, exact)
|
||||
if hit:
|
||||
return Box(hit["x"], hit["y"], hit["w"], hit["h"])
|
||||
if time.monotonic() > deadline:
|
||||
raise NotFound(f"no element named {name!r} on screen")
|
||||
self.sleep(0.3)
|
||||
|
||||
def dialog(self, timeout: float = 8.0) -> Box:
|
||||
"""The box of the topmost open dialog (Flutter labels a dialog's surface "Alert")."""
|
||||
deadline = time.monotonic() + timeout
|
||||
while True:
|
||||
boxes = [n for n in self.nodes() if n["label"] == "Alert"]
|
||||
if boxes:
|
||||
n = boxes[-1]
|
||||
return Box(n["x"], n["y"], n["w"], n["h"])
|
||||
if time.monotonic() > deadline:
|
||||
raise NotFound("no dialog open")
|
||||
self.sleep(0.3)
|
||||
|
||||
def exists(self, name: str, timeout: float = 0.0) -> bool:
|
||||
try:
|
||||
self.find(name, timeout=timeout)
|
||||
return True
|
||||
except NotFound:
|
||||
return False
|
||||
|
||||
@property
|
||||
def viewport(self) -> tuple[int, int]:
|
||||
v = self.page.viewport_size
|
||||
return v["width"], v["height"]
|
||||
|
||||
# ------------------------------------------------------------ the pointer
|
||||
def point(self, target) -> tuple[float, float]:
|
||||
"""A target: a name (see find), a Box, an (x, y) pair, or {"name": …, "dx": …, "dy": …, "nth": …}
|
||||
(dx/dy: offset from the box's centre in px, or as a fraction of its size when |d| < 1)."""
|
||||
if isinstance(target, (tuple, list)) and len(target) == 2 and all(isinstance(v, (int, float)) for v in target):
|
||||
return float(target[0]), float(target[1])
|
||||
if isinstance(target, Box):
|
||||
return target.center
|
||||
if isinstance(target, str):
|
||||
return self.find(target).center
|
||||
if isinstance(target, dict):
|
||||
box = self.find(target["name"], nth=target.get("nth", 0), exact=target.get("exact"))
|
||||
cx, cy = box.center
|
||||
dx, dy = target.get("dx", 0), target.get("dy", 0)
|
||||
dx = dx * box.w if abs(dx) < 1 else dx
|
||||
dy = dy * box.h if abs(dy) < 1 else dy
|
||||
return cx + dx, cy + dy
|
||||
raise TypeError(f"not a target: {target!r}")
|
||||
|
||||
def move(self, target, duration: float | None = None, smooth: bool = True) -> tuple[float, float]:
|
||||
x, y = self.point(target)
|
||||
if not smooth:
|
||||
self.page.mouse.move(x, y)
|
||||
else:
|
||||
dist = math.hypot(x - self.mouse_at[0], y - self.mouse_at[1])
|
||||
duration = move_duration(dist) if duration is None else duration
|
||||
steps = max(2, int(duration * 60))
|
||||
t0 = time.monotonic()
|
||||
for i, (px, py) in enumerate(human_path(self.mouse_at, (x, y), steps)):
|
||||
self.page.mouse.move(px, py)
|
||||
wait = t0 + duration * (i + 1) / steps - time.monotonic()
|
||||
if wait > 0:
|
||||
self.sleep(wait)
|
||||
self.mouse_at = (x, y)
|
||||
return x, y
|
||||
|
||||
def click(self, target, button: str = "left", smooth: bool = True, pause: float = 0.15) -> None:
|
||||
self.move(target, smooth=smooth)
|
||||
if isinstance(target, (str, dict)): # the layout moved while the pointer travelled (a list reloaded): follow
|
||||
x, y = self.point(target)
|
||||
if math.hypot(x - self.mouse_at[0], y - self.mouse_at[1]) > 6:
|
||||
self.move((x, y), duration=0.25)
|
||||
self.sleep(pause)
|
||||
self.page.mouse.down(button=button)
|
||||
self.sleep(0.07)
|
||||
self.page.mouse.up(button=button)
|
||||
|
||||
def drag(self, points: list, smooth: bool = True) -> None:
|
||||
self.move(points[0], smooth=smooth)
|
||||
self.sleep(0.2)
|
||||
self.page.mouse.down()
|
||||
for p in points[1:]:
|
||||
self.move(p, smooth=smooth, duration=0.6)
|
||||
self.sleep(0.2)
|
||||
self.page.mouse.up()
|
||||
|
||||
def type(self, text: str, delay: float = 0.11) -> None:
|
||||
self.page.keyboard.type(text, delay=int(delay * 1000))
|
||||
|
||||
def press(self, key: str) -> None:
|
||||
self.page.keyboard.press(key)
|
||||
|
||||
def scroll(self, dy: float, at=None) -> None:
|
||||
if at is not None:
|
||||
self.move(at)
|
||||
for _ in range(max(1, int(abs(dy) // 100))):
|
||||
self.page.mouse.wheel(0, 100 if dy > 0 else -100)
|
||||
self.sleep(0.05)
|
||||
|
||||
def park(self, away: bool = False) -> None:
|
||||
"""The pointer somewhere it hovers nothing: the sidebar's empty part (videos: the drawn cursor stays in the
|
||||
picture), or with `away` off the page (still pictures: nothing hovered, whatever the layout)."""
|
||||
if away:
|
||||
self.page.mouse.move(-40, -40)
|
||||
self.mouse_at = (-40.0, -40.0)
|
||||
return
|
||||
if self.park_at is None: # just below the sidebar's last tab (Settings): nothing there takes the pointer
|
||||
try:
|
||||
tab = self.find("Settings", timeout=3)
|
||||
self.park_at = (tab.x + tab.w * 0.6, tab.y + tab.h + 44)
|
||||
except NotFound:
|
||||
self.park_at = self.server.park_point(self.viewport)
|
||||
self.page.mouse.move(*self.park_at)
|
||||
self.mouse_at = self.park_at
|
||||
|
||||
# ------------------------------------------------------------ pictures
|
||||
def settle(self, timeout: float = 8.0, interval: float = 0.15, quiet: int = 4, mask: list[Box] = ()) -> bool:
|
||||
"""Wait until the page stops changing: `quiet` screenshots in a row (interval apart) are identical (masked
|
||||
boxes, e.g. a live chart, ignored). False when it was still changing at `timeout`."""
|
||||
deadline, last, same = time.monotonic() + timeout, None, 0
|
||||
while time.monotonic() < deadline:
|
||||
png = self._raw(mask)
|
||||
same = same + 1 if png == last else 0
|
||||
if same >= quiet:
|
||||
return True
|
||||
last = png
|
||||
self.sleep(interval)
|
||||
return False
|
||||
|
||||
def _raw(self, mask: list[Box] = ()) -> bytes:
|
||||
if not mask:
|
||||
return self.page.screenshot(animations="disabled", caret="hide")
|
||||
from io import BytesIO
|
||||
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
im = Image.open(BytesIO(self.page.screenshot(caret="hide")))
|
||||
d = ImageDraw.Draw(im)
|
||||
for b in mask:
|
||||
d.rectangle((b.x, b.y, b.x + b.w, b.y + b.h), fill=(0, 0, 0))
|
||||
return im.tobytes()
|
||||
|
||||
def shot(self, path: Path, clip: Box | None = None, settle: bool = True) -> Path:
|
||||
if settle:
|
||||
self.settle()
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
kw = {"clip": {"x": clip.x, "y": clip.y, "width": clip.w, "height": clip.h}} if clip else {}
|
||||
self.page.screenshot(path=str(path), caret="hide", **kw)
|
||||
return path
|
||||
|
||||
def close(self) -> None:
|
||||
"""Close the window and leave nothing behind for the next one: the job queue is shared by every session
|
||||
(a pretend install would show in the next window's Activity), the live stream's ffmpeg and the monitor
|
||||
stream would run on, and a closed page must not get job events."""
|
||||
app = self.app
|
||||
try:
|
||||
app.jobs.unsubscribe(app._on_job)
|
||||
for job in list(app.jobs.jobs):
|
||||
if job.active:
|
||||
app.jobs.cancel(job)
|
||||
deadline = time.monotonic() + 5
|
||||
while any(j.active for j in app.jobs.jobs) and time.monotonic() < deadline:
|
||||
self.sleep(0.1)
|
||||
app.jobs.clear_finished()
|
||||
fakes.stop_fake_live(app)
|
||||
app.stop_monitor()
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
for thing in (self.ctx, self.browser):
|
||||
try:
|
||||
if thing is not None:
|
||||
thing.close()
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
|
||||
|
||||
class Server:
|
||||
"""The GUI on 127.0.0.1:PORT (web mode) with fakes installed; `run(script)` serves until the script returns."""
|
||||
|
||||
def __init__(self, port: int = PORT, fake_frame: bool = True, monitor_session=None, game: str | None = None,
|
||||
scale: float = 1.0):
|
||||
self.port, self.fake_frame, self.scale = port, fake_frame, scale
|
||||
self.monitor_session = monitor_session or fakes.FakeMonitorSession
|
||||
self.apps: queue.Queue = queue.Queue()
|
||||
self.errors: list[str] = []
|
||||
self.playwright = None
|
||||
self.game = game
|
||||
|
||||
def park_point(self, viewport: tuple[int, int]) -> tuple[float, float]:
|
||||
return 130 * self.scale, viewport[1] * 0.62
|
||||
|
||||
def _app_main(self, page: ft.Page) -> None:
|
||||
try:
|
||||
app = FramePortApp(page)
|
||||
if self.fake_frame:
|
||||
fakes.attach_fake_frame(app, self.monitor_session)
|
||||
except Exception: # noqa: BLE001
|
||||
self.errors.append("startup: " + traceback.format_exc())
|
||||
return
|
||||
self.apps.put(app)
|
||||
|
||||
def session(self, viewport: tuple[int, int], cursor: bool = False, video_dir: Path | None = None,
|
||||
device_scale: float = 1.0) -> Session:
|
||||
"""A new browser context + page (fresh app). `video_dir`: Playwright's own recorder (fallback capture)."""
|
||||
while not self.apps.empty(): # apps from sessions already closed
|
||||
self.apps.get_nowait()
|
||||
kw = {}
|
||||
if video_dir is not None:
|
||||
kw = {"record_video_dir": str(video_dir), "record_video_size": {"width": viewport[0],
|
||||
"height": viewport[1]}}
|
||||
# a browser of its own per window: windows sharing one browser (its GPU process) sometimes drew text with
|
||||
# glyphs from the wrong place ("/sdcard/ʍvies")
|
||||
browser = self.playwright.chromium.launch(args=CHROMIUM_ARGS)
|
||||
# (clipboard: the Screenshots tab's Copy image writes an image to the browser's clipboard in web mode)
|
||||
ctx = browser.new_context(viewport={"width": viewport[0], "height": viewport[1]},
|
||||
device_scale_factor=device_scale, permissions=["clipboard-read", "clipboard-write"],
|
||||
**kw)
|
||||
if cursor:
|
||||
ctx.add_init_script(CURSOR_JS)
|
||||
page = ctx.new_page()
|
||||
page.goto(f"http://127.0.0.1:{self.port}", wait_until="networkidle", timeout=120_000)
|
||||
app = self.apps.get(timeout=120)
|
||||
s = Session(self, ctx, page, app, cursor)
|
||||
s.browser = browser
|
||||
# web fonts: text measured before they load wraps or overlaps ("Q / uest"): a text-heavy first screen (the
|
||||
# Settings page) takes them before the steps start
|
||||
s.sleep(1.0)
|
||||
app.go("settings")
|
||||
s.sleep(2.0)
|
||||
s.enable_semantics()
|
||||
s.park()
|
||||
return s
|
||||
|
||||
def run(self, script) -> int:
|
||||
"""Serve; `script(server) -> exit code` runs in a thread with the browser ready; the process ends with it."""
|
||||
from frameport.ui.app import serialize_flet_updates
|
||||
|
||||
serialize_flet_updates() # as the app's main() does: patches and property writes don't interleave
|
||||
if self.fake_frame:
|
||||
fakes.install_fakes(self.game, self.monitor_session)
|
||||
|
||||
def runner():
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
for _ in range(90):
|
||||
try:
|
||||
socket.create_connection(("127.0.0.1", self.port), timeout=1).close()
|
||||
break
|
||||
except OSError:
|
||||
time.sleep(1)
|
||||
time.sleep(1.5)
|
||||
code = 1
|
||||
try:
|
||||
with sync_playwright() as p:
|
||||
self.playwright = p
|
||||
code = script(self) or 0
|
||||
except Exception: # noqa: BLE001
|
||||
self.errors.append("script: " + traceback.format_exc())
|
||||
for e in self.errors:
|
||||
print("ERROR", e, flush=True)
|
||||
os._exit(1 if self.errors else code)
|
||||
|
||||
from frameport.ui.app import assets_dir
|
||||
|
||||
threading.Thread(target=runner, daemon=True).start()
|
||||
ft.run(self._app_main, view=ft.AppView.WEB_BROWSER, port=self.port, assets_dir=assets_dir())
|
||||
return 1
|
||||
|
||||
|
||||
class Screencast:
|
||||
"""The page's frames as Chrome paints them (CDP Page.startScreencast: JPEGs with timestamps), written to a folder.
|
||||
Sharper than Playwright's own recorder (VP8 at a low bit rate). Chrome sends a frame only when the page changed,
|
||||
so the frames come with their times and are turned into a constant frame rate later (postprod.frames_to_video).
|
||||
Frames only arrive while Playwright runs (Session.sleep, mouse moves), never during time.sleep."""
|
||||
|
||||
def __init__(self, session: Session, folder: Path, quality: int = 92):
|
||||
import base64
|
||||
|
||||
self._b64 = base64.b64decode
|
||||
self.session, self.folder, self.quality = session, Path(folder), quality
|
||||
self.folder.mkdir(parents=True, exist_ok=True)
|
||||
self.frames: list[tuple[float, str]] = [] # (wall-clock time, file name)
|
||||
self.cdp = session.ctx.new_cdp_session(session.page)
|
||||
self.cdp.on("Page.screencastFrame", self._frame)
|
||||
self.running = False
|
||||
|
||||
def _frame(self, params: dict) -> None:
|
||||
name = f"{len(self.frames):06d}.jpg"
|
||||
(self.folder / name).write_bytes(self._b64(params["data"]))
|
||||
self.frames.append((float(params["metadata"].get("timestamp") or time.time()), name))
|
||||
try:
|
||||
self.cdp.send("Page.screencastFrameAck", {"sessionId": params["sessionId"]})
|
||||
except Exception: # noqa: BLE001 (stopping)
|
||||
pass
|
||||
|
||||
def start(self) -> None:
|
||||
vw, vh = self.session.viewport
|
||||
scale = self.session.page.evaluate("window.devicePixelRatio") or 1
|
||||
self.cdp.send("Page.startScreencast", {"format": "jpeg", "quality": self.quality,
|
||||
"maxWidth": int(vw * scale), "maxHeight": int(vh * scale),
|
||||
"everyNthFrame": 1})
|
||||
self.running = True
|
||||
|
||||
def stop(self) -> None:
|
||||
if self.running:
|
||||
self.session.sleep(0.3)
|
||||
self.cdp.send("Page.stopScreencast")
|
||||
self.running = False
|
||||
|
||||
def write_index(self) -> Path:
|
||||
"""frames.json: [[time, file], …] for postprod."""
|
||||
path = self.folder / "frames.json"
|
||||
path.write_text(json.dumps(self.frames))
|
||||
return path
|
||||
|
||||
|
||||
def call(session: Session, fn, *args, **kwargs):
|
||||
"""Run an app action from the script thread, logging (not raising) its errors so one broken step doesn't end a
|
||||
whole render."""
|
||||
try:
|
||||
return fn(*args, **kwargs)
|
||||
except Exception: # noqa: BLE001
|
||||
session.server.errors.append(f"{getattr(fn, '__name__', fn)}: " + traceback.format_exc())
|
||||
return None
|
||||
@@ -17,9 +17,22 @@ import time
|
||||
import traceback
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
|
||||
|
||||
import flet as ft # noqa: E402
|
||||
from showcase.fakes import ( # noqa: E402,F401
|
||||
LINUX_APPIMAGE,
|
||||
LINUX_FOLDER,
|
||||
add_fake_linux_apps,
|
||||
attach_fake_frame,
|
||||
fake_live_stream,
|
||||
install_fakes,
|
||||
open_monitor_details,
|
||||
open_type_tab,
|
||||
start_fake_install,
|
||||
stop_fake_live,
|
||||
)
|
||||
|
||||
from frameport.core import library # noqa: E402
|
||||
from frameport.ui.app import FramePortApp # noqa: E402
|
||||
@@ -28,215 +41,25 @@ PORT = int(os.environ.get("FRAMEPORT_SMOKE_PORT", "8557")) # two smoke runs at
|
||||
ERRORS: list[str] = []
|
||||
|
||||
|
||||
class FakeFS:
|
||||
"""--fake-frame's file system for the Files tab: a temp folder with sample files, served like SFTP."""
|
||||
|
||||
def __init__(self):
|
||||
import tempfile
|
||||
|
||||
self.home = tempfile.mkdtemp(prefix="fp-fake-frame-")
|
||||
samples = {"Videos": ["Earth from orbit (360).mp4", "Mars landing (VR180).mkv", "Concert 8K 3D.mp4"],
|
||||
"Downloads": ["Mods/", "readme.txt"], "Documents": ["Saves/", "Notes.pdf"]}
|
||||
sizes = {".mp4": 2_400_000_000, ".mkv": 1_100_000_000}
|
||||
for folder, names in samples.items():
|
||||
base = os.path.join(self.home, folder)
|
||||
os.makedirs(os.path.join(base, "Trips"), exist_ok=True)
|
||||
for n in names:
|
||||
if n.endswith("/"):
|
||||
os.makedirs(os.path.join(base, n), exist_ok=True)
|
||||
else:
|
||||
with open(os.path.join(base, n), "wb") as f:
|
||||
f.truncate(sizes.get(os.path.splitext(n)[1], 48_000)) # sparse: no real disk use
|
||||
self.shots = self._screenshots()
|
||||
|
||||
def _screenshots(self) -> list[dict]:
|
||||
"""Sample Steam screenshots for the Screenshots tab, two days, a few games + SteamVR: crops of the games' own
|
||||
store art (hero/landscape) when the library has some (docs screenshots), else colour gradients."""
|
||||
from PIL import Image, ImageOps
|
||||
|
||||
from frameport.artwork import fetch
|
||||
|
||||
folder = os.path.join(self.home, "shots")
|
||||
os.makedirs(folder, exist_ok=True)
|
||||
games = []
|
||||
for g in library.games():
|
||||
if g.get("kind") == "rift":
|
||||
continue
|
||||
# the store's own screenshots look like real captures; else hero/wide art
|
||||
shots_art = sorted(fetch.artwork_dir(g["package"]).glob("shot_*.jpg"))
|
||||
games.append((g, shots_art or [p for p in fetch.files(g["package"]) if p.stem in ("hero", "landscape")],
|
||||
bool(shots_art)))
|
||||
games.sort(key=lambda ga: (not ga[2], -len(ga[1])))
|
||||
owners = [(g["package"], g.get("title") or g["package"], arts) for g, arts, _real in games[:3]]
|
||||
spare = games[3][1] if len(games) > 3 else [] # SteamVR's own shots (taken outside a FramePort game)
|
||||
owners.append((None, "SteamVR", spare))
|
||||
now, shots = time.time(), []
|
||||
for i in range(10):
|
||||
t = now - i * 2400 - (86400 if i >= 6 else 0)
|
||||
name = time.strftime("%Y%m%d%H%M%S", time.localtime(t)) + "_1.jpg"
|
||||
path = os.path.join(folder, name)
|
||||
pkg, title, arts = owners[i % len(owners)]
|
||||
if arts: # a different crop of the game's art per shot, so they don't all look alike
|
||||
with Image.open(arts[i % len(arts)]) as src:
|
||||
src = src.convert("RGB")
|
||||
zoom = 1.0 + 0.15 * (i % 3) * (src.width < 2 * src.height)
|
||||
w, h = int(src.width / zoom), int(src.height / zoom)
|
||||
x, y = (src.width - w) * (i % 2), (src.height - h) // 2
|
||||
im = ImageOps.fit(src.crop((x, y, x + w, y + h)), (1280, 720))
|
||||
else:
|
||||
im = Image.linear_gradient("L").resize((640, 360)).convert("RGB")
|
||||
im = Image.merge("RGB", (im.getchannel(0).point(lambda v, i=i: (v + 40 * i) % 256),
|
||||
im.getchannel(1).point(lambda v: 255 - v), im.getchannel(2)))
|
||||
im.save(path, "JPEG", quality=85)
|
||||
shots.append({"path": path, "thumb": None, "time": int(t), "width": 1920, "height": 1080,
|
||||
"size": os.path.getsize(path), "account": "1", "appid": "250820", "package": pkg,
|
||||
"title": title})
|
||||
return shots
|
||||
|
||||
def agent(self, command, **args):
|
||||
if command == "storage_targets":
|
||||
return {"targets": [{"id": n.lower(), "path": os.path.join(self.home, n), "android": a, "shared": True}
|
||||
for n, a in (("Videos", "/sdcard/Movies"), ("Downloads", "/sdcard/Download"),
|
||||
("Documents", "/sdcard/Documents"))]}
|
||||
if command == "list_screenshots":
|
||||
want = args.get("package")
|
||||
shots = [s for s in self.shots if want is None or (s["package"] or "") == want]
|
||||
games = {}
|
||||
for s in self.shots:
|
||||
games.setdefault(s["package"] or "", {"package": s["package"], "title": s["title"], "count": 0})
|
||||
games[s["package"] or ""]["count"] += 1
|
||||
return {"shots": shots, "total": len(shots), "games": list(games.values())}
|
||||
raise RuntimeError(f"fake Frame: {command} not available")
|
||||
|
||||
@property
|
||||
def sftp(self):
|
||||
import paramiko
|
||||
|
||||
class SFTP:
|
||||
def listdir_attr(self, path):
|
||||
out = []
|
||||
for name in sorted(os.listdir(path)):
|
||||
a = paramiko.SFTPAttributes.from_stat(os.lstat(os.path.join(path, name)))
|
||||
a.filename = name
|
||||
out.append(a)
|
||||
return out
|
||||
|
||||
def stat(self, path):
|
||||
return paramiko.SFTPAttributes.from_stat(os.stat(path))
|
||||
|
||||
def get(self, remote, local, callback=None):
|
||||
import shutil
|
||||
|
||||
shutil.copyfile(remote, local)
|
||||
return SFTP()
|
||||
PAINT_SECONDS = 3 # after a step, before its screenshot: Flutter paints (and a view's content loads)
|
||||
STEP_TIMEOUT = 240 # the longest a step may wait for its screenshot (a crashed browser mustn't hang the run)
|
||||
|
||||
|
||||
class FakeTarget:
|
||||
"""--fake-frame: a pretend Steam Frame with the library's working Quest builds installed (no network, no device),
|
||||
for documentation screenshots."""
|
||||
|
||||
def __init__(self, count: int = 8):
|
||||
from frameport.frame.connection import parse_target
|
||||
|
||||
self.label = "steamframe"
|
||||
self.frame = FakeFS()
|
||||
self.target = parse_target("steamos@steamframe.local")
|
||||
works = [g for g in library.games() if g.get("kind") != "rift" and (g.get("build") or {}).get("sha256")
|
||||
and (g.get("recipe") or {}).get("status") in ("works", "issues")]
|
||||
works.sort(key=lambda g: -(g.get("data_bytes") or 0))
|
||||
self.games = [{"package": g["package"], "kind": "quest", "title": g.get("title"),
|
||||
"apk_size": (g.get("data_bytes") or 0) + 2**28, "sha256": g["build"]["sha256"],
|
||||
"recipe": {"patches": (g.get("recipe") or {}).get("patches", [])}} for g in works[:count]]
|
||||
# --linux: the AppImage is on the Frame, but SteamOS lacks one of its libraries
|
||||
self.games += [{"package": g["package"], "kind": "linux", "title": g.get("title"), "apk_size": 2**26,
|
||||
"apk_present": True, "recipe": None, "exe": g.get("exe"),
|
||||
"missing_libraries": ["libwebkit2gtk-4.1.so.0"]}
|
||||
for g in library.games() if g.get("kind") == "linux" and g["package"] == LINUX_APPIMAGE]
|
||||
|
||||
def describe(self) -> dict:
|
||||
return {"hostname": "steamframe", "os": "SteamOS", "os_version": "3.8", "build_id": "20260922",
|
||||
"free_bytes": 312 * 2**30, "installed": self.games, "lepton": True,
|
||||
"proton": {"ready": {"display_name": "Proton 11 (ARM64)"}, "openxr": {"name": "SteamVR"}},
|
||||
"kernel_keys": {"keys": 31, "max_keys": 200}}
|
||||
|
||||
def installed(self) -> list[dict]:
|
||||
return self.games
|
||||
|
||||
def close(self) -> None:
|
||||
pass
|
||||
|
||||
|
||||
class FakeKeyboardSession:
|
||||
"""--fake-frame: Type on Frame connects at once (nothing is sent anywhere)."""
|
||||
|
||||
def __init__(self, frame):
|
||||
self.closed = False
|
||||
|
||||
def key(self, name, action="down"):
|
||||
return True
|
||||
|
||||
def text(self, text):
|
||||
return ""
|
||||
|
||||
def close(self):
|
||||
self.closed = True
|
||||
|
||||
|
||||
def open_type_dialog(app: FramePortApp) -> None:
|
||||
"""Type on Frame over the Steam Frame page, with one key 'pressed' so the screenshot shows it working."""
|
||||
from types import SimpleNamespace
|
||||
|
||||
app.navigate(1)
|
||||
time.sleep(1.5)
|
||||
app.type_on_frame()
|
||||
time.sleep(1.5)
|
||||
dialog = [d for d in app.page._dialogs.controls if d.open][-1]
|
||||
listener = dialog.content.controls[1]
|
||||
listener.on_key_down(SimpleNamespace(key="Enter"))
|
||||
|
||||
|
||||
LINUX_APPIMAGE = "linux.venera" # --linux's packages
|
||||
LINUX_FOLDER = "linux.matineevr"
|
||||
|
||||
|
||||
def _elf(machine: int = 183, appimage: bool = False, extra: bytes = b"") -> bytes:
|
||||
"""A minimal ELF header (183 = aarch64): enough for FramePort's Linux app detection."""
|
||||
head = bytearray(64)
|
||||
head[:4], head[4], head[5] = b"\x7fELF", 2, 1
|
||||
if appimage:
|
||||
head[8:11] = b"AI\x02"
|
||||
head[18:20] = machine.to_bytes(2, "little")
|
||||
return bytes(head) + extra
|
||||
|
||||
|
||||
def add_fake_linux_apps() -> None:
|
||||
"""--linux: an AppImage and a VR app folder (with a helper program, so "Change program…" shows) in the library."""
|
||||
from frameport import pipeline
|
||||
from frameport.core.paths import user_data_dir
|
||||
|
||||
base = user_data_dir() / "smoke-linux"
|
||||
app = base / "MatineeVR"
|
||||
(app / "lib").mkdir(parents=True, exist_ok=True)
|
||||
(base / "Venera-2.4.2-aarch64.AppImage").write_bytes(_elf(appimage=True, extra=b"\0" * 4096))
|
||||
(app / "MatineeVR").write_bytes(_elf(extra=b"\0" * 8192))
|
||||
(app / "crashpad_handler").write_bytes(_elf())
|
||||
(app / "lib" / "libopenxr_loader.so.1").write_bytes(_elf(extra=b"xrCreateInstance"))
|
||||
pipeline.add_linux_app(base / "Venera-2.4.2-aarch64.AppImage")
|
||||
pipeline.add_linux_app(app)
|
||||
|
||||
|
||||
STEP_SECONDS = 4 # per screen (the screenshot is taken ~3 s in)
|
||||
|
||||
|
||||
def driver(app: FramePortApp, steps: list[tuple[str, callable]], ready: threading.Event, done_step: list):
|
||||
def driver(app: FramePortApp, steps: list[tuple[str, callable]], ready: threading.Event, shot_done: threading.Event,
|
||||
done_step: list):
|
||||
"""Runs one step, hands it to the shooter ("ready") and waits until its screenshot and mouse actions are done
|
||||
("shot_done") before the next one: so a screenshot always shows its own step, however long the shooter takes."""
|
||||
for name, action in steps:
|
||||
try:
|
||||
action(app)
|
||||
except Exception: # noqa: BLE001
|
||||
ERRORS.append(f"{name}: {traceback.format_exc()}")
|
||||
done_step.append(name)
|
||||
shot_done.clear()
|
||||
ready.set()
|
||||
time.sleep(STEP_SECONDS)
|
||||
if not shot_done.wait(STEP_TIMEOUT):
|
||||
ERRORS.append(f"{name}: no screenshot within {STEP_TIMEOUT} s, stopping")
|
||||
return
|
||||
|
||||
|
||||
def find_button(root, text: str):
|
||||
@@ -276,7 +99,8 @@ def main() -> int:
|
||||
ap.add_argument("--no-test", action="store_true", help="with --frame: skip the launch-test job")
|
||||
ap.add_argument("--scale", type=float, default=1.0, help="UI scale to render at (e.g. 1.5)")
|
||||
ap.add_argument("--viewport", default="1280x820", help="browser size, e.g. 2560x1440")
|
||||
ap.add_argument("--update", action="store_true", help="pretend a new FramePort release exists (update UI)")
|
||||
ap.add_argument("--update", action="store_true", help="pretend a new FramePort release exists (update UI: "
|
||||
"changelog dialog, what's new bar + dialog, Settings changelog)")
|
||||
ap.add_argument("--fake-frame", action="store_true", help="pretend a Steam Frame is connected (no device needed)")
|
||||
ap.add_argument("--hover", default=None, help="x,y: move the mouse there before the Library screenshot")
|
||||
ap.add_argument("--install-questions", nargs="+", metavar="PKG", default=None,
|
||||
@@ -286,14 +110,18 @@ def main() -> int:
|
||||
"(a Frame cabled to this PC) and screenshot what follows")
|
||||
ap.add_argument("--docs", action="store_true", help="only the screens used in the docs (Library, --game, Frame)")
|
||||
ap.add_argument("--gestures", action="store_true", help="with --fake-frame: real mouse drags (drag-select) and "
|
||||
"right-clicks (menus) in Files, Screenshots and the Library; prints what got selected")
|
||||
"right-clicks (menus) in Files, Screenshots and the Library; prints what got selected "
|
||||
"(positions for --viewport 1440x900)")
|
||||
ap.add_argument("--only", default=None, help="comma-separated step names to keep (e.g. monitor,monitor-details)")
|
||||
ap.add_argument("--linux", action="store_true", help="add two pretend arm64 Linux apps and render their pages")
|
||||
ap.add_argument("--links", action="store_true", help="install links: the Add games menu, the paste dialog, the "
|
||||
"confirmation for a pretend FrameDrop manifest, Settings → Install links and (with --game) the "
|
||||
"VR / flat window choice")
|
||||
ap.add_argument("--themes", action="store_true", help="Settings' theme picker, then switch every theme while "
|
||||
"running (Library and --game in each)")
|
||||
args = ap.parse_args()
|
||||
if args.linux:
|
||||
add_fake_linux_apps()
|
||||
global STEP_SECONDS
|
||||
if args.hover:
|
||||
STEP_SECONDS = 7
|
||||
from frameport.ui import theme
|
||||
|
||||
theme.set_scale(args.scale)
|
||||
@@ -302,15 +130,25 @@ def main() -> int:
|
||||
game = args.game or (library.games()[0]["package"] if library.games() else None)
|
||||
steps = [("library", lambda a: a.navigate(0)), ("frame", lambda a: a.navigate(1)),
|
||||
("files", lambda a: a.go("files")), ("screenshots", lambda a: a.go("screenshots")),
|
||||
("live", lambda a: a.go("live")), ("tools", lambda a: a.go("settings"))]
|
||||
("live", lambda a: a.go("live")), ("live-streaming", fake_live_stream),
|
||||
("keyboard", lambda a: (stop_fake_live(a), a.go("keyboard"))),
|
||||
("monitor", lambda a: a.go("monitor")), ("monitor-details", open_monitor_details),
|
||||
("tools", lambda a: a.go("settings")),
|
||||
# the index on the left: "This PC" scrolls the page there
|
||||
("settings-index", lambda a: a.page.run_task(a.settings_view.show_section, "pc"))]
|
||||
if game:
|
||||
steps.insert(1, ("game", lambda a: a.open_game(game)))
|
||||
steps.insert(2, ("game-customize", lambda a: a.open_game(game, advanced=True)))
|
||||
steps += [("share-dialog", lambda a: a.share_config_dialog(game)),
|
||||
("report-dialog", lambda a: (a.page.pop_dialog(), a.report_problem_dialog(game))),
|
||||
("custom-art-dialog", lambda a: (a.page.pop_dialog(), a.custom_artwork(game)))]
|
||||
# a pretend install of --game, mid-upload: the transit in the sidebar, the game page and Activity
|
||||
steps += [("transit-game", lambda a: (a.page.pop_dialog(), start_fake_install(a, game), a.open_game(game))),
|
||||
("transit-activity", lambda a: a.show_activity(True))]
|
||||
if args.fake_frame: # GitHub #90: the Move to… dialog (drives load in the background)
|
||||
steps.append(("move-dialog", lambda a: (a.page.pop_dialog(), a.move_game(game))))
|
||||
# last: the right-click menu stays open over whatever comes next
|
||||
steps.append(("library-menu", lambda a: (a.page.pop_dialog(), a.navigate(0), time.sleep(3),
|
||||
steps.append(("library-menu", lambda a: (a.show_activity(False), a.navigate(0), time.sleep(3),
|
||||
a.library_view.open_menu(game))))
|
||||
if args.docs:
|
||||
steps = [("library", lambda a: a.navigate(0))]
|
||||
@@ -323,12 +161,66 @@ def main() -> int:
|
||||
for e in a.files_view.entries[1:3]]))
|
||||
steps.append(("screenshots", lambda a: a.go("screenshots")))
|
||||
steps.append(("screenshot-viewer", lambda a: a.screenshots_view.viewer(0)))
|
||||
steps.append(("type-on-frame", lambda a: (a.page.pop_dialog(), open_type_dialog(a))))
|
||||
steps.append(("type-on-frame", lambda a: (a.page.pop_dialog(), open_type_tab(a))))
|
||||
steps.append(("monitor", lambda a: a.go("monitor")))
|
||||
steps.append(("power-confirm", lambda a: (a.page.pop_dialog(), a.frame_power("restart"))))
|
||||
mouse: dict[str, callable] = {} # step name -> mouse actions (Playwright page) after its screenshot
|
||||
if args.gestures:
|
||||
STEP_SECONDS = 14 # the mouse actions run after each step's screenshot, before the next step
|
||||
# step name -> mouse actions (Playwright page) after its screenshot, then a "-mouse" screenshot unless the
|
||||
# actions return True (they saved their own picture, e.g. an opened menu)
|
||||
mouse: dict[str, callable] = {}
|
||||
hover: dict[str, tuple[float, float]] = {} # step name -> where the mouse rests for its screenshot
|
||||
if args.hover:
|
||||
hover["library"] = tuple(float(v) for v in args.hover.split(","))
|
||||
if not args.docs and args.viewport == "1440x900": # menus that open from buttons (positions at this size)
|
||||
def open_and_shoot(x, y, name):
|
||||
def run(page):
|
||||
page.mouse.click(x, y)
|
||||
time.sleep(2)
|
||||
page.screenshot(path=str(args.out / f"{name}.png"))
|
||||
page.mouse.click(1420, 880) # outside the menu (Flutter's popup ignores Escape)
|
||||
return True
|
||||
return run
|
||||
mouse["library"] = open_and_shoot(1354, 54, "library-add-menu")
|
||||
# type to search: click an empty part of the header, then type (the "-mouse" shot shows "arc" + the matches)
|
||||
steps.insert(1, ("library-typed", lambda a: a.library_view.clear_search()))
|
||||
def typed(page):
|
||||
page.mouse.click(480, 60)
|
||||
time.sleep(0.5)
|
||||
page.keyboard.type("arc", delay=120)
|
||||
if args.fake_frame: # the matches' cover buttons: Install (Arcsmith, not installed), Update (Pinball FX)
|
||||
time.sleep(PAINT_SECONDS)
|
||||
for name, pt in (("library-install-hover", (742, 215)), ("library-install-button", (742, 276)),
|
||||
("library-update-button", (357, 276))):
|
||||
page.mouse.move(*pt, steps=8)
|
||||
time.sleep(1.2)
|
||||
page.screenshot(path=str(args.out / f"{name}.png"))
|
||||
page.mouse.move(1300, 700)
|
||||
mouse["library-typed"] = typed
|
||||
steps.insert(2, ("library-cleared", lambda a: a.library_view.clear_search()))
|
||||
if args.fake_frame: # the "On your Frame" shelf's first card, hovered: its Play button shows
|
||||
steps.insert(3, ("library-shelf-hover", lambda a: None))
|
||||
hover["library-shelf-hover"] = (403, 268)
|
||||
# the grid's first card: hovered (lift, zoom, the glass button), the pointer on its button, then Play:
|
||||
# the portal rings mid-ripple and the "Starting on Frame…" pill
|
||||
steps.insert(4, ("library-card-hover", lambda a: None))
|
||||
hover["library-card-hover"] = (357, 420)
|
||||
steps.insert(5, ("library-card-button", lambda a: None))
|
||||
hover["library-card-button"] = (357, 497)
|
||||
|
||||
def launch(page):
|
||||
page.mouse.move(357, 497)
|
||||
time.sleep(1.2)
|
||||
page.mouse.click(357, 497)
|
||||
for i in range(6): # the launch, frame by frame (rings, then the pill)
|
||||
time.sleep(0.15)
|
||||
page.screenshot(path=str(args.out / f"library-play-launch-{i}.png"))
|
||||
time.sleep(1.0)
|
||||
page.screenshot(path=str(args.out / "library-play-starting.png"))
|
||||
page.mouse.move(130, 520)
|
||||
return True
|
||||
mouse["library-card-button"] = launch
|
||||
if game:
|
||||
mouse["game"] = open_and_shoot(491, 306, "game-more-menu") # the hero's "…"
|
||||
if args.gestures: # the mouse actions run after each step's screenshot, before the next step
|
||||
def drag(*points):
|
||||
def run(page):
|
||||
page.mouse.move(*points[0])
|
||||
@@ -365,11 +257,12 @@ def main() -> int:
|
||||
"files-dragged": right_click(900, 320), # a selected one: "… 3 items"
|
||||
"files-menu": lambda page: (escape(page), time.sleep(0.5), right_click(900, 600)(page)),
|
||||
"files-space-menu": escape,
|
||||
"screenshots": drag((680, 280), (950, 280), (950, 430)), # 3 shots
|
||||
"screenshots-dragged": right_click(950, 430),
|
||||
"screenshots": drag((400, 300), (680, 300), (950, 300)), # 3 shots (the first row)
|
||||
"screenshots-dragged": right_click(950, 300),
|
||||
"screenshots-menu": escape,
|
||||
"library": drag((360, 300), (560, 300), (760, 300)), # 3 cards, select mode on
|
||||
"library-dragged": drag((560, 300), (760, 300))} # from a selected card: deselects 2
|
||||
# the grid's first row (below the "On your Frame" shelf)
|
||||
"library": drag((360, 560), (560, 560), (760, 560)), # 3 cards, select mode on
|
||||
"library-dragged": drag((560, 560), (760, 560))} # from a selected card: deselects 2
|
||||
if args.linux:
|
||||
def linux_filter(a, value):
|
||||
a.navigate(0)
|
||||
@@ -381,7 +274,68 @@ def main() -> int:
|
||||
("linux-folder-customize", lambda a: a.open_game(LINUX_FOLDER, advanced=True)),
|
||||
("linux-change-program", lambda a: a.choose_exe(LINUX_FOLDER)),
|
||||
("frame", lambda a: (a.page.pop_dialog(), a.navigate(1))),
|
||||
("linux-menu", lambda a: (a.navigate(0), time.sleep(3), a.library_view.open_menu(LINUX_APPIMAGE)))]
|
||||
("linux-move", lambda a: a.move_game(LINUX_APPIMAGE) if args.fake_frame else None),
|
||||
("linux-menu", lambda a: (a.page.pop_dialog(), a.navigate(0), time.sleep(3),
|
||||
a.library_view.open_menu(LINUX_APPIMAGE)))]
|
||||
if args.links:
|
||||
from frameport import deeplink
|
||||
from frameport.ui.views import link_dialog
|
||||
|
||||
fake = deeplink.Manifest("Example Game", [
|
||||
deeplink.ManifestFile("https://cdn.example.com/example-game-arm64.apk", "ab" * 32),
|
||||
deeplink.ManifestFile("https://cdn.example.com/main.1.com.example.game.obb")],
|
||||
"https://example.com/example-game.framedrop.json",
|
||||
description="A puzzle adventure across floating islands: build bridges, bend light and find your way home. "
|
||||
"Room-scale or seated, with smooth or snap turning.",
|
||||
icon="https://example.com/icon.png")
|
||||
sizes = {fake.files[0].url: 412_000_000, fake.files[1].url: 1_900_000_000}
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
from frameport.core.paths import user_data_dir
|
||||
|
||||
icon = user_data_dir() / "downloads" / "icons" / "smoke-example.png" # a stand-in for the downloaded icon
|
||||
icon.parent.mkdir(parents=True, exist_ok=True)
|
||||
im = Image.new("RGBA", (256, 256), (0, 0, 0, 0))
|
||||
ImageDraw.Draw(im).rounded_rectangle((8, 8, 248, 248), 48, fill=(124, 92, 255, 255))
|
||||
ImageDraw.Draw(im).ellipse((72, 72, 184, 184), fill=(255, 214, 102, 255))
|
||||
im.save(icon)
|
||||
|
||||
steps = [("library", lambda a: a.navigate(0)),
|
||||
("links-paste", lambda a: a.pick_link()),
|
||||
("links-confirm", lambda a: (a.page.pop_dialog(), link_dialog._confirm(a, fake, sizes, False, icon))),
|
||||
("links-settings", lambda a: (a.page.pop_dialog(), a.go("settings")))]
|
||||
if game:
|
||||
steps.append(("links-display-mode", lambda a: a.open_game(game, advanced=True)))
|
||||
def add_menu_open(page):
|
||||
page.mouse.click(1194, 94) # Add games (1280-wide viewport)
|
||||
time.sleep(2)
|
||||
page.screenshot(path=str(args.out / "library-add-menu.png"))
|
||||
page.mouse.click(120, 520) # outside the menu (Flutter's popup ignores Escape)
|
||||
return True
|
||||
# tall pages: run with e.g. --viewport 1280x3200 (at 1440x900 the tour's own Add games click is kept)
|
||||
mouse.setdefault("library", add_menu_open)
|
||||
if args.themes:
|
||||
from frameport.ui import theme as T
|
||||
from frameport.ui.app import themes_dir
|
||||
|
||||
T.load_user_themes(themes_dir()) # installed theme files are switched through too
|
||||
|
||||
def switch(name):
|
||||
def run(a):
|
||||
library.set_setting("ui.theme", name) # what the picker does
|
||||
a.restyle(name)
|
||||
return run
|
||||
|
||||
def appearance(a):
|
||||
"""Settings: Appearance is its first section."""
|
||||
a.go("settings")
|
||||
steps = [("appearance", appearance)]
|
||||
for name in [n for n in T.THEMES if n != T.THEME] + [T.THEME]:
|
||||
steps.append((f"{name}-switched", switch(name)))
|
||||
steps.append((f"{name}-appearance", appearance))
|
||||
steps.append((f"{name}-library", lambda a: a.navigate(0)))
|
||||
if game:
|
||||
steps.append((f"{name}-game", lambda a: a.open_game(game)))
|
||||
if args.usb_setup:
|
||||
def continue_usb(a):
|
||||
dialog = [d for d in a.page._dialogs.controls if d.open and type(d).__name__ == "AlertDialog"][-1]
|
||||
@@ -409,14 +363,48 @@ def main() -> int:
|
||||
steps = [("library", lambda a: a.navigate(0)), ("questions", open_questions),
|
||||
("after-1st-double", double_click), ("after-2nd-double", double_click), ("end", report)]
|
||||
if args.update:
|
||||
from frameport import updates
|
||||
from frameport import __version__, updates
|
||||
|
||||
notes = ("FramePort v9.9.9: Windows (x64), macOS (Apple Silicon) and Linux (x64, ARM64).\n\n## What's new\n\n"
|
||||
"- Self-update test release: the update dialog shows every version since yours\n"
|
||||
"- **Bold** and `code` in notes, and a [link](https://example.invalid)\n- A third bullet\n\n"
|
||||
"Already have FramePort? It offers this update itself (Library → **Update now**).\n\n## Install\n\n"
|
||||
"- footer that the changelog leaves out\n")
|
||||
fake = updates.Update(version="9.9.9", tag="v9.9.9", page="https://example.invalid", asset=None, asset_url=None,
|
||||
sums_url=None, wheel_url=None,
|
||||
notes="## What's new\n- Self-update test release\n- **Bold** and `code` in notes")
|
||||
sums_url=None, wheel_url=None, notes=notes, published="2026-10-08T10:00:00Z")
|
||||
major, minor, _patch = updates.parse_version(__version__)[:3]
|
||||
older = f"{major}.{max(minor - 1, 0)}"
|
||||
|
||||
def entry(version, date, body):
|
||||
return updates.ChangelogEntry(version=version, tag=f"v{version}", date=date, title=f"FramePort v{version}",
|
||||
body=body, page="https://example.invalid",
|
||||
dev=updates.is_dev_version(version))
|
||||
fake_log = [updates.entry_from_update(fake),
|
||||
entry("9.9.8", "2026-10-06", "- Install links from FrameDrop buttons\n- Faster uploads over USB"),
|
||||
entry("9.9.7", "2026-10-04", "- Monitor tab with live Frame stats"),
|
||||
entry(__version__, "2026-10-02", "- The version you have: **Live view** with sound\n"
|
||||
"- Files tab: drag and drop\n- Smaller fixes"),
|
||||
entry(f"{older}.3", "2026-09-30", "- Proton defaults to the newest stable build"),
|
||||
entry(f"{older}.2", "2026-09-28", "- Language packs")]
|
||||
updates.fetch_changelog = lambda force=False, need=None: list(fake_log) # no GitHub in screenshots
|
||||
|
||||
def news(a):
|
||||
a.updater._set(None)
|
||||
a.updater.news = updates.recent_history(fake_log, n=3)
|
||||
a.navigate(0)
|
||||
a.refresh_view()
|
||||
|
||||
def settings_updates(a):
|
||||
a.go("settings")
|
||||
# once the page is mounted: scrolling an unmounted column does nothing
|
||||
threading.Timer(1.0, lambda: a.page.run_task(a.settings_view.show_section, "updates")).start()
|
||||
steps += [("update-banner", lambda a: (a.updater._set(fake), a.navigate(0))),
|
||||
("update-dialog", lambda a: a.updater.show_dialog()),
|
||||
("update-settings", lambda a: (a.page.pop_dialog(), a.go("settings")))]
|
||||
("update-settings", lambda a: (a.page.pop_dialog(), settings_updates(a))),
|
||||
("update-whats-new-bar", lambda a: news(a)),
|
||||
("update-whats-new-dialog", lambda a: a.updater.show_news()),
|
||||
("update-settings-changelog", lambda a: (a.page.pop_dialog(), settings_updates(a),
|
||||
a.updater.show_history()))]
|
||||
if args.frame:
|
||||
from frameport.frame.connection import parse_target
|
||||
|
||||
@@ -439,53 +427,73 @@ def main() -> int:
|
||||
steps.append(("game-connected", lambda a: a.open_game(game)))
|
||||
if not args.no_test:
|
||||
steps.append(("launch-test-job", job))
|
||||
ready, done = threading.Event(), []
|
||||
if args.only: # in the order given (e.g. frame-connected,monitor)
|
||||
by_name = dict(steps)
|
||||
steps = [(n, by_name[n]) for n in args.only.split(",") if n in by_name]
|
||||
# a first screen while the web fonts load: shot before that, text measured with a fallback font wrapped or
|
||||
# overlapped ("Q / uest", a check mark over its pill's text); its picture is 00-warmup.png. Settings, not the
|
||||
# Library: opening the Library twice restarts its card loading and the next shot caught it empty
|
||||
steps.insert(0, ("warmup", lambda a: a.go("settings")))
|
||||
ready, shot_done, done = threading.Event(), threading.Event(), []
|
||||
|
||||
from frameport.ui.app import serialize_flet_updates
|
||||
|
||||
serialize_flet_updates() # as the app's main() does
|
||||
if args.fake_frame: # never reach a real Frame (start-up auto-connect, discovery, the 30 s poll)
|
||||
from frameport.frame import keyboard
|
||||
|
||||
keyboard.KeyboardSession = FakeKeyboardSession
|
||||
FramePortApp.connect = lambda self, *a, **k: None
|
||||
FramePortApp.refresh_frame = lambda self, *a, **k: None
|
||||
install_fakes(game)
|
||||
|
||||
def app_main(page: ft.Page):
|
||||
try:
|
||||
app = FramePortApp(page)
|
||||
if args.fake_frame:
|
||||
app.target = FakeTarget()
|
||||
app.frame_info, app.frame_state = app.target.describe(), "connected"
|
||||
attach_fake_frame(app)
|
||||
except Exception: # noqa: BLE001
|
||||
ERRORS.append("startup: " + traceback.format_exc())
|
||||
return
|
||||
threading.Thread(target=driver, args=(app, steps, ready, done), daemon=True).start()
|
||||
threading.Thread(target=driver, args=(app, steps, ready, shot_done, done), daemon=True).start()
|
||||
|
||||
def shooter():
|
||||
# wait until the app's web server listens (a fixed 6 s was too short with another smoke run on the machine)
|
||||
import socket
|
||||
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
time.sleep(6)
|
||||
for _ in range(90):
|
||||
try:
|
||||
socket.create_connection(("127.0.0.1", PORT), timeout=1).close()
|
||||
break
|
||||
except OSError:
|
||||
time.sleep(1)
|
||||
time.sleep(2)
|
||||
try:
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(args=["--use-gl=swiftshader", "--enable-unsafe-swiftshader"])
|
||||
page = browser.new_page(viewport={"width": vw, "height": vh})
|
||||
page.goto(f"http://127.0.0.1:{PORT}", wait_until="networkidle", timeout=120_000)
|
||||
shot = 0
|
||||
deadline = time.time() + 240 + 8 * len(steps)
|
||||
while len(done) < len(steps) and time.time() < deadline:
|
||||
if ready.wait(1):
|
||||
ready.clear()
|
||||
name = done[-1]
|
||||
time.sleep(3) # let Flutter paint
|
||||
if args.hover and name == "library":
|
||||
hx, hy = (float(v) for v in args.hover.split(","))
|
||||
page.mouse.move(hx, hy)
|
||||
shot = handled = 0
|
||||
while handled < len(steps): # one hand-off per step (see driver)
|
||||
if not ready.wait(STEP_TIMEOUT):
|
||||
ERRORS.append(f"browser: no step after {done[-1] if done else 'start'} "
|
||||
f"within {STEP_TIMEOUT} s")
|
||||
break
|
||||
ready.clear()
|
||||
name = done[-1]
|
||||
try:
|
||||
time.sleep(PAINT_SECONDS)
|
||||
if name in hover:
|
||||
page.mouse.move(*hover[name])
|
||||
time.sleep(1.5)
|
||||
page.screenshot(path=str(args.out / f"{shot:02d}-{name}.png"))
|
||||
shot += 1
|
||||
if name in mouse:
|
||||
mouse[name](page)
|
||||
time.sleep(2)
|
||||
if name in hover:
|
||||
page.mouse.move(130, 520) # the sidebar's empty part: nothing left hovered
|
||||
if name in mouse and mouse[name](page) is not True:
|
||||
time.sleep(PAINT_SECONDS) # e.g. typed search: the matching cards fade in
|
||||
page.screenshot(path=str(args.out / f"{shot:02d}-{name}-mouse.png"))
|
||||
shot += 1
|
||||
finally:
|
||||
handled += 1
|
||||
shot_done.set()
|
||||
browser.close()
|
||||
except Exception: # noqa: BLE001
|
||||
ERRORS.append("browser: " + traceback.format_exc())
|
||||
|
||||
|
After Width: | Height: | Size: 248 KiB |
@@ -9,19 +9,84 @@ from pathlib import Path
|
||||
from ..apk import axml
|
||||
from ..core.models import Analysis
|
||||
from . import elf
|
||||
from .unity_split import split_build as unity_split_build
|
||||
|
||||
logging.getLogger("pyaxmlparser").setLevel(logging.ERROR)
|
||||
|
||||
UNITY_GGM = "assets/bin/Data/globalgamemanagers"
|
||||
IL2CPP_METADATA = "assets/bin/Data/Managed/Metadata/global-metadata.dat"
|
||||
|
||||
# The version of what analyze() stores (Analysis.extra["analysis_version"]). BUMP IT whenever analyze() gains a field
|
||||
# or detects something differently that patches/heuristics read: library entries analysed by an older FramePort are
|
||||
# then analysed again in the background at the next start (pipeline.refresh_analyses), so their new patches are
|
||||
# offered (GitHub #104: entries from before `sdl_java` never got frame.sdl_clipboard). Entries without it are 0.
|
||||
# 1: sdl_java, min_sdk, web_wrapper, expects_obb, vr_activity, unity_version (2026-10)
|
||||
# 2: unity_split (a Unity split-binary build expects an OBB too: expects_obb) (2026-10)
|
||||
# 3: unreal_ovrp_lookups (the OVRPlugin functions Unreal's Oculus module looks up: frame.unreal_ovrp_entrypoints)
|
||||
ANALYSIS_VERSION = 3
|
||||
|
||||
def _read_manifest_info(path: Path) -> tuple[str, str, str, str | None]:
|
||||
|
||||
# Android versions by API level (for messages); the Frame's Lepton container runs Android 11 (API 30)
|
||||
ANDROID_VERSIONS = {29: "10", 30: "11", 31: "12", 32: "12L", 33: "13", 34: "14", 35: "15", 36: "16", 37: "17"}
|
||||
FRAME_API = 30
|
||||
# Quest games declare up to API 32 (Quest's Android 12L) and run on the Frame (OVRPort lowers minSdk to 29; they
|
||||
# don't call newer Android classes). From API 33 on, apps call Android 13+ classes at start (GitHub #71/#72: minSdk
|
||||
# 34, NoClassDefFoundError android/window/OnBackInvokedCallback, NoSuchMethodError VarHandle.storeStoreFence).
|
||||
MAX_RUNNABLE_MIN_SDK = 32
|
||||
|
||||
|
||||
def android_version(api: int) -> str:
|
||||
"""'14' for API 34."""
|
||||
return ANDROID_VERSIONS.get(api, f"API {api}")
|
||||
|
||||
|
||||
def too_new_android(min_sdk: int | None) -> bool:
|
||||
"""The APK needs a newer Android than the Frame's Lepton (11): it crashes at start on missing Android classes."""
|
||||
return bool(min_sdk) and min_sdk > MAX_RUNNABLE_MIN_SDK
|
||||
|
||||
|
||||
TWA_URL_KEY = "android.support.customtabs.trusted.DEFAULT_URL"
|
||||
TWA_ACTIVITY = "com.google.androidbrowserhelper.trusted.LauncherActivity"
|
||||
UE_OBB_KEY = ".GameActivity.bHasOBBFiles" # com.epicgames.ue4.… (UE4) / com.epicgames.unreal.… (UE5)
|
||||
|
||||
|
||||
def expects_obb(meta: dict) -> bool:
|
||||
"""Unreal packaged the game's content as an OBB (expansion file) and opens it at start."""
|
||||
return any(k.endswith(UE_OBB_KEY) and v in (True, "true", "True") for k, v in meta.items())
|
||||
|
||||
|
||||
def _read_manifest_info(path: Path):
|
||||
"""(package, versionName, label, main activity, pyaxmlparser APK)."""
|
||||
from pyaxmlparser import APK
|
||||
|
||||
apk = APK(str(path))
|
||||
label = apk.application or apk.package
|
||||
return apk.package, apk.version_name or "", label, apk.get_main_activity()
|
||||
return apk.package, apk.version_name or "", label, apk.get_main_activity(), apk
|
||||
|
||||
|
||||
def _resolve_string(apk, value) -> str | None:
|
||||
"""A meta-data value: the string itself, or a @string/… reference resolved through resources.arsc."""
|
||||
if isinstance(value, str):
|
||||
return value
|
||||
if apk is None or isinstance(value, bool) or not isinstance(value, int):
|
||||
return None
|
||||
try:
|
||||
res = apk.get_android_resources()
|
||||
for _config, v in (res.get_resolved_res_configs(value) if res else ()):
|
||||
if isinstance(v, str) and v:
|
||||
return v
|
||||
except Exception: # noqa: BLE001 - a broken resource table only loses the URL
|
||||
pass
|
||||
return None
|
||||
|
||||
|
||||
def web_wrapper(meta: dict, manifest_strings: list[str], apk=None) -> dict | None:
|
||||
"""A Trusted Web Activity (Bubblewrap, Meta's PWA packaging): the APK only opens a website in a browser app
|
||||
(Meta's com.oculus.browser on Quest), which Lepton doesn't have (GitHub #86). {"url": str | None} or None."""
|
||||
if TWA_URL_KEY not in meta and TWA_ACTIVITY not in manifest_strings:
|
||||
return None
|
||||
url = _resolve_string(apk, meta.get(TWA_URL_KEY))
|
||||
return {"url": url if url and url.startswith(("https://", "http://")) else None}
|
||||
|
||||
|
||||
def _unreal_version(z: zipfile.ZipFile, lib: str) -> str | None:
|
||||
@@ -111,8 +176,10 @@ def analyze(path: Path, deep: bool = True, data_bytes: int | None = None) -> Ana
|
||||
if "assets/bin/Data/boot.config" in names else "")
|
||||
ggm = z.read(UNITY_GGM) if deep and UNITY_GGM in names else None
|
||||
il2cpp_meta = z.read(IL2CPP_METADATA) if deep and IL2CPP_METADATA in names and "libil2cpp.so" in libs else None
|
||||
# a Unity split build: the rest of the game is in a zip OBB (analysis/unity_split.py)
|
||||
unity_split = "libunity.so" in libs and unity_split_build(z, names, ggm, deep)
|
||||
|
||||
package, version, label, activity = _read_manifest_info(path)
|
||||
package, version, label, activity, apk_info = _read_manifest_info(path)
|
||||
libset = set(libs)
|
||||
engine = ("Unreal" if libset & {"libUE4.so", "libUnreal.so"} else "Unity" if "libunity.so" in libset
|
||||
else "CryEngine" if "libCrySystem.so" in libset else "Other")
|
||||
@@ -159,6 +226,7 @@ def analyze(path: Path, deep: bool = True, data_bytes: int | None = None) -> Ana
|
||||
manifest_strings = axml.Axml(manifest).strings()
|
||||
features = _features(manifest)
|
||||
used_perms, _ = axml.used_and_declared_permissions(manifest)
|
||||
meta = axml.meta_data(manifest)
|
||||
return Analysis(
|
||||
package=package,
|
||||
version=version,
|
||||
@@ -178,6 +246,7 @@ def analyze(path: Path, deep: bool = True, data_bytes: int | None = None) -> Ana
|
||||
is_overport_output=is_overport,
|
||||
debuggable=bool(axml.Axml(manifest).get_bool("application", "debuggable")),
|
||||
extra={
|
||||
"analysis_version": ANALYSIS_VERSION,
|
||||
"frame_patched": "libframe_settings.so" in libset, # already has FramePort's FrameBridge adapter
|
||||
# Team Beef's TBXR ports pick their OpenXR path by headset maker (frame.tbxr_vendor): their libraries
|
||||
# the game asks Meta's platform for asset files (content shipped as separate files, frame.asset_files)
|
||||
@@ -216,10 +285,37 @@ def analyze(path: Path, deep: bool = True, data_bytes: int | None = None) -> Ana
|
||||
# a 2D launcher activity that starts a separate VR activity (frame.start_activity)
|
||||
"vr_activity": axml.vr_activity(manifest),
|
||||
"unity_version": unity_version(ggm, lib_bytes.get("libunity.so")) if engine == "Unity" else None,
|
||||
# the minimum Android version the APK declares (read from the original: OVRPort lowers it to 29)
|
||||
"min_sdk": axml.min_sdk(manifest),
|
||||
# a website in an Android wrapper (TWA): nothing to port
|
||||
"web_wrapper": web_wrapper(meta, manifest_strings, apk_info),
|
||||
# Unreal packaged its content as an OBB (expansion file), or a Unity split build keeps all but its first
|
||||
# scene in one: without it the game hangs at start (GitHub #85, #92)
|
||||
"expects_obb": expects_obb(meta) or unity_split,
|
||||
"unity_split": unity_split,
|
||||
# Unreal's Oculus module needs every OVRPlugin function it looks up (frame.unreal_ovrp_entrypoints)
|
||||
"unreal_ovrp_lookups": (ovrp_lookups(lib_bytes.get(engine_lib.rsplit("/", 1)[1], b""))
|
||||
if engine_lib and "libOVRPlugin.so" in libset else []),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def ovrp_lookups(data: bytes) -> list[str]:
|
||||
"""The OVRPlugin function names (`ovrp_*` strings) an engine library holds: Unreal's Oculus module looks each one
|
||||
up with dlsym in libOVRPlugin.so and gives up on VR when any is missing (FOculusHMDModule::
|
||||
InitializeOculusPluginWrapper)."""
|
||||
names, at = set(), data.find(b"\0ovrp_")
|
||||
while at >= 0:
|
||||
end = data.find(b"\0", at + 1)
|
||||
if end < 0:
|
||||
break
|
||||
name = data[at + 1:end]
|
||||
if re.fullmatch(rb"ovrp_[A-Za-z0-9_]+", name):
|
||||
names.add(name.decode())
|
||||
at = data.find(b"\0ovrp_", end)
|
||||
return sorted(names)
|
||||
|
||||
|
||||
def unity_text_fields(metadata: bytes) -> list[str]:
|
||||
"""The Unity text field classes an IL2CPP game contains (names from its global-metadata.dat string table)."""
|
||||
out = []
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""Native arm64 Linux apps for the Frame (GitHub #31): an AppImage, a folder, or a .zip/.tar.* archive with an
|
||||
aarch64 program. Finds the program to start, checks the CPU architecture (x86_64 builds can't run natively) and
|
||||
"""Linux apps for the Frame (GitHub #31): an AppImage, a folder, or a .zip/.tar.* archive with an aarch64 program
|
||||
(or an x86_64 one, which the Frame runs through FEX). Finds the program to start, checks the CPU architecture and
|
||||
whether it's an OpenXR (VR) app. Archives are unpacked once into FramePort's data folder, so installs upload a
|
||||
plain folder like PC VR games do."""
|
||||
from __future__ import annotations
|
||||
@@ -102,6 +102,60 @@ def _desktop_name(root: Path) -> str | None:
|
||||
return None
|
||||
|
||||
|
||||
def _png_width(path: Path) -> int | None:
|
||||
try:
|
||||
with open(path, "rb") as f:
|
||||
head = f.read(24)
|
||||
except OSError:
|
||||
return None
|
||||
if head[:8] != b"\x89PNG\r\n\x1a\n" or len(head) < 24:
|
||||
return None
|
||||
return int.from_bytes(head[16:20], "big")
|
||||
|
||||
|
||||
def find_icon(root: Path) -> Path | None:
|
||||
"""The app's own icon in a folder (GitHub #99): the Icon= of its bundled .desktop file, looked up next to the
|
||||
file, in (usr/)share/icons/hicolor/<size>/apps and (usr/)share/pixmaps, or a top-level .DirIcon; the biggest PNG
|
||||
(the PC can't draw SVG icons; the Frame's agent uses those for Desktop Mode). Nothing outside `root` (symlinks
|
||||
are resolved and checked). AppImages are read on the Frame instead (their files are compressed)."""
|
||||
root = Path(root)
|
||||
try:
|
||||
real_root = root.resolve()
|
||||
except OSError:
|
||||
return None
|
||||
paths = [root / ".DirIcon"]
|
||||
desktops = [p for p in sorted(root.rglob("*.desktop"))[:5] if len(p.relative_to(root).parts) <= 4]
|
||||
for desktop in desktops:
|
||||
m = re.search(r"^Icon=(.+)$", desktop.read_text(encoding="utf-8", errors="replace"), re.M)
|
||||
name = m.group(1).strip() if m else ""
|
||||
if not name or name.startswith("/") or ".." in name.split("/"):
|
||||
continue
|
||||
stem = re.sub(r"\.(png|svg|xpm)$", "", name, flags=re.I)
|
||||
bases = [root] + [d for d in desktop.parents if d != root and real_root in d.resolve().parents]
|
||||
for base in bases:
|
||||
paths += [base / name, base / f"{stem}.png"]
|
||||
for share in (base / "usr" / "share", base / "share"):
|
||||
paths += sorted(share.glob(f"icons/hicolor/*/apps/{glob_escape(stem)}.png"))
|
||||
paths.append(share / "pixmaps" / f"{stem}.png")
|
||||
break
|
||||
best: tuple[int, Path] | None = None
|
||||
for p in paths:
|
||||
try:
|
||||
real = p.resolve()
|
||||
if real_root not in real.parents or not real.is_file() or real.stat().st_size > 4 << 20:
|
||||
continue
|
||||
except OSError:
|
||||
continue
|
||||
width = _png_width(real)
|
||||
if width and (best is None or width > best[0]):
|
||||
best = (width, real)
|
||||
return best[1] if best else None
|
||||
|
||||
|
||||
def glob_escape(text: str) -> str:
|
||||
return re.sub(r"([*?\[])", r"[\1]", text)
|
||||
|
||||
|
||||
def rank_programs(root: Path) -> list[tuple[Path, int]]:
|
||||
"""(ELF program, machine) candidates, best first: the .desktop Exec= name, then a name like the folder's, then
|
||||
shallow and big ones. Libraries (*.so*) are never programs."""
|
||||
@@ -147,8 +201,14 @@ def uses_openxr(paths: list[Path]) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def runs_on_frame(machine: int | None) -> bool:
|
||||
"""aarch64 natively, x86_64 through FEX (x86 translation, slower)."""
|
||||
return machine in (EM_AARCH64, EM_X86_64)
|
||||
|
||||
|
||||
def inspect(path: Path) -> dict:
|
||||
"""{root, exe (relative to root), appimage, machine, arch_ok, openxr, title, candidates} for an AppImage, a
|
||||
"""{root, exe (relative to root), appimage, machine, arch_ok (aarch64: native), openxr, title, candidates} for an
|
||||
AppImage, a
|
||||
folder or an archive. Raises ValueError when there's no Linux program in it."""
|
||||
path = Path(path)
|
||||
if path.is_file() and is_archive(path):
|
||||
@@ -174,6 +234,11 @@ def inspect(path: Path) -> dict:
|
||||
programs = rank_programs(root)
|
||||
if not programs:
|
||||
raise ValueError(f"no Linux program found in {path.name}")
|
||||
# an arm64 build wins; x86_64 programs only when there is nothing else (they run through FEX on the Frame)
|
||||
for want in (EM_AARCH64, EM_X86_64):
|
||||
if any(m == want for _p, m in programs):
|
||||
programs = [(p, m) for p, m in programs if m == want]
|
||||
break
|
||||
appimages = [p for p, _m in programs if is_appimage(p)]
|
||||
exe, machine = (appimages[0], elf_machine(appimages[0])) if appimages else programs[0]
|
||||
libs = app_libraries(root, exe)
|
||||
@@ -181,4 +246,4 @@ def inspect(path: Path) -> dict:
|
||||
return {"root": str(root), "exe": exe.relative_to(root).as_posix(), "files": None,
|
||||
"appimage": is_appimage(exe), "machine": machine, "arch_ok": machine == EM_AARCH64,
|
||||
"openxr": uses_openxr([exe] + libs), "title": title,
|
||||
"candidates": [p.relative_to(root).as_posix() for p, m in programs[:20] if m == EM_AARCH64]}
|
||||
"candidates": [p.relative_to(root).as_posix() for p, m in programs[:20] if m == machine]}
|
||||
@@ -24,12 +24,21 @@ def _elf_hash(name: bytes) -> int:
|
||||
return h
|
||||
|
||||
|
||||
def build_stub_library(symbols: list[str], soname: str = "libovrstubs.so", abi: str = "arm64-v8a") -> bytes:
|
||||
def build_stub_library(symbols: list[str], soname: str = "libovrstubs.so", abi: str = "arm64-v8a",
|
||||
result: int = 0) -> bytes:
|
||||
"""`result`: what every function returns (a 32-bit int; arm64 only for values other than 0), e.g. OVRPlugin's
|
||||
ovrpFailure (-1000) for stand-ins whose callers must not trust untouched output arguments."""
|
||||
is64 = abi == "arm64-v8a"
|
||||
symbols = sorted(set(symbols))
|
||||
if result and not (is64 and -0x10000 <= result <= 0xFFFF):
|
||||
raise ValueError(f"stub result {result} not supported for {abi}")
|
||||
if is64:
|
||||
machine, ehsize, phentsize, shentsize, symsize, dynsize = 183, 64, 56, 64, 24, 16 # EM_AARCH64
|
||||
body = struct.pack("<II", 0xD2800000, 0xD65F03C0) # mov x0, #0 ; ret
|
||||
if result > 0: # movz w0, #result ; ret
|
||||
body = struct.pack("<II", 0x52800000 | result << 5, 0xD65F03C0)
|
||||
elif result < 0: # movn w0, #~result ; ret (w0 = result)
|
||||
body = struct.pack("<II", 0x12800000 | (~result & 0xFFFF) << 5, 0xD65F03C0)
|
||||
else:
|
||||
machine, ehsize, phentsize, shentsize, symsize, dynsize = 40, 52, 32, 40, 16, 8 # EM_ARM
|
||||
body = struct.pack("<II", 0xE3A00000, 0xE12FFF1E) # mov r0, #0 ; bx lr
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
"""Unity "split application binary" builds: the APK keeps the first scene, the rest of the game is a zip OBB
|
||||
(main.<versionCode>.<package>.obb holding assets/bin/Data/...). Without it the game starts into nothing.
|
||||
|
||||
Two signs, either is enough (checked against 48 Unity APKs, 30 games: all 13 split builds flagged, none of the 17 full
|
||||
builds, whose OBBs, where they have one, are asset bundles or sound banks):
|
||||
A an XR-plugin build (Oculus XR Plugin / Unity OpenXR library) without assets/bin/Data/UnitySubsystems/ in the APK:
|
||||
the split moves the UnitySubsystems manifests into the OBB; full XR-plugin builds always have them (zip names only;
|
||||
the only sign for split builds with one scene, e.g. BONELAB)
|
||||
B the build settings list more scenes than the APK has level files (a split keeps level0 only). The scene list
|
||||
comes from globalgamemanagers (loose, or the node of data.unity3d: only the bundle's head and the blocks up to it
|
||||
are read, a few hundred KB of a file that can be hundreds of MB)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import lzma
|
||||
import re
|
||||
import struct
|
||||
import zipfile
|
||||
|
||||
DATA = "assets/bin/Data/"
|
||||
XR_PLUGIN_LIBS = ("libOculusXRPlugin.so", "libUnityOpenXR.so")
|
||||
LEVEL = re.compile(re.escape(DATA) + r"level(\d+)(?:\.|$)")
|
||||
MAX_NODE = 64 * 2**20 # globalgamemanagers is 0.1-3 MB; a larger node isn't read
|
||||
|
||||
|
||||
def xr_plugin_without_subsystems(names: list[str]) -> bool:
|
||||
"""Sign A (zip names only)."""
|
||||
xr_plugin = any(n.startswith("lib/") and n.rsplit("/", 1)[-1] in XR_PLUGIN_LIBS for n in names)
|
||||
return xr_plugin and not any(n.startswith(DATA + "UnitySubsystems/") for n in names)
|
||||
|
||||
|
||||
def _cstr(f) -> bytes:
|
||||
out = bytearray()
|
||||
while (c := f.read(1)) not in (b"\0", b""):
|
||||
out += c
|
||||
return bytes(out)
|
||||
|
||||
|
||||
def _decompress(data: bytes, kind: int, size: int) -> bytes:
|
||||
if kind == 0:
|
||||
return data
|
||||
if kind in (2, 3): # LZ4 / LZ4HC
|
||||
import lz4.block
|
||||
|
||||
return lz4.block.decompress(data, uncompressed_size=size)
|
||||
if kind == 1: # LZMA: 5 bytes of properties, then raw LZMA1
|
||||
props, dict_size = data[0], struct.unpack("<I", data[1:5])[0]
|
||||
dec = lzma.LZMADecompressor(lzma.FORMAT_RAW, filters=[{
|
||||
"id": lzma.FILTER_LZMA1, "dict_size": dict_size, "lc": props % 9, "lp": (props // 9) % 5,
|
||||
"pb": props // 45}])
|
||||
return dec.decompress(data[5:], size)
|
||||
raise ValueError(f"unknown compression {kind}")
|
||||
|
||||
|
||||
class _Counting:
|
||||
"""A forward-only stream that knows its position (zip member streams have no reliable tell())."""
|
||||
|
||||
def __init__(self, f):
|
||||
self.f, self.pos = f, 0
|
||||
|
||||
def read(self, n: int) -> bytes:
|
||||
b = self.f.read(n)
|
||||
self.pos += len(b)
|
||||
return b
|
||||
|
||||
def align(self, n: int = 16) -> None:
|
||||
if self.pos % n:
|
||||
self.read(n - self.pos % n)
|
||||
|
||||
|
||||
def bundle_node(stream, want: str = "globalgamemanagers") -> tuple[list[str], bytes | None]:
|
||||
"""(node names, bytes of node `want`) of a UnityFS bundle, reading only up to the end of that node. ([], None)
|
||||
for anything else (old formats, block info at the end of the file)."""
|
||||
f = _Counting(stream)
|
||||
if f.read(8) != b"UnityFS\0":
|
||||
return [], None
|
||||
version = struct.unpack(">I", f.read(4))[0]
|
||||
_cstr(f), _cstr(f)
|
||||
_size, csize, usize, flags = struct.unpack(">qIII", f.read(20))
|
||||
if version >= 7:
|
||||
f.align()
|
||||
if flags & 0x80: # block info at the end of the file
|
||||
return [], None
|
||||
info = _decompress(f.read(csize), flags & 0x3F, usize)
|
||||
off = 16 # data hash
|
||||
(nblocks,) = struct.unpack(">i", info[off:off + 4])
|
||||
off += 4
|
||||
blocks = []
|
||||
for _ in range(nblocks):
|
||||
blocks.append(struct.unpack(">IIH", info[off:off + 10]))
|
||||
off += 10
|
||||
(nnodes,) = struct.unpack(">i", info[off:off + 4])
|
||||
off += 4
|
||||
nodes = []
|
||||
for _ in range(nnodes):
|
||||
node_off, node_size, _flags = struct.unpack(">qqI", info[off:off + 20])
|
||||
off += 20
|
||||
end = info.index(b"\0", off)
|
||||
nodes.append((info[off:end].decode("utf-8", "replace"), node_off, node_size))
|
||||
off = end + 1
|
||||
if flags & 0x200: # padding before the first block
|
||||
f.align()
|
||||
names = [n[0] for n in nodes]
|
||||
target = next((n for n in nodes if n[0] == want), None)
|
||||
if target is None or target[2] > MAX_NODE:
|
||||
return names, None
|
||||
need = target[1] + target[2]
|
||||
out = bytearray()
|
||||
for u, c, bf in blocks:
|
||||
if len(out) >= need:
|
||||
break
|
||||
out += _decompress(f.read(c), bf & 0x3F, u)
|
||||
return names, bytes(out[target[1]:need])
|
||||
|
||||
|
||||
def build_scene_count(ggm: bytes) -> int | None:
|
||||
"""Number of scenes in the build settings (BuildSettings.scenes) of a globalgamemanagers file."""
|
||||
try:
|
||||
import UnityPy
|
||||
|
||||
for obj in UnityPy.load(ggm).objects:
|
||||
if obj.type.name == "BuildSettings":
|
||||
return len(obj.read_typetree().get("scenes") or [])
|
||||
except Exception: # noqa: BLE001 - unreadable/unknown version: no answer
|
||||
return None
|
||||
return None
|
||||
|
||||
|
||||
def more_scenes_than_levels(z: zipfile.ZipFile, names: list[str], ggm: bytes | None = None) -> bool:
|
||||
"""Sign B. ggm: the loose globalgamemanagers when already read."""
|
||||
nameset = set(names)
|
||||
levels: set[int] = set()
|
||||
if ggm is None and DATA + "globalgamemanagers" in nameset:
|
||||
ggm = z.read(DATA + "globalgamemanagers")
|
||||
if ggm is not None:
|
||||
levels = {int(m.group(1)) for n in names if (m := LEVEL.match(n))}
|
||||
elif DATA + "data.unity3d" in nameset:
|
||||
try:
|
||||
with z.open(DATA + "data.unity3d") as raw:
|
||||
nodes, ggm = bundle_node(raw)
|
||||
except Exception: # noqa: BLE001
|
||||
return False
|
||||
levels = {int(m.group(1)) for n in nodes if (m := re.fullmatch(r"level(\d+)", n))}
|
||||
if ggm is None:
|
||||
return False
|
||||
scenes = build_scene_count(ggm)
|
||||
return scenes is not None and scenes > len(levels)
|
||||
|
||||
|
||||
def split_build(z: zipfile.ZipFile, names: list[str], ggm: bytes | None = None, deep: bool = True) -> bool:
|
||||
"""The APK of a Unity split build (its OBB holds the rest of the game). Without `deep` only sign A."""
|
||||
return xr_plugin_without_subsystems(names) or (deep and more_scenes_than_levels(z, names, ggm))
|
||||