Skip to content

Exported window: a live-window instrument in the host seam, and the handoff and quarantine cases it pins - #1305

Merged
GLinnik21 merged 2 commits into
mainfrom
uri5/pr2-exported-window-owner
Nov 9, 2026
Merged

GLinnik21 merged 2 commits into
mainfrom
uri5/pr2-exported-window-owner

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Summary

The URI playback engine (Settings > Video & playback > Playback engine > Experimental) is being extended from webOS 4.x to
webOS 5+, where video binds through an exported window instead of the ACB plane. The C seam keeps ONE exported window per
process (src/video_plane.c g_window_id): vp_create_window overwrites it and never destroys the window it held, and
vp_destroy_window ends only what the slot names. Nothing in Rust enforces one window at a time across Feed, the URI backend
and the probe, and the host test seam could not say how many windows a run left live (vp_create_window returned a constant,
vp_destroy_window was a no-op). The worry before production ever selects the exported binding: a NEW request arriving while
a quarantined URI registration still holds its window would create a second one.

This PR adds the missing instrument and two cases on it. Both cases are green on the current code, so no exported-window lease
is added and no production code changes.

The instrument

  • rust-modules/play-feed/src/ffi_host.rs (the host seam): vp_create_window / vp_destroy_window now keep what the C
    seam's single slot would hold: creates and destroys (calls), live and peak. A create over an occupied slot leaves two
    live windows; a destroy ends only the window the slot names; an unarmed seam makes no window. Read with
    window_counts_for_test(), zeroed by reset_windows_for_test() and by reset_native_lifecycle_for_test(). Test and
    test-support builds only.
  • app/run_uri_boot_tests.rs (the application's hostsim rig, lifecycle_regression_tests): a CountingDisplay given to the
    URI driver as its display. Its window verbs forward to HOST_SINK, the sink Feed's hooks run over in this rig
    (backends.rs TEST_HOOKS -> test_raw_sink), so one instrument counts both backends' windows. The driver is installed
    through install_uri_backend_with_ports with Binding::Exported { canvas: (1920, 1080) }, a test clock and short
    allowances (1 s startup, 0.5 s release), so a startup timeout and an unreleased close are reached by moving the clock.

The cases

Case On the current code
a_new_request_over_a_quarantined_uri_driver_makes_no_second_live_window (written first, as the failing-first target) Already green. Premises asserted: the adapter's phase is Quarantined and the counts read creates 1, destroys 0, live 1, peak 1. The new request is resolved, start_playback_tracked returns Failed (not Launched), and the counts are unchanged after two more frames.
a_timed_out_uri_start_destroys_its_live_window_before_the_feed_resolve (regression pin of the already-ordered path) Green. URI start: creates 1, live 1. Startup timeout and close: the window is still held (live 1) and no Feed resolve is pending. On the confirmed release: destroys 1, live 0, and only then play_pending() is true.

The instrument itself has a unit test (ffi_host::tests::the_window_instrument_counts_a_create_over_an_occupied_slot_as_two_live_windows:
create, create reads live 2, peak 2; one destroy leaves live 1). A mutant that disables route_start's quarantine guard
alone still leaves the first case green: the Conflict branch below it (a Stop to the quarantined driver, refused with
ReleaseUncertain, then Failed) is a second guard. That is read from the code, not traced in the mutant.

The fix

None needed. The in-request handoff is ordered after the URI window's destroy, and a new request over a quarantined URI
registration is refused by the adapter's own start path. No exported-window lease was added to tv::plane, and no C seam
file changed.

Verification

Gates ran on the committed tree, git status --short empty before and after.

make test-hostsim T=live_window (application crate, both cases):

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 1473 filtered out; finished in 0.04s

make test-hostsim C=plx_play_feed T=the_window_instrument (the instrument's own test):

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 316 filtered out; finished in 0.13s

make test-crate C=plx_play_feed:

test result: ok. 300 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.65s

(That tier does not enable hostsim, so it never runs the instrument's test; the line above does.) Also: the whole
uri_boot_tests module (make test-hostsim T=uri_boot_tests) test result: ok. 23 passed; 0 failed; 0 ignored; 0 measured; 1452 filtered out; finished in 3.82s,
make check-nodef exit 0, and bash ci/check-deps.sh check-deps: all gates green. Not run here: the python harness, screens,
appkit and make check (CI runs them).

Not covered

  • Feed's own window create after the handoff is read from the code, not pinned by a test. The handoff case stops at the
    Feed resolve and does not run Feed's native start. A first version did (it read creates 2, live 1, peak 1), but under the
    armed seam that start's demux worker outlives the rig and lands its failure in the next test's route control, which failed
    two unrelated Feed fixtures in the same module, and Feed's release did not finish inside the rig's 5 s poll (cause not
    determined). The hermetic place to pin it is the media crate's hostsim engine tests (player/engine.rs,
    force_clocksink_for_test(true)), which already drive with_window_id and the release.
  • Not verified on a TV. Nothing here ran on a television. The instrument is a host model of the C seam's one window slot,
    not a measurement of the compositor: it says the player never asks for a second window, not what a webOS 5+ set does if it
    did. No webOS 5+ device is available to this work.

Part of the webOS 5+ URI work tracked in #1064; does not close it.

🤖 Generated with Claude Code

GLinnik21 and others added 2 commits November 9, 2026 19:08
…ases it pins

The host seam's `vp_create_window` returned a constant and `vp_destroy_window` was a no-op, so
no test could say how many exported windows a run left live (the URI engine on webOS 5+ plan,
F19). The seam now keeps what the C seam's single window slot would hold: creates, destroy
calls, live windows (a create over an occupied slot leaves two) and the peak, zeroed by
`reset_native_lifecycle_for_test`.

The application's hostsim rig gets a `CountingDisplay` (the URI driver's `display`, window verbs
forwarded to `HOST_SINK`, the sink Feed's hooks run over there), so one instrument counts both
backends' windows, and two cases:

- a URI start that times out and hands the same request to Feed: the URI window is destroyed
  on the confirmed release before the Feed resolve begins, and the peak never passes one;
- a new request over a quarantined URI registration, which still holds its window, makes no
  second window: the start is refused (`Failed`), counts stay at one create, one live.

Both are green on the current code, so no lease is added. Disabling route_start's quarantine
guard alone leaves the second case green (a mutant run); the Conflict branch under it, which
sends the quarantined driver a Stop and fails the start on its refusal, is the second guard
(read from the code, not traced in the mutant). The handoff case stops before Feed's own native
start: under the armed seam that start's demux worker outlives the rig and fails the module's
later Feed fixtures.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The handoff case never starts Feed, so its last assertion (no second window) could not fail and
claimed Feed's window count. Rename it to what it pins, that the URI window is destroyed before
the Feed resolve begins, and drop that assertion; the earlier ones (no resolve while the close is
open, destroys 1 and live 0 before the resolve) stay.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit c5ea5d3 into main Nov 9, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the uri5/pr2-exported-window-owner branch November 9, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant