From 62d84914ff14d6988fab265d1ca7c20e6e4a98cf Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Fri, 20 Nov 2026 13:35:21 +0300 Subject: [PATCH 1/5] The simulator runs on its own platform, and the television's code is always compiled The simulator and the macOS app are no longer the webOS port with its answers faked. A new module, `platform_desktop`, states every hook the application reads from its platform: the shared NONE groups of `plx_os::tv` wherever a host has nothing to say (the key manager, the settings service, the device files, the URI media pipe), the Feed backend's host sink when the build has one, and its own bodies for the three things a host does answer: the capability probe, the root press and the toast. `src/bin/sim.rs` names it, so a desktop executable no longer references the television's tables. With nothing on a desktop reaching them, the `hostsim` term leaves all 102 fenced cfg lines in `system.rs`, `port.rs`, `webos.rs`, `webos/{caps,toast,jail_repair}.rs` and `keymanager.rs`. The television's arms are now compiled into every build, the simulator's included, and the linker drops what nothing reaches. The stand-ins that tests rely on stay, gated on `test` and `test-support`. The frame-probe stubs are re-gated on `devtriggers` alone, and the simulator's two opaque-region stubs and its `SINK` arms move to the desktop platform. The dev triggers that force the Dolby Vision answer (`dvcaps0`, `dvcaps1`) and the probe's one log line move from `webos::caps` into the neutral `devcaps::dv`, which the webOS probe and the desktop probe both end in, so the simulator keeps both without a copy. `ci/module-layers.ini` places `platform_desktop` and adds its `[platform desktop]` section, and `ci/check-deps.sh`'s sink rule follows the moved sink arms. Co-Authored-By: Claude --- ci/check-deps.sh | 10 +- ci/module-layers.ini | 11 ++ rust-modules/os/src/devcaps/dv.rs | 97 +++++++++++++- rust-modules/os/src/keymanager.rs | 10 +- rust-modules/os/src/webos.rs | 44 +++---- rust-modules/os/src/webos/caps.rs | 118 +++-------------- rust-modules/os/src/webos/jail_repair.rs | 10 +- rust-modules/os/src/webos/toast.rs | 8 +- rust-modules/os/src/webos/video_sink.rs | 9 +- rust-modules/src/bin/sim.rs | 13 +- rust-modules/src/lib.rs | 20 +-- rust-modules/src/platform_desktop.rs | 157 +++++++++++++++++++++++ rust-modules/src/port.rs | 40 ++---- rust-modules/src/system.rs | 117 ++++++----------- 14 files changed, 386 insertions(+), 278 deletions(-) create mode 100644 rust-modules/src/platform_desktop.rs diff --git a/ci/check-deps.sh b/ci/check-deps.sh index f48a647e67..8ebbf38ce1 100755 --- a/ci/check-deps.sh +++ b/ci/check-deps.sh @@ -14,7 +14,7 @@ # present — the present gate's worker door: ONE atomic static in machine/src/present.rs and ONE # `wake_from_worker`. # effect — `Effect::` spelled nowhere (the enum is `Fx::`, the app's `AppFx::`). -# sink — `tv::sink::installed` and `VideoSink` only under player/, tv/, tv.rs, port.rs and app/adapters/backends.rs +# sink — `tv::sink::installed` and `VideoSink` only under player/, tv/, tv.rs, port.rs, platform_desktop.rs and app/adapters/backends.rs # (step L15: the Starfish/ACB verbs are the player's alone). # # Phase 4 rule (D3 rewrite, phase 12): @@ -1140,8 +1140,8 @@ else fail "frame: $frame_bad line(s) of a privileged OS-primitive call outside a fi # frame # sink: the Starfish/ACB verbs (`tv::sink::VideoSink`) are the player's alone (step L15). Only -# `player/`, `play-uri/`, the native `webos/` port, and `port.rs` (which names one) -# and `tv.rs` with `tv/` (which hold it) name `tv::sink::installed` or `VideoSink`; so does +# `player/`, `play-uri/`, the native `webos/` port, and `port.rs` and `platform_desktop.rs` (which +# name one each) and `tv.rs` with `tv/` (which hold it) name `tv::sink::installed` or `VideoSink`; so does # `app/adapters/backends.rs`, the boot composition that resolves the installed display once for the # ACB plane's boot and hands it on (it was `player/plane_boot.rs`; the composition root is where the # driver set is built). Every other module reaches the television through the narrower `tv` interfaces. Wholly-test files are skipped like inline @@ -1156,12 +1156,12 @@ while IFS= read -r line; do case "$p" in "$SRC_PLAY_FEED"/*|"$SRC_PLAY_URI"/*) case "$line" in *tv::sink::installed*|*tv::sink::display_installed*) ;; *) continue ;; esac ;; esac - case "$p" in "$SRC_MEDIA"/player/*|"$SRC_OS"/tv/*|"$SRC_OS"/tv.rs|"$SRC_OS"/webos/*|"$SRC"/port.rs|"$SRC"/app/adapters/backends.rs) continue ;; esac + case "$p" in "$SRC_MEDIA"/player/*|"$SRC_OS"/tv/*|"$SRC_OS"/tv.rs|"$SRC_OS"/webos/*|"$SRC"/port.rs|"$SRC"/platform_desktop.rs|"$SRC"/app/adapters/backends.rs) continue ;; esac if is_wholly_test "$p"; then continue; fi echo " $line"; sink_bad=$((sink_bad+1)) done < <(grep_code 'tv::sink::(installed|display_installed)|\b(VideoSink|DisplaySink)\b' "$SRC" "$SRC_OS" "$SRC_UI" "$SRC_MEDIA" "$SRC_PLAYBACK_CONTRACT" "$SRC_PLAY_URI" "$SRC_PLAY_FEED" "$SRC_MEDIA_CODECS" "$SRC_APPKIT" "$SRC_SCREENS" "$SRC_OWP") if [ "$sink_bad" -eq 0 ]; then ok "sink" -else fail "sink: $sink_bad line(s) naming the video sink outside playback execution, port.rs, tv.rs and tv/"; fi +else fail "sink: $sink_bad line(s) naming the video sink outside playback execution, port.rs, platform_desktop.rs, tv.rs and tv/"; fi fi # sink # route: `Route::` in app/ = 0, and `enum Route` gone from the whole tree (D1/D4). No allowlist: diff --git a/ci/module-layers.ini b/ci/module-layers.ini index 5bbf045998..00325a7bd3 100644 --- a/ci/module-layers.ini +++ b/ci/module-layers.ini @@ -191,6 +191,7 @@ members = screens uses = base machine os gfx net plex telemetry ui data session media appkit screens playback_contract play_uri play_feed media_codecs members = crate app dev lab capture remote focusprobe hud_cli hud_tools shot coldstart textinput system release_line port + platform_desktop [platform webos] # Not a layer: the modules that exist only because the target is webOS. Identity, capability and @@ -207,3 +208,13 @@ members = # `port.rs` (docs/module-layers.md, step L15). Nothing outside names the port, so it can become its own # crate on top, and another TV OS another port beside it. members = webos keymanager system port + +[platform desktop] +# Not a layer, like [platform webos]: the simulator's and the macOS app's own platform. Its tables +# (`SERVICES`, the shell, the frame probe, `PLATFORM`) and its entry (`run`, which `src/bin/sim.rs` +# calls) are written for a host, from the shared `NONE` groups of `os`'s `tv` wherever a host has +# nothing to say, so nothing outside it needs to name it and it names none of [platform webos]: the +# gate fails a reference from here to `webos`, `keymanager`, `system` or `port` like any other +# reference from outside that port. It stays a module of the application crate until the platform +# crates split (docs/platform-ports.md, W7). +members = platform_desktop diff --git a/rust-modules/os/src/devcaps/dv.rs b/rust-modules/os/src/devcaps/dv.rs index 627d6f8019..e9a03d4b60 100644 --- a/rust-modules/os/src/devcaps/dv.rs +++ b/rust-modules/os/src/devcaps/dv.rs @@ -1,10 +1,12 @@ -//! The television's own Dolby Vision capability: the type, and the cache the port's boot probe -//! publishes into (`webos::caps`). +//! The television's own Dolby Vision capability: the type, the cache a platform's boot probe +//! publishes into (the webOS port's is `webos::caps`, the desktop platform's its own), and the dev +//! triggers that force the answer, which every platform's probe honours the same way. //! -//! An early render-thread read never initializes the cache: the port's worker is the only +//! An early render-thread read never initializes the cache: the platform's probe is the only //! publisher, and a failed or late answer cannot be mistaken for an affirmative capability. use std::sync::OnceLock; +use std::time::Instant; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum DvCapability { @@ -110,9 +112,96 @@ pub fn publish(probe: DvProbe) { RESULT.publish(probe); } +/// The configd key the webOS probe asks for, and the one every probe line names. +pub const CONFIG_KEY: &str = "tv.config.supportDolbyHDRContents"; + +plx_base::devtrig::latched_flag!( + /// `/tmp/plxnative-dvcaps0` — force the boot's platform answer to unsupported. + fn forced_unsupported = "dvcaps0"; +); + +plx_base::devtrig::latched_flag!( + /// `/tmp/plxnative-dvcaps1` — force the boot's platform answer to supported. + fn forced_supported = "dvcaps1"; +); + +fn override_capability(zero: bool, one: bool) -> Option<(DvCapability, bool)> { + if zero { + Some((DvCapability::Unsupported, one)) + } else if one { + Some((DvCapability::Supported, false)) + } else { + None + } +} + +/// Publish a probe's answer and log it, one `webos-caps:` line, with the time the probe took. A +/// platform's probe ends in this call whatever it learned, so every answer leaves the same line. +pub fn publish_logged(probe: DvProbe, started: Instant, code: Option, detail: Option<&str>) { + publish(probe); + let elapsed = started.elapsed().as_millis(); + if probe.capability == DvCapability::Unknown { + let code = code.map(|n| format!(" code={n}")).unwrap_or_default(); + let detail = detail + .filter(|s| !s.is_empty()) + .map(|s| format!(" detail={s}")) + .unwrap_or_default(); + plx_base::eventlog::log(&format!( + "webos-caps: key={CONFIG_KEY} answer=unknown stage={}{}{} elapsed_ms={elapsed}", + probe.reason, code, detail, + )); + } else { + plx_base::eventlog::log(&format!( + "webos-caps: key={CONFIG_KEY} answer={} source={} elapsed_ms={elapsed}", + probe.capability.label(), + probe.provenance(), + )); + } +} + +/// The dev triggers' answer, if one is armed: `dvcaps0` forces unsupported and `dvcaps1` supported, +/// `dvcaps0` winning when both are (and saying so). Published and logged like any probe answer, and +/// answers whether it did, so the probe stops there instead of asking its platform. +pub fn publish_forced(started: Instant) -> bool { + let Some((capability, conflict)) = override_capability(forced_unsupported(), forced_supported()) else { + return false; + }; + if conflict { + plx_base::eventlog::log("webos-caps: dvcaps0 and dvcaps1 both armed; dvcaps0 wins"); + } + publish_logged( + DvProbe { + capability, + source: ProbeSource::Override, + reason: if conflict { "override-conflict" } else { "override" }, + }, + started, + None, + None, + ); + true +} + #[cfg(test)] mod tests { - use super::{DvCache, DvCapability, DvProbe, ProbeSource}; + use super::{override_capability, DvCache, DvCapability, DvProbe, ProbeSource}; + + #[test] + fn dv_caps_override_precedence() { + assert_eq!(override_capability(false, false), None); + assert_eq!( + override_capability(true, false), + Some((DvCapability::Unsupported, false)) + ); + assert_eq!( + override_capability(false, true), + Some((DvCapability::Supported, false)) + ); + assert_eq!( + override_capability(true, true), + Some((DvCapability::Unsupported, true)) + ); + } #[test] fn early_caps_read_does_not_initialize_cache() { diff --git a/rust-modules/os/src/keymanager.rs b/rust-modules/os/src/keymanager.rs index 0bf228480d..78b07f3a70 100644 --- a/rust-modules/os/src/keymanager.rs +++ b/rust-modules/os/src/keymanager.rs @@ -203,26 +203,24 @@ fn call_with(client: &mut platform::Client, uri: &str, payload: &Value) -> Optio .and_then(|s| serde_json::from_str(&s).ok()) } -#[cfg(any(feature = "hostsim", test, feature = "test-support"))] +#[cfg(any(test, feature = "test-support"))] mod platform { pub(super) struct Client; impl Client { pub(super) fn new() -> Result { - #[cfg(any(test, feature = "test-support"))] if super::RPC_FOR_TEST.with(|hook| hook.get().is_some()) { return Ok(Self); } Err(()) } - pub(super) fn call(&mut self, _uri: &str, _payload: &str) -> Result { - #[cfg(any(test, feature = "test-support"))] - if let Some(rpc) = super::RPC_FOR_TEST.with(|hook| hook.get()) { return rpc(_uri, _payload); } + pub(super) fn call(&mut self, uri: &str, payload: &str) -> Result { + if let Some(rpc) = super::RPC_FOR_TEST.with(|hook| hook.get()) { return rpc(uri, payload); } Err(()) } } } -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] mod platform { use std::time::Duration; diff --git a/rust-modules/os/src/webos.rs b/rust-modules/os/src/webos.rs index d8ff5013fe..2f964bcc97 100644 --- a/rust-modules/os/src/webos.rs +++ b/rust-modules/os/src/webos.rs @@ -45,7 +45,7 @@ use crate::tv::device::{Hardware, Info, NyxFile, Platform, WebosDetail}; pub mod jail_repair; pub mod caps; pub mod toast; -#[cfg(all(not(feature = "hostsim"), not(test)))] +#[cfg(not(test))] pub mod video_sink; const OS_INFO: &str = "/var/run/nyx/os_info.json"; @@ -486,7 +486,7 @@ pub fn poll_home() { /// minimize leg instead of leaving the user on a screen whose BACK did nothing. const HOME_APP_ID: &str = "com.webos.app.home"; -#[cfg(any(feature = "hostsim", test, feature = "test-support"))] +#[cfg(any(test, feature = "test-support"))] fn launch_home() -> bool { plx_base::eventlog::log(&format!( "gohome: no LS2 bus off-device — the root press would launch {HOME_APP_ID} on a television" @@ -494,22 +494,22 @@ fn launch_home() -> bool { true } -#[cfg(any(feature = "hostsim", test, feature = "test-support"))] +#[cfg(any(test, feature = "test-support"))] fn minimize() {} -#[cfg(any(feature = "hostsim", test, feature = "test-support"))] +#[cfg(any(test, feature = "test-support"))] fn ls2_probe() { plx_base::eventlog::log("gohome: no LS2 bus off-device — nothing to probe"); } -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] fn ls2_probe() { ls2::probe(); } /// Grade only the allowlisted fields in the LS2 wake reply. The raw platform JSON never enters a /// report or the local snapshot. -#[cfg(any(test, all(target_os = "linux", target_arch = "arm", not(feature = "hostsim"))))] +#[cfg(any(test, all(target_os = "linux", target_arch = "arm")))] fn storage_activation_reply(reply: &str) -> crate::storage::wire::failure::Detail { use crate::storage::wire::failure::{Detail, Stage}; if reply.len() > 4096 { return Detail::new(Stage::ActivationInvalidReply, None); } @@ -531,7 +531,7 @@ fn storage_activation_reply(reply: &str) -> crate::storage::wire::failure::Detai /// The helper publishes readiness from its startup path, so neither a successful method reply nor /// delivery of `/wake` is required; the result is retained only as diagnostics and the authenticated /// Unix-socket `Hello` is the sole readiness proof. -#[cfg(all(target_os = "linux", target_arch = "arm", not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(all(target_os = "linux", target_arch = "arm", not(any(test, feature = "test-support"))))] pub fn activate_storage_helper(service: &str) -> crate::storage::wire::failure::Detail { use crate::storage::wire::failure::{Detail, Stage}; let uri = format!("luna://{service}/wake"); @@ -549,7 +549,7 @@ pub fn activate_storage_helper(service: &str) -> crate::storage::wire::failure:: /// Hosts and the simulator have no storage helper to wake: the same answer an absent port gives. #[cfg(all( target_os = "linux", - not(all(target_arch = "arm", not(feature = "hostsim"), not(any(test, feature = "test-support")))) + not(all(target_arch = "arm", not(any(test, feature = "test-support")))) ))] pub fn activate_storage_helper(_service: &str) -> crate::storage::wire::failure::Detail { use crate::storage::wire::failure::{Detail, Stage}; @@ -559,7 +559,7 @@ pub fn activate_storage_helper(_service: &str) -> crate::storage::wire::failure: /// One `getSystemSettings` round trip on a fresh anonymous registration (any thread: the /// registration owns its glib context). `None` when the bus refused or timed out. `budget` bounds /// the call only: registration and unregistration are not bounded by it (`ls2`'s own doc says so). -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] fn settings_reply(payload: &str, budget: std::time::Duration) -> Option { ls2::register() .map_err(ls2::Fail::from) @@ -570,7 +570,7 @@ fn settings_reply(payload: &str, budget: std::time::Duration) -> Option /// What the platform's settings service says about the locale; `i18n` owns the parse and the log /// lines. The same 600 ms bus budget as a root press, and for the same reason: the caller is the /// main thread at boot. -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] pub fn system_locale() -> crate::tv::LocaleReply { match settings_reply(r#"{"keys":["localeInfo"]}"#, std::time::Duration::from_millis(600)) { Some(raw) => crate::tv::LocaleReply::Reply(raw), @@ -578,7 +578,7 @@ pub fn system_locale() -> crate::tv::LocaleReply { } } -#[cfg(any(feature = "hostsim", test, feature = "test-support"))] +#[cfg(any(test, feature = "test-support"))] pub fn system_locale() -> crate::tv::LocaleReply { crate::tv::LocaleReply::NoPlatform } @@ -597,7 +597,7 @@ pub fn system_locale() -> crate::tv::LocaleReply { /// before `Load` is ever called, for as long as the hub takes: this Load is delayed by that, and is /// failed by the pump's `NATIVE_LOAD_BUDGET` if the wait outlasts it. A hub that answers the /// registration and then stays silent costs the call's 300 ms and keeps the 400 ms default. -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] pub fn sound_output() -> crate::tv::sound::Reply { use crate::tv::sound::Reply; match settings_reply(r#"{"category":"sound","keys":["soundOutput"]}"#, std::time::Duration::from_millis(300)) { @@ -606,12 +606,12 @@ pub fn sound_output() -> crate::tv::sound::Reply { } } -#[cfg(any(feature = "hostsim", test, feature = "test-support"))] +#[cfg(any(test, feature = "test-support"))] pub fn sound_output() -> crate::tv::sound::Reply { crate::tv::sound::Reply::NoPlatform } -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] fn launch_home() -> bool { let payload = format!("{{\"id\":\"{HOME_APP_ID}\"}}"); let started = std::time::Instant::now(); @@ -653,7 +653,7 @@ fn launch_home() -> bool { } } -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] fn minimize() { let win = WINDOW.load(std::sync::atomic::Ordering::Relaxed); if win.is_null() { @@ -666,11 +666,11 @@ fn minimize() { plx_base::eventlog::log("gohome: fallback=SDL minimize — asked, and SDL cannot say whether it took"); } -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] static WINDOW: std::sync::atomic::AtomicPtr = std::sync::atomic::AtomicPtr::new(std::ptr::null_mut()); -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] extern "C" { fn SDL_MinimizeWindow(win: *mut std::os::raw::c_void); } @@ -678,21 +678,21 @@ extern "C" { /// Hand this module the SDL window, once, at boot — `textinput::bind`'s shape and for its reason: /// the window is created deep inside `plex_run` and the platform call needs it a long way from /// there. -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] pub fn bind_window(win: *mut std::os::raw::c_void) { WINDOW.store(win, std::sync::atomic::Ordering::Relaxed); } -#[cfg(any(feature = "hostsim", test, feature = "test-support"))] +#[cfg(any(test, feature = "test-support"))] pub fn bind_window(_win: *mut std::os::raw::c_void) {} /// The URI media pipe the port installs (`tv::LegacyWebosMedia::uri_media`): the explicitly enabled bus /// worker on the television, or `NoUriMedia` in a feature-off build, simulator or test. /// This does not select the URI playback route. -#[cfg(all(feature = "uri-transport", not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(all(feature = "uri-transport", not(any(test, feature = "test-support"))))] pub const URI_MEDIA: &dyn crate::tv::uri::UriMedia = &ls2::uri::Transport; -#[cfg(not(all(feature = "uri-transport", not(feature = "hostsim"), not(any(test, feature = "test-support")))))] +#[cfg(not(all(feature = "uri-transport", not(any(test, feature = "test-support")))))] pub const URI_MEDIA: &dyn crate::tv::uri::UriMedia = &crate::tv::uri::NoUriMedia; /// One LS2 request/reply, on the calling thread. @@ -728,7 +728,7 @@ pub const URI_MEDIA: &dyn crate::tv::uri::UriMedia = &crate::tv::uri::NoUriMedia /// caller's log line instead of being freed. Anonymous clients do not /// collide with each other, so nothing here is serialised; a registration lives for one caller's /// use and is unregistered on drop, as both copies always did. -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] pub mod ls2 { use std::ffi::{CStr, CString}; use std::os::raw::{c_char, c_int, c_void}; diff --git a/rust-modules/os/src/webos/caps.rs b/rust-modules/os/src/webos/caps.rs index bf6f88d53c..19ec3672d8 100644 --- a/rust-modules/os/src/webos/caps.rs +++ b/rust-modules/os/src/webos/caps.rs @@ -6,57 +6,19 @@ //! publishes into): the worker is the only publisher, and a failed or late answer cannot be //! mistaken for an affirmative capability. -use crate::devcaps::dv::{DvCapability, DvProbe, ProbeSource}; +use crate::devcaps::dv::{self, DvCapability, DvProbe, ProbeSource}; use std::sync::OnceLock; use std::time::Instant; -const KEY: &str = "tv.config.supportDolbyHDRContents"; +#[cfg(any(test, all(target_arch = "arm", target_os = "linux")))] +const KEY: &str = dv::CONFIG_KEY; static STARTED: OnceLock<()> = OnceLock::new(); -plx_base::devtrig::latched_flag!( - /// `/tmp/plxnative-dvcaps0` — force the boot's platform answer to unsupported. - pub fn forced_unsupported = "dvcaps0"; -); - -plx_base::devtrig::latched_flag!( - /// `/tmp/plxnative-dvcaps1` — force the boot's platform answer to supported. - pub fn forced_supported = "dvcaps1"; -); - -fn override_capability(zero: bool, one: bool) -> Option<(DvCapability, bool)> { - if zero { - Some((DvCapability::Unsupported, one)) - } else if one { - Some((DvCapability::Supported, false)) - } else { - None - } -} - -fn publish(probe: DvProbe, started: Instant, code: Option, detail: Option<&str>) { - crate::devcaps::dv::publish(probe); - let elapsed = started.elapsed().as_millis(); - if probe.capability == DvCapability::Unknown { - let code = code.map(|n| format!(" code={n}")).unwrap_or_default(); - let detail = detail - .filter(|s| !s.is_empty()) - .map(|s| format!(" detail={s}")) - .unwrap_or_default(); - plx_base::eventlog::log(&format!( - "webos-caps: key={KEY} answer=unknown stage={}{}{} elapsed_ms={elapsed}", - probe.reason, code, detail, - )); - } else { - plx_base::eventlog::log(&format!( - "webos-caps: key={KEY} answer={} source={} elapsed_ms={elapsed}", - probe.capability.label(), - probe.provenance(), - )); - } - // The boot worker publishes DvProbe only. Bridge captures the typed probe before present - // admission and owns the Page damage when this diagnostic fact changes. -} +// The boot worker publishes DvProbe only (`dv::publish_logged`, which every platform's probe ends +// in). Bridge captures the typed probe before present admission and owns the Page damage when this +// diagnostic fact changes. The dev triggers that force the answer (`dvcaps0`, `dvcaps1`) are +// `dv::publish_forced`'s, so a platform other than this one honours them the same way. /// Start the one boot probe. The registration and its private GLib context are both created and /// dropped on this worker; no LS2 handle crosses a thread boundary and the app never joins it. @@ -65,7 +27,7 @@ pub fn start_probe() { return; } if plx_base::task::spawn("dv-caps-probe", run_probe).is_none() { - publish( + dv::publish_logged( DvProbe { capability: DvCapability::Unknown, source: ProbeSource::Failure, @@ -80,26 +42,7 @@ pub fn start_probe() { fn run_probe() { let started = Instant::now(); - if let Some((capability, conflict)) = - override_capability(forced_unsupported(), forced_supported()) - { - if conflict { - plx_base::eventlog::log("webos-caps: dvcaps0 and dvcaps1 both armed; dvcaps0 wins"); - } - publish( - DvProbe { - capability, - source: ProbeSource::Override, - reason: if conflict { - "override-conflict" - } else { - "override" - }, - }, - started, - None, - None, - ); + if dv::publish_forced(started) { return; } run_transport(started); @@ -108,7 +51,6 @@ fn run_probe() { #[cfg(all( target_arch = "arm", target_os = "linux", - not(feature = "hostsim"), not(any(test, feature = "test-support")) ))] fn run_transport(started: Instant) { @@ -121,7 +63,7 @@ fn run_transport(started: Instant) { detail, code, }) => { - publish( + dv::publish_logged( DvProbe { capability: DvCapability::Unknown, source: ProbeSource::Failure, @@ -141,7 +83,7 @@ fn run_transport(started: Instant) { ); match reply { Ok(reply) => match parse_dv_reply(&reply) { - Ok(capability) => publish( + Ok(capability) => dv::publish_logged( platform_gate( DvProbe { capability, @@ -154,7 +96,7 @@ fn run_transport(started: Instant) { None, None, ), - Err(failure) => publish( + Err(failure) => dv::publish_logged( DvProbe { capability: DvCapability::Unknown, source: ProbeSource::Failure, @@ -165,7 +107,7 @@ fn run_transport(started: Instant) { None, ), }, - Err(super::ls2::Fail::Timeout) => publish( + Err(super::ls2::Fail::Timeout) => dv::publish_logged( DvProbe { capability: DvCapability::Unknown, source: ProbeSource::Failure, @@ -179,7 +121,7 @@ fn run_transport(started: Instant) { stage, detail, code, - }) => publish( + }) => dv::publish_logged( DvProbe { capability: DvCapability::Unknown, source: ProbeSource::Failure, @@ -195,11 +137,10 @@ fn run_transport(started: Instant) { #[cfg(not(all( target_arch = "arm", target_os = "linux", - not(feature = "hostsim"), not(any(test, feature = "test-support")) )))] fn run_transport(started: Instant) { - publish( + dv::publish_logged( DvProbe { capability: DvCapability::Unknown, source: ProbeSource::Host, @@ -214,7 +155,6 @@ fn run_transport(started: Instant) { #[cfg(all( target_arch = "arm", target_os = "linux", - not(feature = "hostsim"), not(any(test, feature = "test-support")) ))] fn reply_error_code(reply: &str) -> Option { @@ -228,7 +168,7 @@ fn reply_error_code(reply: &str) -> Option { #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[cfg(any( test, - all(target_arch = "arm", target_os = "linux", not(feature = "hostsim")) + all(target_arch = "arm", target_os = "linux") ))] enum ProbeFailure { Json, @@ -240,13 +180,12 @@ enum ProbeFailure { #[cfg(any( test, - all(target_arch = "arm", target_os = "linux", not(feature = "hostsim")) + all(target_arch = "arm", target_os = "linux") ))] impl ProbeFailure { #[cfg(all( target_arch = "arm", target_os = "linux", - not(feature = "hostsim"), not(any(test, feature = "test-support")) ))] const fn stage(self) -> &'static str { @@ -270,7 +209,7 @@ impl ProbeFailure { /// gets. `major == 0` is an unknown version and keeps configd's answer; webOS 4+ is untouched. #[cfg(any( test, - all(target_arch = "arm", target_os = "linux", not(feature = "hostsim")) + all(target_arch = "arm", target_os = "linux") ))] fn platform_gate(probe: DvProbe, webos_major: u32) -> DvProbe { if probe.capability == DvCapability::Supported && (1..=3).contains(&webos_major) { @@ -288,7 +227,7 @@ fn platform_gate(probe: DvProbe, webos_major: u32) -> DvProbe { /// by a boolean elsewhere in the object. #[cfg(any( test, - all(target_arch = "arm", target_os = "linux", not(feature = "hostsim")) + all(target_arch = "arm", target_os = "linux") ))] fn parse_dv_reply(reply: &str) -> Result { let value: serde_json::Value = serde_json::from_str(reply).map_err(|_| ProbeFailure::Json)?; @@ -322,7 +261,7 @@ fn parse_dv_reply(reply: &str) -> Result { #[cfg(test)] mod tests { - use super::{override_capability, parse_dv_reply, platform_gate, DvCapability, ProbeFailure}; + use super::{parse_dv_reply, platform_gate, DvCapability, ProbeFailure}; use crate::devcaps::dv::{DvProbe, ProbeSource}; fn configd(capability: DvCapability) -> DvProbe { @@ -368,23 +307,6 @@ mod tests { ); } - #[test] - fn dv_caps_override_precedence() { - assert_eq!(override_capability(false, false), None); - assert_eq!( - override_capability(true, false), - Some((DvCapability::Unsupported, false)) - ); - assert_eq!( - override_capability(false, true), - Some((DvCapability::Supported, false)) - ); - assert_eq!( - override_capability(true, true), - Some((DvCapability::Unsupported, true)) - ); - } - #[test] fn dv_caps_reply_parser_real_shapes() { use DvCapability::{Supported, Unsupported}; diff --git a/rust-modules/os/src/webos/jail_repair.rs b/rust-modules/os/src/webos/jail_repair.rs index 324dc52dc4..b69f2e2cd4 100644 --- a/rust-modules/os/src/webos/jail_repair.rs +++ b/rust-modules/os/src/webos/jail_repair.rs @@ -7,12 +7,12 @@ use crate::tv::native_video::Failure; use serde_json::Value; use std::path::Path; -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] use std::time::Duration; -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] const EXEC_URI: &str = "luna://org.webosbrew.hbchannel.service/exec"; -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] const BUDGET: Duration = Duration::from_secs(10); const OK_MARKER: &str = "PLXNATIVE_JAIL_REPAIR_OK_74"; const NOT_ROOT_MARKER: &str = "PLXNATIVE_JAIL_REPAIR_NOT_ROOT_74"; @@ -30,7 +30,7 @@ pub fn execute() -> Result<(), Failure> { const RTKMEM: &str = "/dev/rtkmem"; -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] fn call_hbc(payload: &str) -> Result { let registration = super::ls2::register().map_err(|_| Failure::HbcUnavailable)?; registration @@ -41,7 +41,7 @@ fn call_hbc(payload: &str) -> Result { }) } -#[cfg(any(feature = "hostsim", test, feature = "test-support"))] +#[cfg(any(test, feature = "test-support"))] fn call_hbc(_payload: &str) -> Result { Err(Failure::HbcUnavailable) } diff --git a/rust-modules/os/src/webos/toast.rs b/rust-modules/os/src/webos/toast.rs index 53301f2918..da98a612bc 100644 --- a/rust-modules/os/src/webos/toast.rs +++ b/rust-modules/os/src/webos/toast.rs @@ -23,21 +23,19 @@ use crate::tv::toast::{Identity, Outcome, Sent}; const CREATE_TOAST: &str = "luna://com.webos.notification/createToast"; /// How long one round trip may take. Off the UI thread, so generous next to `ls2::BUDGET`. -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] const BUDGET: std::time::Duration = std::time::Duration::from_secs(3); /// The `createToast` payload for `message`, attributed to `source_id`. `noaction` removes the /// launch arrow so the card is a notice, not a shortcut. Built with `serde_json` so every quote, /// backslash, newline and non-ASCII character is escaped by the same writer the rest of the crate /// trusts. -#[cfg_attr(feature = "hostsim", allow(dead_code))] // Built only for a real bus call. pub fn payload(source_id: &str, message: &str) -> String { serde_json::json!({ "sourceId": source_id, "noaction": true, "message": message }).to_string() } /// Grade the service's own reply: `returnValue: true` is acceptance; anything else is a refusal, /// carrying the `errorText` when there is one. -#[cfg_attr(feature = "hostsim", allow(dead_code))] // Graded only against a real bus reply. pub fn grade(reply: &str) -> Outcome { let value = serde_json::from_str::(reply).ok(); let field = |name: &str| value.as_ref().and_then(|v| v.get(name)); @@ -52,7 +50,7 @@ pub fn grade(reply: &str) -> Outcome { /// One attempt under the chosen [`Identity`], reply and grade both. Blocks. The port's /// `deliver_toast`: `tv::toast::send` is the door callers use. -#[cfg(any(feature = "hostsim", test, feature = "test-support"))] +#[cfg(any(test, feature = "test-support"))] pub fn deliver(_message: &str, identity: Identity) -> Sent { plx_base::eventlog::log(&format!( "toast: no LS2 bus off-device — {identity:?} call to {CREATE_TOAST} not sent" @@ -61,7 +59,7 @@ pub fn deliver(_message: &str, identity: Identity) -> Sent { } /// The on-device arm of [`deliver`] above. -#[cfg(all(not(feature = "hostsim"), not(any(test, feature = "test-support"))))] +#[cfg(not(any(test, feature = "test-support")))] pub fn deliver(message: &str, identity: Identity) -> Sent { use super::ls2::{self, Fail}; let payload = payload(plx_base::paths::app_id(), message); diff --git a/rust-modules/os/src/webos/video_sink.rs b/rust-modules/os/src/webos/video_sink.rs index ab4776dc17..c5b9d63b9a 100644 --- a/rust-modules/os/src/webos/video_sink.rs +++ b/rust-modules/os/src/webos/video_sink.rs @@ -25,10 +25,11 @@ //! `sf_play` after `sf_destroy`). Calling any of them remains something to think about; the token //! only says *where* from. //! -//! This module is not compiled for the `hostsim` build or for this crate's own tests: the simulator's -//! own `VideoSink` is the media player's `ffi_host`. The application's test binary does carry it -//! (its dependency is compiled without `cfg(test)`), but `port.rs` installs `NoSink` there, so no -//! live code reaches an extern and the linker drops them. +//! This module is not compiled for this crate's own tests. The application's test binary does carry +//! it (its dependency is compiled without `cfg(test)`), and so does a desktop build, the simulator's +//! own `VideoSink` being the Feed backend's `ffi_host`: `port.rs` installs `NoSink` in the one, and +//! the desktop platform never names this module in the other, so no live code reaches an extern and +//! the linker drops them. use plx_base::task::MainThread; use std::ffi::CStr; use std::os::raw::{c_char, c_int, c_long}; diff --git a/rust-modules/src/bin/sim.rs b/rust-modules/src/bin/sim.rs index e1b1400045..4b7066cd1d 100644 --- a/rust-modules/src/bin/sim.rs +++ b/rust-modules/src/bin/sim.rs @@ -36,9 +36,8 @@ //! PLXNATIVE_RUNTIME_DIR this instance's trigger/FIFO/log root //! PLXNATIVE_APP_DIR where appfont*.ttf and the icons live (repo `pkg/`) -use plxnative_modules::port::plex_run; +use plxnative_modules::platform_desktop; use std::ffi::CString; -use std::os::raw::c_int; /// Defaults chosen to fail loudly rather than silently talk to the wrong thing. const DEFAULT_PORT: u16 = 32400; @@ -97,7 +96,7 @@ fn main() { // No host is not an error — it is what a person who was SENT this app has. The boot host is // only ever consulted by the two paths that already hold credentials (the stored session and - // the harness's injected token); with neither, `plex_run` goes to QR sign-in and plex.tv's + // the harness's injected token); with neither, the application goes to QR sign-in and plex.tv's // `/api/v2/resources` supplies the address, exactly as on a television out of the box. // // The dev loop keeps its loud failure where it belongs: the Makefile's `SIM_PRE` refuses to @@ -145,9 +144,9 @@ fn main() { plx_base::process::exit_now(2) }); - // `as c_int` directly — an intermediate i16 would wrap every port above 32767. - // `plex_run` ends the process itself through `plx_base::process::exit_now` (no `atexit` - // handlers under live workers, #1115); the call is typed `c_int` only for the C shim. - let rc = plex_run(c_host.as_ptr(), port as c_int); + // The desktop platform's entry returns the status the application ended with; ending the + // process is this executable's, through `plx_base::process::exit_now` (no `atexit` handlers + // under live workers, #1115). + let rc = platform_desktop::run(&c_host, port); plx_base::process::exit_now(rc) } diff --git a/rust-modules/src/lib.rs b/rust-modules/src/lib.rs index 6d758077e6..f1fe806ea1 100644 --- a/rust-modules/src/lib.rs +++ b/rust-modules/src/lib.rs @@ -72,17 +72,17 @@ pub fn sim_events_log() -> std::path::PathBuf { plx_base::eventlog::events_log() } -/// The port holds `plex_run`, the C entry the simulator binary calls too. It is reached by path -/// (`plxnative_modules::port::plex_run`) so the SAME entry the C shim calls is the one called, with -/// the compiler checking the signature. It previously re-declared `plex_run` in its own `extern "C"` -/// block, which meant the one binary whose whole premise is "cannot drift from the shipped boot -/// path" was the one place a signature change would become a silent ABI mismatch instead of a -/// compile error. There is deliberately no `pub use` here: a re-export would be a reference from -/// the crate root into the port. -#[cfg(feature = "hostsim")] -pub mod port; -#[cfg(not(feature = "hostsim"))] +/// The webOS port: `plex_run`, the C entry `src/main.c` calls, and the two tables it hands the +/// application. Every build compiles it, the desktop ones included, and a desktop executable never +/// reaches it. mod port; +/// The desktop platform, the simulator's and the macOS app's own: its tables and its entry, which +/// `src/bin/sim.rs` calls by path (`plxnative_modules::platform_desktop::run`) because that binary +/// is a separate crate. It never names the webOS port, so the television's code stays unreferenced +/// in its executable. There is deliberately no `pub use` here: a re-export would be a reference from +/// the crate root into the platform. +#[cfg(feature = "hostsim")] +pub mod platform_desktop; #[cfg(feature = "hostsim")] pub use app::synthetic_home_initial; diff --git a/rust-modules/src/platform_desktop.rs b/rust-modules/src/platform_desktop.rs new file mode 100644 index 0000000000..b4cb8f580e --- /dev/null +++ b/rust-modules/src/platform_desktop.rs @@ -0,0 +1,157 @@ +//! The desktop platform: what `plxnative-sim` and the macOS app hand the application. +//! +//! A desktop has no television's services, so this is a platform in its own right and not the webOS +//! port with its answers faked: [`PLATFORM`] states every hook the application reads, from the +//! shared `NONE` groups of `plx_os::tv` wherever a host has nothing to say (the key manager, the +//! settings service, the device files, the URI media pipe) and with its own body where it has +//! something to do: +//! +//! - the capability probe publishes the host's answer, and honours the same `dvcaps0` / `dvcaps1` +//! dev triggers the television's does (`devcaps::dv`, which both probes end in); +//! - the root press is a log line, the one thing a Mac window has to say about a launcher that does +//! not exist; +//! - the system toast says it was not sent; +//! - the video sink is the Feed backend's host sink (`HOST_SINK`) when the build has one, else the +//! refusing `NoSink`. +//! +//! The shell and the frame probe are plain no-ops: SDL owns the window and its event loop, there is +//! no compositor to hint and no bus to pump. The secure store is `SecureHooks::NONE`: nothing seals, +//! so a session is the 0600 plaintext file the session layer writes itself, which the simulator's +//! harnesses plant and read. +//! +//! This module never names `port`, `system`, `webos` or `keymanager`, so a desktop executable +//! references none of the television's code. It still COMPILES it (the television arms of those +//! files have no `hostsim` gate any more), and the linker drops what nothing reaches: a build that +//! made one of them reachable would fail to link for want of libwayland, glib or luna-service2, on +//! a Mac and on Linux alike. `simulators.yml` links the shapes the simulator ships in to guard that +//! until the platform crates split (`docs/platform-ports.md`, W7). +use crate::app::platform::{FrameProbe, Platform, Shell}; +use plx_os::devcaps::dv::{self, DvCapability, DvProbe, ProbeSource}; +use plx_os::tv::toast::{Identity, Outcome, Sent}; +use plx_os::tv::{IdentityHooks, LegacyWebosMedia, SecureHooks, Services, SystemHooks}; +use std::ffi::CStr; +use std::os::raw::{c_int, c_void}; + +/// The Feed backend's host sink, built with the simulator's decoded picture. +#[cfg(feature = "play-feed")] +const SINK: &dyn plx_os::tv::sink::VideoSink = &crate::app::adapters::hostsim::HOST_SINK; +/// A build without the Feed backend has no picture to show: every verb is refused. +#[cfg(not(feature = "play-feed"))] +const SINK: &dyn plx_os::tv::sink::VideoSink = &plx_os::tv::sink::NoSink; + +/// The display binding the player's plane boot resolves: the same sink, so the plane is the host's. +const DISPLAY: &dyn plx_os::tv::sink::DisplaySink = SINK; + +/// What the lower layers read from the desktop platform. Every hook is stated, as `tv` requires: a +/// hook a host has nothing to say for is the shared `NONE` group's own, named, so a hook added to a +/// group is a compile error here until this platform states it. +static SERVICES: Services = Services { + identity: IdentityHooks { + probe_device: IdentityHooks::NONE.probe_device, + start_capability_probe, + repair_native_video: IdentityHooks::NONE.repair_native_video, + device_files: IdentityHooks::NONE.device_files, + system_locale: IdentityHooks::NONE.system_locale, + sound_output: IdentityHooks::NONE.sound_output, + }, + secure: SecureHooks::NONE, + system: SystemHooks { go_home, poll_home: SystemHooks::NONE.poll_home, deliver_toast }, + legacy_webos_media: LegacyWebosMedia { + sink: SINK, + display_sink: DISPLAY, + uri_media: LegacyWebosMedia::NONE.uri_media, + }, +}; + +/// The boot capability probe: a host has no configd to ask, so it answers `unknown`, from the host, +/// unless a dev trigger forces the answer. Synchronous, with no worker: the answer needs no bus, +/// and the app reads it only after boot. +fn start_capability_probe() { + let started = std::time::Instant::now(); + if dv::publish_forced(started) { + return; + } + dv::publish_logged( + DvProbe { capability: DvCapability::Unknown, source: ProbeSource::Host, reason: "host" }, + started, + None, + None, + ); +} + +/// The root press: there is no launcher to hand a desktop window to, so the screen does not change +/// and the press is a log line, the one the simulator's skill (`ui-sim`) tells a reader to look for. +fn go_home() { + plx_base::eventlog::log("gohome: request mode=auto"); + plx_base::eventlog::log( + "gohome: no LS2 bus off-device — the root press would launch com.webos.app.home on a television", + ); +} + +/// The system toast: a host has no notification service this app may call, so nothing is sent. +fn deliver_toast(_message: &str, identity: Identity) -> Sent { + plx_base::eventlog::log(&format!("toast: no system notifications on this host — {identity:?} toast not sent")); + Sent { reply: None, outcome: Outcome::NoBus } +} + +/// The desktop shell: SDL owns the window and its event loop, so nothing is bound, grabbed, hinted +/// or pumped, and no surface is ever held. +struct DesktopShell; + +impl Shell for DesktopShell { + fn bind_window(&self, _win: *mut c_void) {} + fn grab_surface(&self, _win: *mut c_void) {} + fn release_surface(&self) -> bool { + false + } + fn arm_opaque_region(&self) {} + fn opaque_route(&self, _player: bool) {} + fn clear_opaque_region(&self) {} + fn pump_bus(&self) {} +} + +/// The desktop frame probe: always unarmed, there is no compositor callback to clock. +struct DesktopProbe; + +impl FrameProbe for DesktopProbe { + fn request(&self) {} + fn prepare_begin(&self) {} + fn prepare_end(&self) {} + fn waiting(&self) {} + fn acquired(&self) {} + fn fields(&self) -> String { + String::new() + } +} + +/// The desktop platform: what [`run`] hands `app::run_application`. +static PLATFORM: Platform = Platform::new(&SERVICES, &DesktopShell, &DesktopProbe); + +/// The desktop entry: boot the application on [`PLATFORM`] and return the status it ended with. +/// Ending the process is the executable's (`src/bin/sim.rs`), which owns it, like the television's +/// entry does (`port::plex_main`): a process that hosts the application never does. +/// +/// Nothing is logged before `run_application`: a boot it refuses early must leave the log as the +/// harnesses expect (`tests/replay_fixtures.py`). +pub fn run(pms_host: &CStr, pms_port: u16) -> c_int { + crate::app::run_application(&PLATFORM, pms_host.as_ptr(), c_int::from(pms_port)).code +} + +#[cfg(test)] +mod tests { + use super::*; + + /// The app's plane boot resolves the display through `display_installed()` (this table's + /// `display_sink`), where media's old `acb_init` resolved it through `player::display()`. In + /// the simulator both must be the host sink, never `NoSink`: a boot that read `NoSink` would + /// report no plane to every backend and nothing in a simulator run would say so. + #[cfg(feature = "play-feed")] + #[test] + fn the_simulator_port_display_is_the_host_sink_the_acb_init_reads() { + let host = std::ptr::from_ref(&crate::app::adapters::hostsim::HOST_SINK).cast::<()>(); + let media = &SERVICES.legacy_webos_media; + assert_eq!(std::ptr::from_ref(media.display_sink).cast::<()>(), host, + "display_installed() is the host sink"); + assert_eq!(std::ptr::from_ref(media.sink).cast::<()>(), host, "so is the video sink"); + } +} diff --git a/rust-modules/src/port.rs b/rust-modules/src/port.rs index 6214eecef0..7f717ca525 100644 --- a/rust-modules/src/port.rs +++ b/rust-modules/src/port.rs @@ -3,25 +3,21 @@ //! `plx_os::tv::Services` is what the lower layers read, and `app::platform::Platform` adds the shell //! and the frame probe the loop alone reads. Everything outside this module reaches the television //! through those; this is the only place that names `webos`, `keymanager`, `system` and the native -//! video sink together. Its functions keep their own `cfg(any(hostsim, test))` arms, so the -//! simulator runs on these same tables and behaves as it always did. +//! video sink together. The simulator and the macOS app are not on these tables: they are their own +//! platform (`platform_desktop`), which never names this module, so a desktop build compiles the +//! television's code and the linker drops it. use crate::app::platform::{FrameProbe, Platform, Shell}; use std::os::raw::{c_char, c_int, c_void}; -#[cfg(all(not(feature = "hostsim"), not(test), feature = "play-feed"))] +#[cfg(all(not(test), feature = "play-feed"))] const SINK: &dyn plx_os::tv::sink::VideoSink = &plx_os::webos::video_sink::StarfishSink; -#[cfg(all(feature = "hostsim", feature = "play-feed"))] -const SINK: &dyn plx_os::tv::sink::VideoSink = &crate::app::adapters::hostsim::HOST_SINK; -#[cfg(any( - all(feature = "hostsim", not(feature = "play-feed")), - all(not(feature = "hostsim"), any(test, not(feature = "play-feed"))), -))] +#[cfg(any(test, not(feature = "play-feed")))] const SINK: &dyn plx_os::tv::sink::VideoSink = &plx_os::tv::sink::NoSink; // URI-only native builds retain the display vtable without the packet-feed vtable. -#[cfg(all(not(feature = "hostsim"), not(test)))] +#[cfg(not(test))] const DISPLAY: &dyn plx_os::tv::sink::DisplaySink = &plx_os::webos::video_sink::StarfishSink; -#[cfg(any(feature = "hostsim", test))] +#[cfg(test)] const DISPLAY: &dyn plx_os::tv::sink::DisplaySink = SINK; /// What the lower layers read: the webOS identity, key manager, Home key and toast, and the native @@ -109,8 +105,8 @@ impl FrameProbe for WebosProbe { /// for the lower layers and keeps it for the loop. static PLATFORM: Platform = Platform::new(&SERVICES, &WebosShell, &WebosProbe); -/// The C shim's entry (`src/main.c`) and the simulator's (`src/bin/sim.rs`). The `-> c_int` is only -/// the C signature: `plex_main` never returns, so neither does this. +/// The C shim's entry (`src/main.c`). The `-> c_int` is only the C signature: `plex_main` never +/// returns, so neither does this. #[no_mangle] pub extern "C" fn plex_run(pms_host: *const c_char, pms_port: c_int) -> c_int { plex_main(pms_host, pms_port) @@ -152,21 +148,3 @@ pub unsafe extern "C" fn plx_launch_args(json: *const c_char) { let raw = unsafe { std::ffi::CStr::from_ptr(json) }.to_string_lossy(); plx_os::tv::launch::offer(&raw); } - -#[cfg(all(test, feature = "hostsim", feature = "play-feed"))] -mod tests { - use super::SERVICES; - - /// The app's plane boot resolves the display through `display_installed()` (this table's - /// `display_sink`), where media's old `acb_init` resolved it through `player::display()`. In - /// the simulator both must be the host sink, never `NoSink`: a boot that read `NoSink` would - /// report no plane to every backend and nothing in a simulator run would say so. - #[test] - fn the_simulator_port_display_is_the_host_sink_the_acb_init_reads() { - let host = std::ptr::from_ref(&crate::app::adapters::hostsim::HOST_SINK).cast::<()>(); - let media = &SERVICES.legacy_webos_media; - assert_eq!(std::ptr::from_ref(media.display_sink).cast::<()>(), host, - "display_installed() is the host sink"); - assert_eq!(std::ptr::from_ref(media.sink).cast::<()>(), host, "so is the video sink"); - } -} diff --git a/rust-modules/src/system.rs b/rust-modules/src/system.rs index 78fccd594e..21c87081bc 100644 --- a/rust-modules/src/system.rs +++ b/rust-modules/src/system.rs @@ -18,8 +18,6 @@ const GL_STENCIL_BITS: c_uint = 0x0D57; // SDL_SysWMinfo layout (32-bit): version u8[3]@0, subsystem int@4, info union@8 extern "C" { - // the wayland grab is `cfg(not(hostsim))` — desktop SDL has no webOS surface to reach for - #[cfg_attr(feature = "hostsim", allow(dead_code))] fn SDL_GetWindowWMInfo(window: *mut c_void, info: *mut c_void) -> c_int; /// Fills `SDL_version` — three `Uint8`, major/minor/patch. fn SDL_GetVersion(ver: *mut u8); @@ -28,10 +26,9 @@ extern "C" { } // The three symbols that exist only on a television: wayland's proxy marshaller and glib's main -// context. The desktop simulator links neither — SDL owns its own event loop there, and there is -// no luna bus to pump — so they are declared apart rather than in the block above, which would -// otherwise fail the host link. -#[cfg(not(feature = "hostsim"))] +// context. A host build links neither: the desktop platform (`platform_desktop`) brings its own +// shell, so nothing it runs reaches this file, and the linker drops the television code that does. +// They are declared apart rather than in the block above, which every host build links against. extern "C" { fn wl_proxy_marshal(proxy: *mut c_void, opcode: c_uint, ...); fn g_main_context_pending(ctx: *mut c_void) -> c_int; @@ -50,7 +47,6 @@ static mut G_WL_DISPLAY: *mut c_void = std::ptr::null_mut(); /// crumb does not fire. So a `surface_changed` crumb proves a replacement, but a missing crumb /// does not prove the surface was kept. Comparing `wl_proxy_get_id` would not help, because /// Wayland recycles object ids through a free list. -#[cfg(any(not(feature = "hostsim"), test))] static G_WL_SURFACE_SEEN: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); pub(crate) fn clear_opaque_region() { @@ -63,15 +59,12 @@ pub(crate) fn clear_opaque_region() { // commit is left to SDL_GL_SwapWindow (a bare commit here presents a // null-buffer surface and disrupts the slaved video plane). // - // Nothing to do on the simulator: there is no video plane underneath to show through, so - // a non-opaque surface would buy a desktop compositor nothing but per-frame blending. - // - // …and nothing to LINK against under `cargo test`. Since phase 9 this is reached through + // Nothing to LINK against under `cargo test`. Since phase 9 this is reached through // `Rig::clear_opaque_region` (`app/bridge.rs`), which the host suite exercises, where // before it was reachable only from `plex_run` and the dead-strip hid the missing // `libwayland-client`. The guard below is `G_WL_SURFACE`, which is null in a test, so // nothing is skipped that would have run. - #[cfg(all(not(feature = "hostsim"), not(test)))] + #[cfg(not(test))] wl_proxy_marshal(surface, 4, std::ptr::null_mut::()); } } @@ -88,10 +81,7 @@ pub(crate) fn sys_release_wayland() -> bool { let had_surface = !G_WL_SURFACE.is_null(); G_WL_SURFACE = std::ptr::null_mut(); G_WL_DISPLAY = std::ptr::null_mut(); - #[cfg(not(feature = "hostsim"))] - { - G_OPAQUE_SENT = -1; - } + G_OPAQUE_SENT = -1; if had_surface { log("wm: released borrowed Wayland handles"); } @@ -100,11 +90,7 @@ pub(crate) fn sys_release_wayland() -> bool { } /// Service the glib main context that luna-service2 replies arrive on. -/// -/// A no-op on the simulator: glib is not linked and there is no luna bus to pump, so the loop -/// simply has nothing to service. Every caller stays unchanged. pub(crate) fn ls2_pump() { - #[cfg(not(feature = "hostsim"))] unsafe { let mut guard = 8; while guard > 0 && g_main_context_pending(std::ptr::null_mut()) != 0 { @@ -151,9 +137,9 @@ pub(crate) fn sys_grab_wayland(winp: *mut c_void) { let mut sbits: c_int = -1; glGetIntegerv(GL_ALPHA_BITS, &mut abits); glGetIntegerv(GL_RED_BITS, &mut rbits); - // Deprecated in a desktop CORE profile (the simulator), where they leave the value alone - // and raise `GL_INVALID_ENUM` — harmless and once, at boot, and the SDL attributes above - // answer the same question portably. On the television's ES2 context both are legal. + // Deprecated in a desktop CORE profile, where they would leave the value alone and raise + // `GL_INVALID_ENUM`; the SDL attributes above answer the same question portably. On the + // television's ES2 context, the only one this runs on, both are legal. glGetIntegerv(GL_DEPTH_BITS, &mut dbits); glGetIntegerv(GL_STENCIL_BITS, &mut sbits); // `depth=`/`stencil=` are here to be READ: `app.rs` asks for zero of each because nothing @@ -164,14 +150,9 @@ pub(crate) fn sys_grab_wayland(winp: *mut c_void) { "FB bits: alpha={abits} red={rbits} depth={dbits} stencil={sbits} \ (config alpha={a} depth={d} stencil={s})" )); - // The Wayland query is webOS-only. Desktop SDL reports a different backend with a - // different union layout, and has no hardware video plane needing this request. // update_wayland_info reads unaligned because the oversized byte buffer has no pointer // alignment guarantee, and rejects any non-Wayland subsystem before reading the union. - #[cfg(not(feature = "hostsim"))] update_wayland_info(SDL_GetWindowWMInfo(winp, wmbuf.as_mut_ptr() as *mut c_void), &wmbuf); - #[cfg(feature = "hostsim")] - let _ = winp; let subsystem = i32::from_ne_bytes([wmbuf[4], wmbuf[5], wmbuf[6], wmbuf[7]]); let (surf, disp) = (G_WL_SURFACE, G_WL_DISPLAY); // The version bytes are still in wmbuf[0..3] — SDL_GetWindowWMInfo validates them and @@ -183,7 +164,7 @@ pub(crate) fn sys_grab_wayland(winp: *mut c_void) { // Loud, because the consequence is a black screen with working audio and nothing else in // the log would say why. SDL_SYSWM_WAYLAND is 6 in SDL2's enum; anything else here means // we did not get a surface and the video plane will stay hidden under an opaque UI. - if surf.is_null() && !cfg!(feature = "hostsim") { + if surf.is_null() { log( "wm: NO wl_surface — the UI plane cannot be made transparent, so video will \ decode invisibly beneath it. Check the SDL_SysWMinfo version handshake.", @@ -229,32 +210,22 @@ use plx_base::eventlog::log; /// `wl_registry.bind` / `wl_compositor.create_region` / `wl_region.add` — opcodes from /// `wayland-client-protocol.h` (`WL_REGISTRY_BIND 0`, `WL_COMPOSITOR_CREATE_REGION 1`, /// `WL_REGION_ADD 1`), beside `WL_SURFACE_SET_OPAQUE_REGION 4` which this file already used. -#[cfg(not(feature = "hostsim"))] const WL_REGISTRY_BIND: c_uint = 0; -#[cfg(not(feature = "hostsim"))] const WL_DISPLAY_GET_REGISTRY: c_uint = 1; -#[cfg(not(feature = "hostsim"))] const WL_COMPOSITOR_CREATE_REGION: c_uint = 1; -#[cfg(not(feature = "hostsim"))] const WL_REGION_ADD: c_uint = 1; -#[cfg(not(feature = "hostsim"))] const WL_SURFACE_SET_OPAQUE_REGION: c_uint = 4; /// The full-surface `wl_region`, created once at boot. Never per frame — a region is a server /// object and allocating one every present would be protocol traffic on the frame path. -#[cfg(not(feature = "hostsim"))] static mut G_WL_REGION: *mut c_void = std::ptr::null_mut(); /// What we last told the compositor: `1` = the full region, `0` = NULL, `-1` = nothing yet. -#[cfg(not(feature = "hostsim"))] static mut G_OPAQUE_SENT: i8 = -1; /// Set only by [`opaque_region_init`], and only when the trigger armed AND a region was built. -#[cfg(not(feature = "hostsim"))] static mut G_OPAQUE_ENABLED: bool = false; /// Scratch for the registry callback: the `wl_compositor` proxy it binds. -#[cfg(not(feature = "hostsim"))] static mut G_WL_COMPOSITOR: *mut c_void = std::ptr::null_mut(); -#[cfg(not(feature = "hostsim"))] #[repr(C)] struct RegistryListener { global: unsafe extern "C" fn(*mut c_void, *mut c_void, c_uint, *const std::ffi::c_char, c_uint), @@ -263,17 +234,14 @@ struct RegistryListener { /// A libwayland symbol from the process's own scope. `libwayland-client` is linked normally, so it /// is already mapped; this only avoids naming these particular symbols in `DT_NEEDED`. -#[cfg(not(feature = "hostsim"))] fn wl_sym(name: &str) -> Option<*mut c_void> { plx_base::dynlib::Handle::self_handle() .sym(name) .filter(|p| !p.is_null()) } -#[cfg(not(feature = "hostsim"))] unsafe extern "C" fn on_global_remove(_data: *mut c_void, _reg: *mut c_void, _name: c_uint) {} -#[cfg(not(feature = "hostsim"))] unsafe extern "C" fn on_global( _data: *mut c_void, registry: *mut c_void, @@ -324,7 +292,6 @@ unsafe extern "C" fn on_global( /// Build the full-surface opaque region, once, at boot. No-op unless `/tmp/plxnative-opaque` is /// armed; returns without touching the surface's current (NULL) region either way. -#[cfg(not(feature = "hostsim"))] pub(crate) fn opaque_region_init() { if !plx_base::devtrig::flag("opaque") { return; @@ -420,15 +387,11 @@ pub(crate) fn opaque_region_init() { )); } -#[cfg(feature = "hostsim")] -pub(crate) fn opaque_region_init() {} - /// Assert the opaque region appropriate to this route, if the experiment is armed. /// /// A no-op — one read of a `static` and a return — whenever `/tmp/plxnative-opaque` is absent, /// which is what keeps the default path byte-identical. Only sends a request when the answer /// CHANGES, because the opaque region is sticky server-side. -#[cfg(not(feature = "hostsim"))] pub(crate) fn opaque_route(player: bool) { unsafe { if !G_OPAQUE_ENABLED { @@ -464,11 +427,6 @@ pub(crate) fn opaque_route(player: bool) { } } -/// Nothing to declare opaque on a desktop: there is no video plane underneath and no LG compositor -/// to hint. The simulator keeps the same call site rather than growing a `cfg` at it. -#[cfg(feature = "hostsim")] -pub(crate) fn opaque_route(_player: bool) {} - // ---- The COMPOSITOR FRAME-CALLBACK PROBE (`/tmp/plxnative-framecb`) ----------------------------- // // A present's wait for a free back buffer is paid inside the frame's first framebuffer-0 command @@ -496,9 +454,9 @@ pub(crate) fn opaque_route(_player: bool) {} // from the process's own scope, ONCE (`frame_syms`, on the first armed present, before the swap // stretch is marked), so the probe adds no symbol to the link and its lookups are not charged to // the `s` stretch. Unarmed it is one latched bool per presented frame. The whole probe is -// compiled only with `devtriggers` (and not in the simulator); the shipping build has the empty +// compiled only with `devtriggers`; the shipping build has the empty // stubs at the end of this section. -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] plx_base::devtrig::latched_flag!( /// `/tmp/plxnative-framecb` — see the section comment above. pub(crate) fn frame_probe_armed = "framecb"; @@ -506,12 +464,12 @@ plx_base::devtrig::latched_flag!( /// `(frame seq, compositor stamp ms, our CLOCK_MONOTONIC µs at dispatch)` for every `done` that /// arrived since the last [`frame_probe_fields`]. -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] static FRAME_DONE: std::sync::Mutex> = std::sync::Mutex::new(Vec::new()); -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] static FRAME_SEQ: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0); -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] fn mono_us() -> u64 { let mut ts = libc::timespec { tv_sec: 0, tv_nsec: 0 }; // SAFETY: a plain clock read into a local. @@ -520,7 +478,7 @@ fn mono_us() -> u64 { } /// What the frame thread has cost so far, read at each boundary of a frame's present. -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] #[derive(Clone, Copy, Default)] struct ThreadCost { /// `CLOCK_MONOTONIC`, µs. @@ -536,7 +494,7 @@ struct ThreadCost { preempted: u64, } -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] impl ThreadCost { fn now() -> Self { let mut ts = libc::timespec { tv_sec: 0, tv_nsec: 0 }; @@ -590,10 +548,10 @@ impl ThreadCost { /// This frame's boundaries: `[before the first framebuffer command, back buffer acquired, before /// the swap]`. Frame-thread only; a `Mutex` because it is a `static`. -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] static FRAME_COST: std::sync::Mutex<[Option; 3]> = std::sync::Mutex::new([None; 3]); -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] fn frame_probe_mark(slot: usize) { if !frame_probe_armed() { return; @@ -605,11 +563,11 @@ fn frame_probe_mark(slot: usize) { /// `prepare_window`'s boundaries: `[before, after]`. Independent of [`FRAME_COST`]: it is marked on /// frames that never reach the wait. Frame-thread only. -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] static PREPARE_COST: std::sync::Mutex<[Option; 2]> = std::sync::Mutex::new([None; 2]); /// `prepare_window` is next. Starts the frame's `p` stretch, dropping any earlier frame's marks. -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] pub(crate) fn frame_probe_prepare_begin() { if !frame_probe_armed() { return; @@ -620,7 +578,7 @@ pub(crate) fn frame_probe_prepare_begin() { } /// `prepare_window` has returned: closes the frame's `p` stretch. -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] pub(crate) fn frame_probe_prepare_end() { if !frame_probe_armed() { return; @@ -631,19 +589,19 @@ pub(crate) fn frame_probe_prepare_end() { } /// The frame's first framebuffer command is next: the wait for a back buffer starts here. -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] pub(crate) fn frame_probe_waiting() { frame_probe_mark(0); } /// The frame's first framebuffer command has returned: the back buffer is acquired. -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] pub(crate) fn frame_probe_acquired() { frame_probe_mark(1); } /// The libwayland entry points the probe calls, as addresses (a raw pointer is not `Sync`). -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] struct FrameSyms { ctor: usize, add_listener: usize, @@ -654,7 +612,7 @@ struct FrameSyms { /// Resolved once. `None` when any of the three request symbols is missing, which makes the probe a /// silent no-op. -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] fn frame_syms() -> Option<&'static FrameSyms> { static SYMS: std::sync::OnceLock> = std::sync::OnceLock::new(); SYMS.get_or_init(|| { @@ -668,7 +626,7 @@ fn frame_syms() -> Option<&'static FrameSyms> { .as_ref() } -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] unsafe extern "C" fn on_frame_done(data: *mut c_void, callback: *mut c_void, time: c_uint) { if let Ok(mut done) = FRAME_DONE.lock() { done.push((data as usize as u32, time, mono_us())); @@ -681,7 +639,7 @@ unsafe extern "C" fn on_frame_done(data: *mut c_void, callback: *mut c_void, tim } /// Ask for this frame's callback. Call on a PRESENTING frame, before the swap that commits it. -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] pub(crate) fn frame_probe_request() { if !frame_probe_armed() { return; @@ -722,7 +680,7 @@ pub(crate) fn frame_probe_request() { /// the section comment, then `p=`/`psw=` for the frame's `prepare_window` (independent of them: it /// prints whenever that frame took both of its marks, wait or no wait), then `cb=::` for each callback that /// arrived since the previous line. `""` unarmed. -#[cfg(all(not(feature = "hostsim"), feature = "devtriggers"))] +#[cfg(feature = "devtriggers")] pub(crate) fn frame_probe_fields() -> String { if !frame_probe_armed() { return String::new(); @@ -758,24 +716,23 @@ pub(crate) fn frame_probe_fields() -> String { out } -#[cfg(any(feature = "hostsim", not(feature = "devtriggers")))] +#[cfg(not(feature = "devtriggers"))] pub(crate) fn frame_probe_request() {} -#[cfg(any(feature = "hostsim", not(feature = "devtriggers")))] +#[cfg(not(feature = "devtriggers"))] pub(crate) fn frame_probe_prepare_begin() {} -#[cfg(any(feature = "hostsim", not(feature = "devtriggers")))] +#[cfg(not(feature = "devtriggers"))] pub(crate) fn frame_probe_prepare_end() {} -#[cfg(any(feature = "hostsim", not(feature = "devtriggers")))] +#[cfg(not(feature = "devtriggers"))] pub(crate) fn frame_probe_waiting() {} -#[cfg(any(feature = "hostsim", not(feature = "devtriggers")))] +#[cfg(not(feature = "devtriggers"))] pub(crate) fn frame_probe_acquired() {} -#[cfg(any(feature = "hostsim", not(feature = "devtriggers")))] +#[cfg(not(feature = "devtriggers"))] pub(crate) fn frame_probe_fields() -> String { String::new() } // Publish SDL's borrowed handles. Kept separate from the native query so failed queries can // be exercised without loading the television's SDL or marshalling a fake proxy. -#[cfg(any(not(feature = "hostsim"), test))] unsafe fn update_wayland_info(ok: c_int, info: &[u8; 512]) { sys_release_wayland(); let subsystem = i32::from_ne_bytes(info[4..8].try_into().unwrap()); @@ -846,11 +803,9 @@ mod wayland_tests { pointers.add(1).write_unaligned(surface_ptr); update_wayland_info(1, &info); let acquired = (G_WL_DISPLAY, G_WL_SURFACE); - #[cfg(not(feature = "hostsim"))] - { G_OPAQUE_SENT = 1; } + G_OPAQUE_SENT = 1; assert!(sys_release_wayland(), "a held surface answers true"); assert!(!sys_release_wayland(), "WILL + DID background is idempotent: nothing left to release"); - #[cfg(not(feature = "hostsim"))] { let sent = G_OPAQUE_SENT; assert_eq!(sent, -1); } let released = (G_WL_DISPLAY, G_WL_SURFACE); clear_opaque_region(); // No native marshal can run after revocation. From a8fb39b2d17c95b2b28094e961b97de79f0b1c1f Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Fri, 20 Nov 2026 13:51:37 +0300 Subject: [PATCH 2/5] CI links the macOS app's feature set, and the prose follows the desktop platform The simulator's television code is now compiled in every build and only the linker keeps it out of the executable, so the macOS simulator job links the shape `make macapp` ships (`--no-default-features --features hostsim,play-feed`, in debug, in its own target tree) and says why: it guards the dead-strip reliance until the platform crates split. `ci/test_sim_backend.py` scans `simulators.yml` for the same `play-feed` rule it holds for the other simulator builds. `ci.yml`'s comment that nothing else compiles the simulator feature set was stale before this change; it now names what does. `.gitignore` lists the `target-sim-ci*` trees that job builds into, and the `ci/mkmacapp.py`, `ci/test_sim_backend.py` and `docs/macos-app.md` prose names the desktop platform where it said the simulator swaps the television's sink in. Co-Authored-By: Claude --- .github/workflows/ci.yml | 5 +++-- .github/workflows/simulators.yml | 22 +++++++++++++++++++++- .gitignore | 3 +++ ci/mkmacapp.py | 5 +++-- ci/test_sim_backend.py | 25 ++++++++++++++----------- docs/macos-app.md | 6 +++--- 6 files changed, 47 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e7882e75f..3e220bbe9d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -273,8 +273,9 @@ jobs: - name: Type-check the simulator feature set # The host simulator is a real build configuration with real users (the `ui-sim` skill, and # `make macapp`, which ships `--release --no-default-features --features hostsim,play-feed` to - # somebody who has none of this installed). Nothing else in CI compiles it, so a change that - # only breaks the Mac side merges green and is found by a person trying to demo the app. + # somebody who has none of this installed). `simulators.yml` builds, links and launches it on + # macOS and Linux, in jobs that need a macOS runner and the host FFmpeg; this is the cheap early + # answer for the same feature sets, so a change that only breaks the Mac side fails here first. run: | cd rust-modules cargo "+$RUST_TOOLCHAIN" check --lib --features hostsim diff --git a/.github/workflows/simulators.yml b/.github/workflows/simulators.yml index a953ac2210..185d527aa0 100644 --- a/.github/workflows/simulators.yml +++ b/.github/workflows/simulators.yml @@ -188,10 +188,30 @@ jobs: uses: ./.github/actions/deps-cache - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 with: - workspaces: rust-modules -> target-sim-ci + workspaces: | + rust-modules -> target-sim-ci + rust-modules -> target-sim-ci-macapp key: simulator-macos - name: Build native macOS simulator run: make sim-macos SIM_TDIR=rust-modules/target-sim-ci + - name: Link the macOS app's feature set + # What `make macapp` ships: `--no-default-features --features hostsim,play-feed` (the + # release build in `ci/mkmacapp.py`, linked here in DEBUG: the harder case for the reliance + # below, and cheaper than a release build). The desktop platform (`platform_desktop`) never + # names the television's code, but the crate still COMPILES it (`system.rs`'s Wayland and + # SDL-private externs, `webos`, `keymanager`): a host executable links only because nothing + # references those items and the linker drops them (`-dead_strip` here, `--gc-sections` on + # Linux). A change that makes one reachable from the desktop entry fails this link on + # libwayland, glib or luna-service2, which the default-features build above may not show. This + # step guards that reliance until the platform crates split and the desktop build no longer + # contains `webos` (docs/platform-ports.md, W7). It has its own target dir because cargo does + # not hash its output: in `target-sim-ci` it would overwrite the binary the steps below run. + # The host FFmpeg and libass it links were staged by the step above. + run: | + CARGO_INCREMENTAL=0 cargo "+$(make -s print-rust-toolchain)" build \ + --manifest-path rust-modules/Cargo.toml \ + --target-dir rust-modules/target-sim-ci-macapp \ + --no-default-features --features hostsim,play-feed --bin plxnative-sim - name: Replay all committed product recordings # 960x540, not the driver's 1920x1080 default. The runner has no GPU (the log says `GL: # Apple Software Renderer`), so a replay is CPU-bound in the rasteriser and costs what the diff --git a/.gitignore b/.gitignore index 591a3e4aa0..6ef59224f8 100644 --- a/.gitignore +++ b/.gitignore @@ -68,6 +68,9 @@ rust-modules/target-sim-lab/ # `make screenshots-sim` — the documentation-screenshot simulator (hostsim + devtriggers). rust-modules/target-sim-shots/ rust-modules/target-sim-video/ +# `simulators.yml` builds into `target-sim-ci` (`make sim-macos SIM_TDIR=...`) and `target-sim-ci-macapp` +# (the macapp feature set's link), in the checkout; a lane reproducing that job gets the same trees. +rust-modules/target-sim-ci*/ # pkg/plxnative-storage's own target dir, deliberately separate from $(RUST_TDIR) — see the # Makefile's STORAGE_TDIR comment. One glob for every RELEASE/LAB/SYMBOLS combination. rust-modules/target*-storage/ diff --git a/ci/mkmacapp.py b/ci/mkmacapp.py index 7fae3c4987..a8df0451de 100755 --- a/ci/mkmacapp.py +++ b/ci/mkmacapp.py @@ -1,8 +1,9 @@ #!/usr/bin/env python3 """Build `PlxNative.app` — the app core as a SELF-CONTAINED macOS application. -This is the `hostsim` build (`rust-modules/src/bin/sim.rs`): the same UI, the same Plex data layer -and the same event loop the television runs, wrapped in a bundle that carries its own SDL, its own +This is the desktop platform's build (`rust-modules/src/platform_desktop.rs`, entered by +`rust-modules/src/bin/sim.rs`, feature `hostsim`): the same UI, the same Plex data layer and the same +event loop the television runs, booted on the desktop's own platform and wrapped in a bundle that carries its own SDL, its own fonts and its own copy of every non-system library it links, so it starts on a Mac that has none of this repo's build environment installed. What it is NOT is a television — there is no video pipeline off-device (`play-feed/src/ffi_host.rs`), so Play lands on the app's real failure read-out. diff --git a/ci/test_sim_backend.py b/ci/test_sim_backend.py index b063c51342..b218b443c8 100644 --- a/ci/test_sim_backend.py +++ b/ci/test_sim_backend.py @@ -1,14 +1,15 @@ #!/usr/bin/env python3 """Every simulator build that drops the default features still selects the Feed backend. -`hostsim` swaps the television's native video sink for the simulator's (`plx_play_feed::ffi_host`), -but that stand-in is the Feed backend's, so it exists only when `play-feed` is built. A simulator -built `--no-default-features --features hostsim` selects NO backend: its app installs `NoSink`, so -Play can only ever reach the failure read-out and the clock sink (`plxnative-clocksink`) has nothing -to arm. Three builds drift into that state because they drop `devtools` and `devtriggers` with -`--no-default-features` and then list `hostsim` alone: the `.app` bundle (`ci/mkmacapp.py`), the -screenshot simulator (`make screenshots-sim`) and the demo-video simulator (`make site-video-sim`); -so does the CI step that type-checks the simulator feature set, which then proves nothing about the +The simulator is its own platform (`platform_desktop`, which `hostsim` compiles), and the video sink +it hands the application is the Feed backend's host sink (`plx_play_feed::ffi_host`), which exists +only when `play-feed` is built. A simulator built `--no-default-features --features hostsim` selects +NO backend: its platform installs `NoSink`, so Play can only ever reach the failure read-out and the +clock sink (`plxnative-clocksink`) has nothing to arm. Three builds drift into that state because +they drop `devtools` and `devtriggers` with `--no-default-features` and then list `hostsim` alone: +the `.app` bundle (`ci/mkmacapp.py`), the screenshot simulator (`make screenshots-sim`) and the +demo-video simulator (`make site-video-sim`); so do the CI steps that type-check +(`ci.yml`) and link (`simulators.yml`) the simulator feature set, which then prove nothing about the configuration the other three ship. The scan finds every cargo command line in the files that can hold one, joins its continuations and @@ -26,6 +27,7 @@ MAKEFILE = "Makefile" MKMACAPP = "ci/mkmacapp.py" CI_YML = ".github/workflows/ci.yml" +SIMULATORS_YML = ".github/workflows/simulators.yml" def feature_flags(tokens): @@ -91,7 +93,7 @@ def python_cargo_commands(path): def scan(): commands = [] - for path in (MAKEFILE, CI_YML): + for path in (MAKEFILE, CI_YML, SIMULATORS_YML): commands += text_cargo_commands(path) for path in sorted(p.relative_to(ROOT).as_posix() for p in (ROOT / "ci").glob("*.py")): commands += python_cargo_commands(path) @@ -106,7 +108,7 @@ class SimulatorBackend(unittest.TestCase): def test_the_scan_reaches_the_builds_it_exists_for(self): sims = sim_commands(scan()) reached = {(path, bool(no_default)) for path, _, _, no_default, _ in sims} - for site in (MKMACAPP, MAKEFILE, CI_YML): + for site in (MKMACAPP, MAKEFILE, CI_YML, SIMULATORS_YML): with self.subTest(site): self.assertIn((site, True), reached, f"no `--no-default-features --features hostsim` build found in {site}") makefile_lines = " ".join(line for path, _, line, _, _ in sims if path == MAKEFILE) @@ -126,10 +128,11 @@ def test_a_simulator_without_default_features_selects_the_feed_backend(self): ) def test_each_scripted_simulator_build_is_pinned_to_its_features(self): - """The three bundle/screenshot/video builds and the CI type-check, spelled out.""" + """The three bundle/screenshot/video builds and the CI type-check and link, spelled out.""" pinned = { MKMACAPP: {"hostsim", "play-feed"}, CI_YML: {"hostsim", "play-feed"}, + SIMULATORS_YML: {"hostsim", "play-feed"}, } sims = sim_commands(scan()) for site, expected in pinned.items(): diff --git a/docs/macos-app.md b/docs/macos-app.md index 6f513fcd65..735dd796ef 100644 --- a/docs/macos-app.md +++ b/docs/macos-app.md @@ -7,9 +7,9 @@ television runs, packaged so it starts on a Mac that has none of this repo's bui no Homebrew, no SDL, no toolchain. `ci/mkmacapp.py` is the whole recipe; this note is why it looks the way it does and what the result is and is not. -It is **not a new build of the app**. It is `--features hostsim,play-feed` — the desktop simulator -(`docs/…`/`rust-modules/src/bin/sim.rs`, and the `ui-sim` skill) — with the dev features off and a -bundle around it. (`play-feed` is named because `--no-default-features` drops it, and the simulator's +It is **not a new build of the app**. It is `--features hostsim,play-feed` — the desktop simulator, +which boots the app on the desktop's own platform (`rust-modules/src/platform_desktop.rs`, entered by +`rust-modules/src/bin/sim.rs`; the `ui-sim` skill) — with the dev features off and a bundle around it. (`play-feed` is named because `--no-default-features` drops it, and the simulator's video sink belongs to that backend.) Every UI change, every Plex data-layer change, is the same code the ipk ships. ## What it can do, and the one thing it cannot From 3069d8f53c8252f3248c09a33da44d018a7c5b67 Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Fri, 20 Nov 2026 14:06:22 +0300 Subject: [PATCH 3/5] Prose that said the simulator runs the television's tables now says it has its own platform `docs/module-layers.md` told a reader that the simulator runs the same `port.rs` tables with `hostsim` arms, that the stand-ins in `webos` and `keymanager` are what it executes, that it enters through `port::plex_run`, and that W4 was planned. Each of those is now the other way round, so the L15 to L15d status cells, the L15b item 2 paragraph, the sink rule's path list and the entry description follow `platform_desktop`. The same claim sat in `app/exit.rs`, `play-feed`'s `ffi_host`, `app/adapters/{hostsim,backends}.rs`, four comments of `webos.rs` that put the simulator on the webOS probe, the `hostsim` feature's comment in `rust-modules/Cargo.toml`, and the fuzz package's account of why `hostsim` is the one configuration a host executable links: the television's externs are compiled in every build now and only the linker keeps them out, which those lines say instead. Co-Authored-By: Claude --- docs/agent-reference.md | 2 +- docs/module-layers.md | 56 ++++++++++++----------- fuzz/Cargo.toml | 8 ++-- rust-modules/Cargo.toml | 6 ++- rust-modules/os/src/webos.rs | 11 +++-- rust-modules/play-feed/src/ffi_host.rs | 2 +- rust-modules/src/app/adapters/backends.rs | 2 +- rust-modules/src/app/adapters/hostsim.rs | 6 +-- rust-modules/src/app/exit.rs | 5 +- 9 files changed, 53 insertions(+), 45 deletions(-) diff --git a/docs/agent-reference.md b/docs/agent-reference.md index 2207261422..c1b2787593 100644 --- a/docs/agent-reference.md +++ b/docs/agent-reference.md @@ -345,7 +345,7 @@ the pinned Sentry Native cross-build), and `sshpass` (Homebrew; deploy/run use y asserts only what its code promises (no panic, the documented bounds, round trips) and a crash fails the run, with the input in `fuzz/artifacts//`. The package is a top-level `fuzz/` with its own `[workspace]`, so no shipped `Cargo.toml` names it and no shipped build changes; it depends on the layer - crates by path, with `plx_media/hostsim` (the one configuration that links on a host), and `fuzz/build.rs` + crates by path, with `plx_media/hostsim` (the host configuration: the Feed backend's host sink and the layers' host stand-ins), and `fuzz/build.rs` reuses `rust-modules/build_support/host_link.rs`. `tools/fuzz-hud.py` is the whole workflow (`list | seed | lock | build | run`): it copies `rust-modules/Cargo.lock` to the gitignored `fuzz/Cargo.lock` (the shared crates are exactly the shipped versions), builds with the nightly named by `FUZZ_TOOLCHAIN` diff --git a/docs/module-layers.md b/docs/module-layers.md index 31ac64876e..1cdb533b0e 100644 --- a/docs/module-layers.md +++ b/docs/module-layers.md @@ -330,13 +330,13 @@ proves the references are gone and nothing more; L15b is open. | **L12** media owns its lifecycle seams — **done** | 7 / 28 | The foreground-resume machine is `player::lifecycle`, its drivers `player::foreground` and the transport-pause contract `player::transport` (`app::lifecycle` re-exports them), the stats switch is `player::DIAG_READOUT_ON`, `Venc::open` takes the capture socket writer as an argument, and `route` takes the HUD context line as a parameter, with the up-next still prefetch a hook the app installs. | | **L13** tests move up to the layer that owns their parts — **done** | 41 / 96 | Part a moved the auth, plex, i18n, task and fontcov tests that named upper layers to `app/` (`session_*_tests.rs`), `screens/login_text_fit_tests.rs`, `plex`, `auth::owner` and `storage::client`, and moved `fontcov`'s `Measure` impl beside the trait, with `ui::machine`'s new `BareArg`/`BareMeasure` fixtures for the rest; part b moved the data, media and ui ones to `app/` (`dispatch_return_tests.rs`, `overscan_audit_tests.rs`) and `screens/` (`plaintext_question`, `library/labels_tests.rs`, `search/tests.rs`, `player`), and rewrote two against their own layer. | | **L14** session-layer presentation to screens — **done** | 2 / 4 | `auth::signed_in_reason` is a private fn of `screens::login`, its only caller, with its two tests; `auth` already handed over the plain account name. | -| **L15** the webOS port — **gate-complete** | 44 / 205 | Everything outside `[platform webos]` reaches the television through the `tv` interfaces in `os` that the port fills at boot: `tv::{device, native_video, secure, home, toast}` (the window, the bus pump and the frame probe are `app::platform`'s `Shell` and `FrameProbe` since W2), `devcaps::dv`, and `tv::sink::VideoSink`, a Starfish-shaped verb trait that `plx_os::webos::video_sink::StarfishSink` and `plx_play_feed::ffi_host::HostSink` implement. `plex_run` is `port::plex_run`. The allowlist is empty. Not "done": the sink is not OS-neutral and the simulator is not its own port (L15b). | -| **L15b** the OS-neutral port — **open** | — | An OS-neutral video sink with the ACB bind sequence behind it, the simulator as its own port, and the webOS facts the gate cannot see. See below. | +| **L15** the webOS port — **gate-complete** | 44 / 205 | Everything outside `[platform webos]` reaches the television through the `tv` interfaces in `os` that the port fills at boot: `tv::{device, native_video, secure, home, toast}` (the window, the bus pump and the frame probe are `app::platform`'s `Shell` and `FrameProbe` since W2), `devcaps::dv`, and `tv::sink::VideoSink`, a Starfish-shaped verb trait that `plx_os::webos::video_sink::StarfishSink` and `plx_play_feed::ffi_host::HostSink` implement. `plex_run` is `port::plex_run`. The allowlist is empty. Not "done": the sink is not OS-neutral (L15b). | +| **L15b** the OS-neutral port — **open** | — | An OS-neutral video sink with the ACB bind sequence behind it and the webOS facts the gate cannot see; the simulator became its own platform in W4. See below. | | **L15c** the platform value and the three contracts — **done** | — | Wave R (the rename that gave this page `os` and `[platform webos]`) landed as #1474; W2 landed (`tv::Port` became `tv::Services`, with four groups of hooks; the shell and the frame probes moved to `app::Platform`), and so did the three contracts, W3a to W3c: who may persist credentials (#1477), what evidence admits a URI player (#1478), who ends the process (#1479). See "L15c to L15h" below. | -| **L15d** neutral types and the simulator as its own platform (L15b item 2) — **W3d landed, W4 planned** | — | W3d has landed (the opaque `Backend` tag, `sandbox` to `native_video`, identity publishes a platform name and version, `device::Info` keeps its webOS fields in `WebosDetail`, and `devcaps` reads its files through the platform), and what is planned is W4 (a second fence section, `[platform desktop]`, with its own value; the simulator's host arms leave `system` and `port`, the other `hostsim` terms of the fence go, and the simulator's stand-ins in `webos` and `keymanager` stay, compiled for tests and `test-support`: `docs/platform-ports.md`, W4). The desktop platform is the second implementation. | +| **L15d** neutral types and the simulator as its own platform (L15b item 2) — **W3d and W4 landed** | — | W3d landed (the opaque `Backend` tag, `sandbox` to `native_video`, identity publishes a platform name and version, `device::Info` keeps its webOS fields in `WebosDetail`, and `devcaps` reads its files through the platform), and so did W4: `platform_desktop` (`rust-modules/src/platform_desktop.rs`, a second fence section, `[platform desktop]`) is the simulator's and the macOS app's own platform value, which `src/bin/sim.rs` enters through; the `hostsim` terms of the television's fence are gone, so the television's code is compiled into every build and the linker drops it from a desktop executable (`simulators.yml` links the macapp feature set to guard that until W7), and the stand-ins in `webos` and `keymanager` are test seams, compiled for tests and `test-support` (`docs/platform-ports.md`, W4). The desktop platform is the second implementation. | | **L15e** events, the shell and composition — **planned** | — | W5 (`HostEvent` with `Option`), W6b (platform-supplied composition in two boot phases), W6 (`plx_shell_sdl`, a `[shell_sdl]` layer) and W6c (a URI-only and a two-driver composition play an ordinary title). | | **L15f** extract the platform crates — **planned** | — | W7: a narrow public `host` module in the application crate, `rust-modules/platform-webos` and `platform-desktop` as crates above `app`, and the gate learning "a platform is a crate above `app`". After L15d, before L15g and L15h. | -| **L15g** the webOS facts and the remaining `hostsim` (L15b item 3) — **planned** | — | W8: the `target_arch = "arm"` and `target_os = "linux"` sites sorted into "is webOS" (a platform value or runner) and "is 32-bit ARM" or "is Linux" (stays), then the library name lists, `paths`, the packaging and the 363 `feature = "hostsim"` lines outside the fence (360 cfg lines and three doc comments). | +| **L15g** the webOS facts and the remaining `hostsim` (L15b item 3) — **planned** | — | W8: the `target_arch = "arm"` and `target_os = "linux"` sites sorted into "is webOS" (a platform value or runner) and "is 32-bit ARM" or "is Linux" (stays), then the library name lists, `paths`, the packaging and the `feature = "hostsim"` lines left in the tree (none of them in the fence now; `git grep -h 'feature = "hostsim"' -- '*.rs' | wc -l` counts them). | | **L15h** the OS-neutral Feed sink (L15b item 1) — **planned** | — | W11: `plx_acb` (an `[acb]` layer) takes the ACB plane owner and the URI media verbs out of `os`, the Feed-side ACB results become neutral, and the bind sequence moves behind a neutral sink. Needs the television. | ### L15: the webOS port @@ -356,8 +356,8 @@ tests, where nothing calls `plex_run`) `tv::Services::HOST_TEST` answers what th shipping build that reaches it logs `tv: port not installed - using the no-port defaults` once. Only `tv`'s own modules read the table. Two things leave it: the sink, through `tv::sink::installed()` (rule `sink` of `ci/check-deps.sh` fences naming `VideoSink` or `installed` to `media`'s -`player/`, `play-uri/`, `os`'s `tv/`, `tv.rs` and `webos/`, `port.rs` and -`app/adapters/backends.rs`; `play-feed/` may name the trait but never resolves `installed`), and the URI media pipe through +`player/`, `play-uri/`, `os`'s `tv/`, `tv.rs` and `webos/`, `port.rs`, `platform_desktop.rs` (each platform's table names its own +sink) and `app/adapters/backends.rs`; `play-feed/` may name the trait but never resolves `installed`), and the URI media pipe through `tv::uri::installed()`, resolved once by the composition (`app/adapters/backends.rs::install_uri_product`, every build with the `play-uri` feature) and, in a `devtriggers` build, again by the media wrapper `player::uriprobe_drive` for the developer probe. The independent `play-uri` driver receives that transport and a shared `DisplaySink` as injected ports; it @@ -381,10 +381,11 @@ published values rather than hooks: the webOS code writes them into `tv::device` | system toast | `tv::toast::{toast, send, Identity, Outcome, Sent}` | `app::clock_notice`, `dev::scenarios::toast_probe` | `tv` may name only `base`, `machine` and `os`. `port.rs` holds `plex_run` and the `SERVICES` and `PLATFORM` tables -that point each hook at the `webos`, `keymanager` and `system` function behind it. The C shim and -the simulator both enter through `port::plex_run`: it calls `app::run_application`, which returns +that point each hook at the `webos`, `keymanager` and `system` function behind it. The C shim +enters through `port::plex_run`: it calls `app::run_application`, which returns how the session ended as an `Exit` (a status and whether the teardown released everything), and then -ends the process with that status. `lib.rs` declares the port but re-exports nothing from it, because a re-export would +ends the process with that status. The simulator enters through `platform_desktop::run`, which hands the desktop +platform to `run_application` and returns that status; the simulator's `main` ends the process. `lib.rs` declares the port but re-exports nothing from it, because a re-export would be a reference from the crate root into the port, which the gate refuses. The video sink landed as a verb-level cut. `tv::sink::VideoSink` has one method per verb of the @@ -412,21 +413,22 @@ order or its interleaving, and its log lines are graded on the television. A ver can be graded by comparing the television's log before and after; a redesign that changes where those stages run, and when, is its own step's scope and risk. -The simulator runs the same tables. Under `hostsim` `port.rs` builds a `SERVICES` and a `PLATFORM` whose fields point -at the same `webos`, `keymanager` and `system` functions, whose `hostsim` arms answer on the host, -and whose sink is `HostSink`. So the simulator behaves as it did, but it is not yet a second -implementation of the interfaces. +The simulator does not run the television's tables. `platform_desktop.rs` states its own `SERVICES` and `PLATFORM`: the +shared `NONE` groups where a host has nothing to say, its own bodies for the capability probe, the root press and the +toast, `HostSink` as the sink, and a `Shell` and a `FrameProbe` that do nothing. `port.rs` is the webOS port only. The +desktop build still compiles the television's code, and the linker drops what nothing reaches, which `simulators.yml` +guards with a link step until the platform crates split (W7). L15 is gate-complete: no entry carries its tag, `plex_run`, which the C shim calls, lives in the port, and the gate fails on a new reference into it. That is all the gate can see. L15 also set out -to put an OS-neutral sink with the bind sequence behind it and the simulator's stand-ins in their -own port. Neither landed, so L15 is not called done. They are L15b. +to put an OS-neutral sink with the bind sequence behind it and the simulator in its own port. The +sink did not land, so L15 is not called done; it is L15b. The simulator did, in W4. ### L15b: the OS-neutral port Open. L15 made every reference to the webOS code visible and one-directional. It did not make the interfaces something another OS could implement, because the verbs and several types in them are -still webOS's. Three things are left: +still webOS's. Three things were left, and item 2 is done: 1. **An OS-neutral video sink.** A sink another OS can implement takes codec configuration and timestamped access units, and it seeks, flushes, pauses and reports events. The ACB bind @@ -434,13 +436,13 @@ still webOS's. Three things are left: `sf_on_event`/`acb_on_event` and `sink_counter_kind(ty, major)` in `player/mod.rs` move behind it, into the port. This changes where the stages and the callback decode live and when they run, so it needs the television: see the reasons above. -2. **The simulator as its own port.** `ffi_host` and the simulator's arms of `system` and `port` - become a second `Port` table, a second implementation of the same interfaces, instead of the - webOS table running its host arms. That keeps both honest. The stand-ins in `webos` and - `keymanager` do not move: the nine `any(hostsim, test, test-support)` items are what the - simulator runs today (`launch_home`, `system_locale`, `sound_output`, `bind_window`, the - keymanager client, `deliver`, `call_hbc` among them), and they stay compiled for tests and - `test-support` with only their `hostsim` term gone (`docs/platform-ports.md`, W4). The +2. **The simulator as its own platform (done, W4).** `platform_desktop` is a second implementation of the + same interfaces: it states every hook of `tv::Services` (the shared `NONE` groups where a host has + nothing to say, its own capability probe, root press, toast and sink) with a no-op `Shell` and + `FrameProbe`, and `src/bin/sim.rs` enters through it, so the webOS table no longer runs host arms. The + `hostsim` terms are gone from `system`, `port`, `webos` and `keymanager`. The stand-ins in `webos` and + `keymanager` are test seams only, `cfg(any(test, feature = "test-support"))`: a simulator run executes + none of them (`docs/platform-ports.md`, W4). The webOS-shaped types in `tv` needed neutral shapes then, and have them since W3d: `tv::secure::Backend` is an opaque tag that stays a string on the wire (the two webOS spellings are constants, and a tag no installed platform knows is refused on open), `tv::sandbox` is `tv::native_video` with a verdict that is @@ -463,13 +465,13 @@ still webOS's. Three things are left: crate (`rust-modules/storage`, an LS2 service over DB8), and the Makefile's NDK cross-build and `.ipk` packaging. -L15b is done when the sink is OS-neutral, the simulator is its own port, and these facts are the -port's. The port does not wait for all three before it leaves its layers. The order, amended 2026-11-20, is item 2 -(the simulator as its own port), then the extraction, then item 3 and item 1 ("L15c to L15h" below). Extracted, the +L15b is done when the sink is OS-neutral and these facts are the +port's (the simulator became its own platform in W4). The port does not wait for both before it leaves its layers. The +order, amended 2026-11-20, is item 2 (the simulator as its own platform, done), then the extraction, then item 3 and item 1 ("L15c to L15h" below). Extracted, the port is a crate of its own on top: it names `app` to start it, and nothing names it. `plx_platform_webos` produces the staticlib the Makefile links, and `plxnative-modules` stays the application crate beneath it. Another TV OS is another platform in that position. The simulator binary, `src/bin/sim.rs`, is already a separate crate there, -and enters through `port::plex_run` until W4 gives it its own platform value. +and enters through `platform_desktop::run`. ### L15c to L15h: the platform plan diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 75bb12169e..b384986dd9 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -11,8 +11,10 @@ # would need an `exclude`; here they cannot see it. # # WHAT IT FUZZES. The parsers of `plx_appkit` (`hud_format`), `plx_data` (`hudpacks`), `plx_net` (`ws`) and `plx_owp` (`json`), -# built in the host-simulator configuration: `hostsim`, the only one a host executable can link (the television build -# declares the LS2, glib and ACB symbols only the TV's own libraries define). The parsers have no `cfg` +# built in the host-simulator configuration: `hostsim`, which selects the host stand-ins of the layers below (the Feed +# backend's host sink, the desktop platform). The television's own LS2, glib and ACB declarations are compiled in every +# build, `hostsim` included; a host executable links only because nothing here references them and the linker drops +# them (`simulators.yml` guards that for the simulator). The parsers have no `cfg` # on that feature (`rust-modules/Cargo.toml`, "What it changes, and nothing else"), and nothing here # enables `test-support` or `devtriggers`. `fuzz/Cargo.lock` is not committed: `tools/fuzz-hud.py` copies # `rust-modules/Cargo.lock` over it before a build, so the shared crates (zip, serde_json, ...) are exactly @@ -45,7 +47,7 @@ plx_owp = { path = "../rust-modules/owp" } # The registry-index targets sign with TEST ONLY keys (`src/signing.rs`) to reach what follows the signature # check. The same version and features as `plx_data`, so the lock gains nothing. ed25519-compact = { version = "=2.6.1", default-features = false, features = ["opt_size"] } -# Named only to switch the layers below `plx_appkit` to their host stand-ins (`plx_media/hostsim` +# Named only to switch the layers below `plx_appkit` to their host configuration (`plx_media/hostsim` # forwards to every layer that has the feature); no code here calls it. plx_media = { path = "../rust-modules/media", features = ["hostsim"] } diff --git a/rust-modules/Cargo.toml b/rust-modules/Cargo.toml index 5d4f2b25ba..808cc7465f 100644 --- a/rust-modules/Cargo.toml +++ b/rust-modules/Cargo.toml @@ -174,8 +174,10 @@ placeholder-sentinel = ["plx_ui/placeholder-sentinel"] # # What it changes, and nothing else: the media seam (29 symbols that exist only on a television), # the GL context request (macOS has no GLES2 driver), the window flags, the keyboard event decode -# (LG's SDL fork shifts SDL_KeyboardEvent; stock SDL2 does not), and the wayland/glib calls that -# have no host equivalent. Everything else — all of `ui/`, the whole Plex data layer, the demux +# (LG's SDL fork shifts SDL_KeyboardEvent; stock SDL2 does not), and the desktop platform it compiles +# (`platform_desktop`, which supplies the tables the television's `port` supplies on a set; the +# television's wayland/glib code is compiled either way and is not what this feature switches). +# Everything else — all of `ui/`, the whole Plex data layer, the demux # orchestration — is compiled identically for both. hostsim = ["dep:xxhash-rust", "plx_base/hostsim", "plx_machine/hostsim", "plx_os/hostsim", "plx_gfx/hostsim", "plx_plex/hostsim", "plx_telemetry/hostsim", "plx_data/hostsim", "plx_session/hostsim", "plx_media/hostsim", "plx_play_feed?/hostsim"] diff --git a/rust-modules/os/src/webos.rs b/rust-modules/os/src/webos.rs index 2f964bcc97..88e13eb609 100644 --- a/rust-modules/os/src/webos.rs +++ b/rust-modules/os/src/webos.rs @@ -142,7 +142,8 @@ fn plex_platform(release: &str) -> Platform { } /// The files `devcaps::probe` parses, read from the file system: webOS's own paths, named by the -/// model. The simulator's host has none of them and so answers "unreadable", as it always did. +/// model. A host that is not a television has none of them and so answers "unreadable"; the simulator does not +/// read them at all, its platform states `Files::NONE`. pub const DEVICE_FILES: crate::tv::device::Files = crate::tv::device::Files { read: |path| std::fs::read_to_string(path), exists: |path| std::path::Path::new(path).exists(), @@ -214,7 +215,7 @@ fn os_release_value<'a>(s: &'a str, key: &str) -> Option<&'a str> { /// [`OS_RELEASE_FIRST_MAJOR`]: no firmware older than that writes this file, so such a text is not /// this set's own, and a major 1 to 4 would flip the decisions that read it (the credential /// default, VP9 10-bit, the DV platform gate, the old-ABI seek). The ID check is what keeps a Linux -/// host that runs the simulator from reading its distribution's `VERSION_ID` as a firmware. +/// host that runs this probe (the unit tests, a CI runner) from reading its distribution's `VERSION_ID` as a firmware. /// /// The file carries no codename, API version or build id, so those stay empty rather than invented; /// in particular [`Info::build`] stays empty, not the release, so that this boot and a nyx boot of @@ -687,7 +688,7 @@ pub fn bind_window(win: *mut std::os::raw::c_void) { pub fn bind_window(_win: *mut std::os::raw::c_void) {} /// The URI media pipe the port installs (`tv::LegacyWebosMedia::uri_media`): the explicitly enabled bus -/// worker on the television, or `NoUriMedia` in a feature-off build, simulator or test. +/// worker on the television, or `NoUriMedia` in a feature-off build or a test. /// This does not select the URI playback route. #[cfg(all(feature = "uri-transport", not(any(test, feature = "test-support"))))] pub const URI_MEDIA: &dyn crate::tv::uri::UriMedia = &ls2::uri::Transport; @@ -1409,8 +1410,8 @@ mod tests { } } - /// The probe also runs in the simulator, which installs the webOS port's table: on a Linux - /// host `/usr/lib/os-release` is the host's, and Ubuntu's `VERSION_ID` is numeric. Only a file + /// The probe also runs on a Linux host that is not a television (the unit tests, a CI runner): there + /// `/usr/lib/os-release` is the host's, and Ubuntu's `VERSION_ID` is numeric. Only a file /// that says it is webOS TV's (`ID=starfish`, on every firmware image checked from 5.5 to /// 11.2) may name a firmware. #[test] diff --git a/rust-modules/play-feed/src/ffi_host.rs b/rust-modules/play-feed/src/ffi_host.rs index f210637efc..de971b7fd4 100644 --- a/rust-modules/play-feed/src/ffi_host.rs +++ b/rust-modules/play-feed/src/ffi_host.rs @@ -61,7 +61,7 @@ //! # How it is reached //! //! The verbs below are private; [`HostSink`] is the simulator's own `tv::sink::VideoSink`, one -//! method per verb, installed by `port.rs` for the `hostsim` build (the application builds it in +//! method per verb, held by `platform_desktop.rs`'s `SERVICES` for the `hostsim` build (the application builds it in //! `app::adapters::hostsim`, with the simulator's picture) and returned directly by the media //! tests' composition (`player::test_physical`) and the application's (`app::adapters::backends`) //! in the hostsim tests. The `*_for_test` hooks stay here, next to the statics diff --git a/rust-modules/src/app/adapters/backends.rs b/rust-modules/src/app/adapters/backends.rs index 50539a74c6..d82b91c03d 100644 --- a/rust-modules/src/app/adapters/backends.rs +++ b/rust-modules/src/app/adapters/backends.rs @@ -250,7 +250,7 @@ const START_HOOKS: StartHooks = StartHooks { play_url: plx_play_feed::playurl::playurl, }; -/// The television's (and the simulator's, whose port table holds the host sink) hooks: the +/// The television's (and the simulator's, whose platform table holds the host sink) hooks: the /// installed port's sink and the Feed's own monotonic clock. #[cfg(feature = "play-feed")] const TV_HOOKS: NativeHooks = diff --git a/rust-modules/src/app/adapters/hostsim.rs b/rust-modules/src/app/adapters/hostsim.rs index 28ca7f9d5f..7ae416a40c 100644 --- a/rust-modules/src/app/adapters/hostsim.rs +++ b/rust-modules/src/app/adapters/hostsim.rs @@ -1,4 +1,4 @@ -//! The simulator's side of the playback seam: the host sink its port table holds, and the decoded +//! The simulator's side of the playback seam: the host sink the desktop platform's `SERVICES` holds, and the decoded //! picture that sink is built with. The sink itself is the Feed backend's stand-in //! (`plx_play_feed::ffi_host`); what lives here is what only the application may name, because it //! draws: `sim_video` composites the picture under the finished UI frame with `plx_gfx`. The media @@ -10,8 +10,8 @@ mod sim_video; use plx_play_feed::ffi_host::{HostSink, Hooks}; -/// The simulator's video sink, built with the simulator's decoded picture. The port table holds -/// it as `Services.legacy_webos_media.sink`; a hostsim test binary of this crate reads it directly. +/// The simulator's video sink, built with the simulator's decoded picture. The desktop platform +/// (`platform_desktop.rs`) holds it as `Services.legacy_webos_media.sink`; a hostsim test binary of this crate reads it directly. pub(crate) static HOST_SINK: HostSink = HostSink::new(Hooks::over(&sim_video::SimVideo)); /// The render thread's half of the simulator's picture, once per bound-plane frame, after the diff --git a/rust-modules/src/app/exit.rs b/rust-modules/src/app/exit.rs index 0b9ed5ec6e..a66d6f7f63 100644 --- a/rust-modules/src/app/exit.rs +++ b/rust-modules/src/app/exit.rs @@ -3,9 +3,10 @@ //! [`run_application`](super::run_application) RETURNS an [`Exit`]; it never ends the process. //! An early-boot refusal returns its code, and a played session returns after `run::shutdown` and //! the telemetry guard drop. Ending the process is the EXECUTABLE entry's: `port::plex_main` (the C -//! shim and the simulator both enter through `plex_run`, which only calls it) calls +//! shim enters through `plex_run`, which only calls it) calls //! `plx_base::process::exit_now(exit.code)` right after, in the order the app always ended in, so a -//! television behaves as before. A process that HOSTS the application never calls `exit_now` or +//! television behaves as before; the simulator's `main` calls `platform_desktop::run`, which returns the +//! code, and ends the process the same way. A process that HOSTS the application never calls `exit_now` or //! `exit`: libc's `exit` runs OpenSSL's cleanup under the detached curl workers (#1115), and a host //! would be killed under its own runtime. No exit a hosted process can reach remains in the tree: //! the graphics boot returns a [`GfxFault`](plx_gfx::gfx::GfxFault) ([`Exit::from`]) where it used From dd55f2eb742de3e6030de7bea48bf1e84603a16f Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Fri, 20 Nov 2026 14:40:00 +0300 Subject: [PATCH 4/5] Two Cargo.toml comments stay as they were, because the read-only dependency certificate pins them The previous commit reworded a comment in `rust-modules/Cargo.toml` (the `hostsim` feature) and two in `fuzz/Cargo.toml`. `ci/readonly_generated.py` reads the certificate under `ci/proofs/` and pins every `Cargo.toml`, `Cargo.lock` and `.cargo` config byte for byte, so those three comments turned `make check-python-rest` red (`check-machine-shape.py`, `test_check_machine_shape.py`, `test_transition_arguments.py`, `test_readonly_dependencies.py`). A comment is not worth a certificate review, so both files return to the bytes `main` has, and the certificate is not re-sealed. Those comments therefore still say, for now, that `hostsim` is the only configuration a host executable can link because the television build declares symbols only the television's own libraries define, and that the feature switches the wayland and glib calls. The television's arms are compiled into every build today and only the linker keeps them out. The platform crates' split changes both files and re-seals the certificate, and rewords them then. Co-Authored-By: Claude --- fuzz/Cargo.toml | 8 +++----- rust-modules/Cargo.toml | 6 ++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index b384986dd9..75bb12169e 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -11,10 +11,8 @@ # would need an `exclude`; here they cannot see it. # # WHAT IT FUZZES. The parsers of `plx_appkit` (`hud_format`), `plx_data` (`hudpacks`), `plx_net` (`ws`) and `plx_owp` (`json`), -# built in the host-simulator configuration: `hostsim`, which selects the host stand-ins of the layers below (the Feed -# backend's host sink, the desktop platform). The television's own LS2, glib and ACB declarations are compiled in every -# build, `hostsim` included; a host executable links only because nothing here references them and the linker drops -# them (`simulators.yml` guards that for the simulator). The parsers have no `cfg` +# built in the host-simulator configuration: `hostsim`, the only one a host executable can link (the television build +# declares the LS2, glib and ACB symbols only the TV's own libraries define). The parsers have no `cfg` # on that feature (`rust-modules/Cargo.toml`, "What it changes, and nothing else"), and nothing here # enables `test-support` or `devtriggers`. `fuzz/Cargo.lock` is not committed: `tools/fuzz-hud.py` copies # `rust-modules/Cargo.lock` over it before a build, so the shared crates (zip, serde_json, ...) are exactly @@ -47,7 +45,7 @@ plx_owp = { path = "../rust-modules/owp" } # The registry-index targets sign with TEST ONLY keys (`src/signing.rs`) to reach what follows the signature # check. The same version and features as `plx_data`, so the lock gains nothing. ed25519-compact = { version = "=2.6.1", default-features = false, features = ["opt_size"] } -# Named only to switch the layers below `plx_appkit` to their host configuration (`plx_media/hostsim` +# Named only to switch the layers below `plx_appkit` to their host stand-ins (`plx_media/hostsim` # forwards to every layer that has the feature); no code here calls it. plx_media = { path = "../rust-modules/media", features = ["hostsim"] } diff --git a/rust-modules/Cargo.toml b/rust-modules/Cargo.toml index 808cc7465f..5d4f2b25ba 100644 --- a/rust-modules/Cargo.toml +++ b/rust-modules/Cargo.toml @@ -174,10 +174,8 @@ placeholder-sentinel = ["plx_ui/placeholder-sentinel"] # # What it changes, and nothing else: the media seam (29 symbols that exist only on a television), # the GL context request (macOS has no GLES2 driver), the window flags, the keyboard event decode -# (LG's SDL fork shifts SDL_KeyboardEvent; stock SDL2 does not), and the desktop platform it compiles -# (`platform_desktop`, which supplies the tables the television's `port` supplies on a set; the -# television's wayland/glib code is compiled either way and is not what this feature switches). -# Everything else — all of `ui/`, the whole Plex data layer, the demux +# (LG's SDL fork shifts SDL_KeyboardEvent; stock SDL2 does not), and the wayland/glib calls that +# have no host equivalent. Everything else — all of `ui/`, the whole Plex data layer, the demux # orchestration — is compiled identically for both. hostsim = ["dep:xxhash-rust", "plx_base/hostsim", "plx_machine/hostsim", "plx_os/hostsim", "plx_gfx/hostsim", "plx_plex/hostsim", "plx_telemetry/hostsim", "plx_data/hostsim", "plx_session/hostsim", "plx_media/hostsim", "plx_play_feed?/hostsim"] From 71c55cff169c6f71caa7cb854092955709c8d345 Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Fri, 20 Nov 2026 15:02:22 +0300 Subject: [PATCH 5/5] The prose the review found still naming the television's entry and the old `hostsim` arms now names both entries `app/mod.rs` (the module doc and two comments) and `app/boot.rs` said the entry that ends the process is `port::plex_run`. That is the television's; the desktop executable ends it in `src/bin/sim.rs` after `platform_desktop::run`, and each of those lines now names both. `Services::HOST_TEST`'s comment in `os/src/tv.rs` called the arm it replaced `cfg(any(hostsim, test))`; the arm is `cfg(any(test, feature = "test-support"))`. `fuzz/Cargo.toml` is not a member of the certified workspace, so its two comments get the wording the last commit gave them before the certificate forced it back: `hostsim` selects the host configuration of the layers below, the television's declarations are compiled in every build, and the linker keeps them out of a host executable. The fuzz package does not depend on `plxnative-modules`, so it no longer lists the desktop platform among what `hostsim` selects. `ci/test_readonly_dependencies.py` and `ci/test_readonly_generated.py` pass with the edit. `rust-modules/Cargo.toml`'s comment on `hostsim` stays as it is, because the certificate pins that file; `docs/module-layers.md` says in the L15b item 2 paragraph what `hostsim` selects now, that the television's wayland and glib calls are compiled either way and dropped by the linker, and that W7 rewords the comment when it re-seals. Co-Authored-By: Claude --- docs/module-layers.md | 7 ++++++- fuzz/Cargo.toml | 8 +++++--- rust-modules/os/src/tv.rs | 2 +- rust-modules/src/app/boot.rs | 5 +++-- rust-modules/src/app/mod.rs | 9 ++++++--- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/docs/module-layers.md b/docs/module-layers.md index 1cdb533b0e..06df7a3e28 100644 --- a/docs/module-layers.md +++ b/docs/module-layers.md @@ -442,7 +442,12 @@ still webOS's. Three things were left, and item 2 is done: `FrameProbe`, and `src/bin/sim.rs` enters through it, so the webOS table no longer runs host arms. The `hostsim` terms are gone from `system`, `port`, `webos` and `keymanager`. The stand-ins in `webos` and `keymanager` are test seams only, `cfg(any(test, feature = "test-support"))`: a simulator run executes - none of them (`docs/platform-ports.md`, W4). The + none of them (`docs/platform-ports.md`, W4). `hostsim` no longer selects a platform: it selects the + host build of what is not one (the media seam's host sink, the GL context request, the window flags + and the keyboard event decode), while the television's wayland and glib calls, like the rest of the + television's arms, are compiled in every build and the linker drops them from a host executable. + The comment on the feature in `rust-modules/Cargo.toml` still lists those calls under what it + switches; the certificate pins that file, so W7 rewords it when it re-seals. The webOS-shaped types in `tv` needed neutral shapes then, and have them since W3d: `tv::secure::Backend` is an opaque tag that stays a string on the wire (the two webOS spellings are constants, and a tag no installed platform knows is refused on open), `tv::sandbox` is `tv::native_video` with a verdict that is diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 75bb12169e..ddbe87d1ee 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -11,8 +11,10 @@ # would need an `exclude`; here they cannot see it. # # WHAT IT FUZZES. The parsers of `plx_appkit` (`hud_format`), `plx_data` (`hudpacks`), `plx_net` (`ws`) and `plx_owp` (`json`), -# built in the host-simulator configuration: `hostsim`, the only one a host executable can link (the television build -# declares the LS2, glib and ACB symbols only the TV's own libraries define). The parsers have no `cfg` +# built in the host-simulator configuration: `hostsim`, which selects the host configuration of the layers below. The +# television's own LS2, glib and ACB declarations are compiled in every build, `hostsim` included; a host executable +# links only because nothing here references them and the linker drops them (`simulators.yml` guards that for the +# simulator). The parsers have no `cfg` # on that feature (`rust-modules/Cargo.toml`, "What it changes, and nothing else"), and nothing here # enables `test-support` or `devtriggers`. `fuzz/Cargo.lock` is not committed: `tools/fuzz-hud.py` copies # `rust-modules/Cargo.lock` over it before a build, so the shared crates (zip, serde_json, ...) are exactly @@ -45,7 +47,7 @@ plx_owp = { path = "../rust-modules/owp" } # The registry-index targets sign with TEST ONLY keys (`src/signing.rs`) to reach what follows the signature # check. The same version and features as `plx_data`, so the lock gains nothing. ed25519-compact = { version = "=2.6.1", default-features = false, features = ["opt_size"] } -# Named only to switch the layers below `plx_appkit` to their host stand-ins (`plx_media/hostsim` +# Named only to switch the layers below `plx_appkit` to their host configuration (`plx_media/hostsim` # forwards to every layer that has the feature); no code here calls it. plx_media = { path = "../rust-modules/media", features = ["hostsim"] } diff --git a/rust-modules/os/src/tv.rs b/rust-modules/os/src/tv.rs index 752c3bc93c..4d372c7798 100644 --- a/rust-modules/os/src/tv.rs +++ b/rust-modules/os/src/tv.rs @@ -111,7 +111,7 @@ impl LegacyWebosMedia { impl Services { /// No platform installed: host unit tests (nothing installs one). Every entry is what today's - /// `cfg(any(hostsim, test))` arm answered, minus the off-device log lines the other entries would + /// `cfg(any(test, feature = "test-support"))` arm answered, minus the off-device log lines the other entries would /// write (`deliver_toast` keeps its one). pub const HOST_TEST: Self = Self { identity: IdentityHooks::NONE, diff --git a/rust-modules/src/app/boot.rs b/rust-modules/src/app/boot.rs index 21acced293..1645c2d47d 100644 --- a/rust-modules/src/app/boot.rs +++ b/rust-modules/src/app/boot.rs @@ -1373,8 +1373,9 @@ pub(super) fn install_pms_owned( /// Everything before the loop: SDL and the window, GL, text, the poster workers, the boot gate /// (login / token / session / picker), every dev trigger read once, and the `App` literal — /// `plex_run`'s former body up to `while app.running`, moved verbatim in phase 1b-ii. An early -/// refusal returns its `Exit` (the entry ends the process with its code, `port::plex_run`; a hosted -/// entry reports it and stays alive). +/// refusal returns its `Exit` (the entry ends the process with its code: `port::plex_run` on the +/// television, `src/bin/sim.rs` after `platform_desktop::run` on a desktop; a hosted entry reports it +/// and stays alive). /// /// `mt`, THE main-thread token, is minted once by `plex_run` itself (`plx_base::task::MainThread:: /// assume()` — that function IS the SDL main thread) and MOVES into `App.adapters.player` here, diff --git a/rust-modules/src/app/mod.rs b/rust-modules/src/app/mod.rs index e6966f1e4c..b2381fc11e 100644 --- a/rust-modules/src/app/mod.rs +++ b/rust-modules/src/app/mod.rs @@ -3,7 +3,8 @@ //! the buffer-feed pump orchestration, and the dev triggers. The C boot shim //! (main.c) sets up the log and fallback crash tracer, calls the Rust image-marker and native-spool //! entries when required, then calls `plex_run` (port.rs), which hands over to `run_application` -//! and, when it returns its `Exit` (`exit.rs`), ends the process. +//! and, when it returns its `Exit` (`exit.rs`), ends the process. The desktop executable +//! (`src/bin/sim.rs`) enters through `platform_desktop::run` instead and ends the process itself. //! The only application subsystems left in C are the starfish.c C++ Feed seam and the video_plane.c //! ACB / exported-window display binding (the engine itself is Rust: plx_media::player). #![allow(non_upper_case_globals)] @@ -574,7 +575,8 @@ fn pre_boot_diagnostics() -> plx_telemetry::telemetry::native::Guard { /// reason as [`pre_boot_diagnostics`] (D4): `run_application` stays a ten-line skeleton naming only /// the THREE real phases (pre-boot diagnostics, `boot`, this), never the steps inside any one of them. /// -/// It RETURNS how the session ended; ending the process is the executable entry's (`port::plex_run`). +/// It RETURNS how the session ended; ending the process is the executable entry's (`port::plex_run` on +/// the television, `src/bin/sim.rs` after `platform_desktop::run` on a desktop). /// The `App` is leaked by the caller (`exit::entry`), so the last thing this does is the one `Drop` /// that persists something. unsafe fn run_and_shutdown(app: &mut App) -> Exit { @@ -661,7 +663,8 @@ fn enter_application(platform: &'static platform::Platform, pms_host: *const c_c pub(crate) fn run_application(platform: &'static platform::Platform, pms_host: *const c_char, pms_port: c_int) -> Exit { // Returns how it ended and drops nothing: an early-boot refusal has live workers (diagnostics, // capability probe, telemetry) just as a played session does, so `exit::entry` leaks the `App`. - // Ending the process is the entry's (`port::plex_run`); a hosted entry never does. + // Ending the process is the entry's (`port::plex_run` on the television, `src/bin/sim.rs` after + // `platform_desktop::run` on a desktop); a hosted entry never does. platform.install_services(); // once, before anything below reads `tv` exit::entry(|| enter_application(platform, pms_host, pms_port), |app| unsafe { run_and_shutdown(app) }) }