Repository navigation
libobs: Port the hotkey binding press count to obs-hotkey (#1836) - #3075
Conversation
|
Coordinator: pushed |
11fce9f to
96de425
Compare
|
Worker tick: rebased Conflicts were all registry-style and are resolved by keeping master's text plus this unit:
The coordinator's |
96de425 to
8b7766b
Compare
|
Worker tick: rebased |
zackees
left a comment
There was a problem hiding this comment.
Coordinator review: no defects found. press/release match obs-hotkey-binding-press.c.h (flag set, count checked before the increment on press and after the decrement on release, dispatch last), with null and i32-overflow handled where C is UB. RED (6de87e3) then GREEN (a83937d) is visible. Tier 3 parity runs against the new oracle and Tier 2 via test_hotkey_press_state. No C tests or public headers changed, and the tests are in the existing hotkey binary. The Test cost line is present, and it's an internal port, so no ledger line is needed.
…t port RED for the port of libobs/obs-hotkey-binding-press.c.h to a new module, binding_press, of rust/obs-hotkey. The safe core is a stub (todo!()): press and release take the binding's pressed flag and its hotkey's pressed count by reference, write them and return whether the caller dispatches the hotkey event now (the count was 0 before a press, or reaches 0 after a release). tests/hotkey/binding_press.rs ports the 5 cases of the C characterization test_hotkey_binding_press_steps 1:1, under the same names and with the same steps and expectations: every_step (2 flag states x 6 counts x press or release, run once per routing state, since routing only decides whether a call happens at all), writes_before_the_return, two_bindings, release_without_press and wraps_at_the_edges, plus a proptest of the count invariant over random event sequences. The Tier 3 parity test (tests/hotkey/binding_press_parity.rs) compares the shims with the original C (oracle/hotkey_binding_press.c) on fake bindings, logging every accessor call and every dispatch with the flag and count it sees: the C test's whole table, two bindings of one hotkey, sequences from a pressed state, the intentional null differences, and random runs. soldr cargo test -p obs-data --test obs-tests-core hotkey::binding_press fails with "not yet implemented". Refs #1836
Ports libobs/obs-hotkey-binding-press.c.h to the binding_press module of rust/obs-hotkey: the press count that turns each binding's press and release into hotkey events, so a hotkey's callback runs on the first press and the last release only and a hotkey held through two bindings fires once. The hotkey thread's poll, obs_hotkey_inject_event() and remove_bindings() stay C in obs-hotkey.c.h and call the wrappers inside libobs, so the bindings array, its walk, the mutex and the callback stay C; the hybrid libobs drops the C file and links the Rust shims in its place. Safe core (src/binding_press.rs): press and release work on the flag and the count by reference and return whether to dispatch, so they keep no state, take no lock and never see a pointer. The press tests the count before incrementing it and the release after decrementing it, as the C does, so a press of a pressed binding counts again and a release at count 0 goes negative (characterized, not endorsed: libobs presses only a released binding and releases only a pressed one). The count is C's int and wraps at the edges of i32, where C is undefined; libobs never reaches them. Shim (src/ffi/binding_press.rs): obs_hotkey_binding_press and obs_hotkey_binding_release keep the C signature and are hidden (declared in obs-internal.h without EXPORT). They take the binding's flag, its hotkey's count and the hotkey once through the hidden obs_hotkey_binding_count_fields() (#1836, so neither struct is mirrored) and write the flag and the count through those pointers, never through a copy; the dispatch is obs_hotkey_dispatch(), last and only when the core says so, and the binding is not touched after it, since a callback may rebind or unregister hotkeys. A null binding or a null accessor field does nothing (C dereferences it). C side: the file leaves libobs.core for its own group, libobs.ported-hotkey-binding-press (LIBOBS_PORTED_SOURCES), whose PCH is obs-internal.h. The two wrappers are not EXPORT, so the shims are hidden in rust-hidden.txt, the local: list of rust-exports.map and rust-unexports-macos.txt. test_hotkey_load, test_wayland_hotkeys, test_portal_shortcuts, test_hotkey_press_steps and test_hotkey_pair_steps still compile the C file into themselves; test_hotkey_press_state sees the swap through the public hotkey API. ci/test_ported_sources.py checks the group on every host. Because the wrappers are Rust now, the press state machine's oracle (oracle/hotkey_press.c) calls oracle_seam_* stand-ins instead of the real symbols, and press_parity drives them through the ported shim so the same log is compared on both sides. Tier 3 compares the call log (accessor calls; dispatches with the hotkey, the pressed value and the flag and count they see) and the flag of every binding and the count of every hotkey after every step, over every flag and count state, two bindings of one hotkey, every sequence of four events and random sequences. Fixes #1836
8b7766b to
81a5593
Compare
|
Coordinator: the merge-group ejection was |
…ows keys link #3078's test_windows_keys_steps_rust stubbed obs_hotkey_binding_press and _release, which were C seams. With this port they come from the Rust staticlib (duplicate definitions), whose shims now call obs_hotkey_binding_count_fields and obs_hotkey_dispatch (undefined). Stub those two instead.
|
Coordinator: Tier 2 Linux (build) and asan failed to link |
…#3103) edge_downmix_model ran 4000 full-size cases unscaled and hit nextest's 30 s limit on master b083524 (run 41121995484) and in the merge queue for obs-rust#3075 and obs-rust#3093. Route the block through obs_c_oracle::parity::cases() like the other proptest modules, so PR, queue and master runs take the reduced count (obs-rust#2593); local, nightly and release runs keep 4000.
obs-rust#3112) (obs-rust#3113) * test(ci): fail when a bench stand-in is also a workspace export (obs-rust#3112) The port_comparison bench defines stand-ins for libobs functions the C oracle objects call by name. Once a port ships the real #[no_mangle] shim, the bench binary holds two definitions and neither rust-lld nor lld-link will link it (obs-rust#3075 did that to obs_hotkey_binding_press and _release, and the bench has been unbuildable since). No bench build runs in PR CI, so nothing caught it. Red: this test fails on master for those two names. * perf(bench): drop the stand-ins obs-hotkey now exports (obs-rust#3112) obs_hotkey_binding_press() and obs_hotkey_binding_release() are real #[no_mangle] shims in obs-hotkey since obs-rust#3075, so the bench's stand-ins for them are duplicate definitions and the bench binary would not link: rust-lld reports 'duplicate symbol' on Linux/macOS and lld-link fails the same way on Windows. Green: the bench links again (soldr cargo bench --no-run) and the new test passes. record.py --category format completes once more, which is what obs-rust#3111's before/after numbers need.
Ports
libobs/obs-hotkey-binding-press.c.htobinding_pressinrust/obs-hotkey(part 2 of #1836; PR 1, the characterization, extraction and seam, was #3032 and is merged).RED
6de87e34c— the two new test modules and the port's wirings, against atodo!()core.GREEN
a83937d1e— the safe core (press,release), the hidden shims, the oracle and the C group move.tests/hotkey/binding_press.rsports the 5 cases oftest_hotkey_binding_press_steps1:1 (every_stepin all three routing states,writes_before_the_return,two_bindings,release_without_press,wraps_at_the_edges) plus a proptest of the count invariant.12 passed.tests/hotkey/binding_press_parity.rscompares the shims with the original C (oracle/hotkey_binding_press.c) on fake bindings, logging every accessor call and every dispatch with the flag and count it sees: the C test's whole table, two bindings of one hotkey, sequences from a pressed state, the intentional null differences and random runs.6 passed.test_hotkey_press_statesees the swap through a real libobs (CI's Tier 2 lane);test_hotkey_press_steps,test_hotkey_pair_steps,test_hotkey_load,test_wayland_hotkeysandtest_portal_shortcutsstill compile the C file into themselves.The shims take the flag, the count and the hotkey once through the hidden
obs_hotkey_binding_count_fields()(#1836) and write through those pointers, never a copy;obs_hotkey_dispatch()is last and only when the core says so, and the binding is not touched after it. The press count uses C'sintsemantics (wrap at the edges ofi32, where C is undefined).Because the wrappers are Rust now, the press state machine's oracle calls
oracle_seam_*stand-ins instead of the real symbols, andpress_paritydrives them through the ported shim so both sides log the same thing.Test cost
New tests: longest 0.37 s (
binding_press_parity::random_runs_match_c, over 25 runs of the binary), peak RSS 19.6 MB over 25 runs, no own threads../lint: every lane passes excepttest_check_changes.py, which cannot shell out togitin this checkout (cludshim), an environment artifact and not this change.test_build_groups.py,test_ported_sources.py,test_registration.pypass;soldr cargo clippy -p obs-hotkey -p obs-c-oracle --all-targetsis clean.Fixes #1836