Repository navigation
Lifecycle and quit reach the loop as a HostEvent - #1484
Merged
Merged
Conversation
…by the SDL drain (W5a) Quit and the four lifecycle edges (WILL and DID enter background, WILL and DID enter foreground) used to be read from SDL's event type inside one long ladder in ingest_sdl_event_with_window. They now arrive as an app-private HostEvent (HostEvent::Quit, HostEvent::Lifecycle(WillBackground | DidBackground | WillForeground | DidForeground), in app/events.rs): the SDL decoder (decode_host_event, beside decode_key) maps SDL_QUIT and 0x103..0x106 to it, and one function in the loop, run::ingest_host_event, consumes it. A hosted stop is the same HostEvent::Quit an SDL_QUIT decodes to and takes the same path; no C ABI is added (plx_host_post and plx_host_stop are W9's). Nothing changes on webOS or in the simulator. The effects are the arms they were, moved verbatim into host_background and host_foreground and run in the same order: the window gate, telemetry's crash steps and session, the controlled-replay refusal, the damage note, the tape record, the park and resume of the tree and playback, restore_window on DID foreground. The SDL-coded readers (window activity, telemetry, and the tape, whose recorded codes are the format) are fed Lifecycle::sdl_code(), the inverse of the decode table, so enc_lifecycle writes the same code for each edge and every recorded tape replays as before. Key, text, pointer and wheel events keep their raw path in ingest_sdl_event_with_window (W5b and W5c move them). Tests: the decode table both ways and the raw events that must stay raw (events.rs); the four edges recorded as the literal records an earlier build wrote (recorder.rs); and, on the hostsim rig, the same events delivered as SDL bytes and as a HostEvent leave the same loop, the same crash steps, the same tape and the same inputs to Exit::played, for Quit on a bare app, during playback and in a controlled replay, and for a park and resume of a playing film. The source pin in plx_ui's fixture follows the two arms to their new functions. Co-Authored-By: Claude <noreply@anthropic.com>
…t_foreground in the window prose (W5a)
Review of the HostEvent change found that nothing tied a single edge to its arm. An
`ingest_host_event` arm narrowed to `Lifecycle::DidBackground => host_background(..)`, with
`WillBackground` falling to `{}`, would have passed every test: the plx_ui pin found only the two
function definitions, the sequence test reads its values after the DID edges (which repeat what
WILL did), and every other test sends WILL and DID as a pair.
`a_host_will_edge_does_its_arms_work_without_its_did_edge` sends WILL background alone to a
playing film, then WILL foreground alone, delivering each both as SDL bytes and as a HostEvent
and comparing what the loop leaves. WILL background alone parks the film, suspends the tree and
queues the keyboard dismissal; WILL foreground alone resumes the tree but leaves the film parked
and the window unpresented, since only the DID edge restores them. The plx_ui source pin also
now follows the consumer's dispatch (both edges of each pair reach their function), bounded to
that function.
telemetry's window.rs doc comments on its `background` and `foreground` fixtures named "the
run.rs background/foreground arm"; they now name `host_background` and `host_foreground` in
`app/run.rs`.
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step W5a of the platform plan (discussion #1460), the first step of the event contract. Lifecycle and quit reach the loop as an app-private
HostEventinstead of raw SDL codes. On Tizen the same function will receive the hosted stop asHostEvent::Quit. No behaviour change on webOS or the simulator.What changes
app/events.rsgainspub(crate) enum HostEvent { Lifecycle(Lifecycle), Quit }andLifecycle { WillBackground, DidBackground, WillForeground, DidForeground }, besidedecode_key, plusdecode_host_event(&[u8]) -> Option<HostEvent>:0x100(SDL_QUIT)Quit0x103Lifecycle(WillBackground)0x104Lifecycle(DidBackground)0x105Lifecycle(WillForeground)0x106Lifecycle(DidForeground)None: the raw path, unchangedapp/run.rs: the drain decodes first. AHostEventgoes to one consumer,ingest_host_event, which runshost_backgroundfor both background edges andhost_foregroundfor both foreground edges, and handlesQuit. Every effect runs in the same order as before: telemetry,restore_windowon0x106, the park and resume of playback, the quit path, the recorder. Keys, text, pointer and wheel keep today's raw path; they are W5b and W5c.ingest_sdl_event_with_windowkeeps its name and signature, becauseci/list-caps.inikeys an entry on it.The recorder tape stays the SDL code.
Lifecycle::sdl_code()feedsenc_lifecycleand the other SDL-coded sinks (window activity, telemetry), so recordings are byte-equal.ui/src/fixture.rs: the source pinan_app_switch_suspends_every_body_and_the_loop_is_what_delivers_itused to look for the literalet == 0x103 || et == 0x104. It now findshost_backgroundandhost_foreground, bounded to each function's body, and asserts the same things. It also pinsingest_host_event's two dispatch arms: both edges of each pair reach their function.No C ABI is added (the hosted entry is W9). No new process global, no ledger line, and the fnlen budgets are untouched.
Tests
New:
events.rs: the decode table, the lifecycle round-trip throughsdl_code, and every other event staying on the raw path.recorder.rs: a lifecycle edge is recorded as the SDL code it arrived as, for all four variants.run.rslifecycle_regression_tests, which feed each event both ways (SDL bytes, and aHostEventhanded toingest_host_event) and compare what the loop leaves:Quittakes an SDL_QUIT's path, also during playback and during a controlled replay;0x103-0x106in order, and a quit is not recorded.Bounded runs on the committed tree (efad77e):
make test-crate C=app T=recorder:test result: ok. 55 passed; 0 failed; 0 ignored; 0 measured; 1435 filtered out.make test-hostsim, whole suite. Two existing tests SIGSEGV on this Mac in the system libGL with no GL context:player_owner_events_record_and_replay_through_the_actual_app_host, andan_unregistered_product_screen_uses_generic_navigation_and_actual_store_effects, which also crashes onmain. With both skipped, the built binary givestest result: ok. 1725 passed; 0 failed; 0 ignored; 0 measured; 2 filtered outin three runs.deeplink_route_tests::a_play_landing_waits_for_an_abandoning_previewand…_behind_a_preview_that_never_returns_gives_up. Both read the process-globalplx_media::route::play_pending()withouttestlock::serial(), so they race under load. That is code this PR does not touch, and both passed on the rerun.ci/check-deps.sh,ci/check-module-layers.pyandci/check-ledger-ratchet.py: green.On the review-fix head 5d68d8e (committed, clean tree):
make test-hostsim T=a_host_:test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 1721 filtered out.lifecycle_regression_tests, with the known SIGSEGV test skipped:test result: ok. 171 passed; 0 failed; 0 ignored; 0 measured; 1557 filtered out.make test-crate C=plx_ui T=an_app_switch_suspends:test result: ok. 1 passed; 0 failed.make test-crate C=plx_telemetry T=window:test result: ok. 13 passed; 0 failed; 1 ignored.ci/check-deps.sh,ci/check-module-layers.pyandci/check-ledger-ratchet.py: green.Not run here:
make check,check-nodefand the ARM cross-build. This PR's own CI gates them.🤖 Generated with Claude Code