Repository navigation
rust: Port libobs/util/platform-nix.c to obs-util - #403
Conversation
|
Checked on Linux. Your gate stamp is from darwin-arm64, and Linux hits three problems macOS doesn't:
I have 1 and 2 as commits locally and can push them if you want, but 3 is your call. |
|
Went ahead and took all three. Pushed 0fdcc8b. Don't push your local copies of 1 and 2; this commit has them. dstr_catf in the platform-nix oracle is now oracle_dstr_catf. I ran the tests in the tier2 Ubuntu image (arm64). platform_nix is 15/15, platform_nix_layout 4/4, platform_nix_parity 7/7, including the host path that calls dstr_catf. The u64 casts in free_disk_space, sys_free, and sys_total stay, with allows. On this machine f_frsize, f_bavail, freeram, bufferram, and totalram are 8 bytes, and clippy did not flag those lines. mem_unit is still 4. The macOS gate does not compile that module. This container is arm64. The GitHub runner is x86_64, so that job is still the one that sees the original lint. arm64 clippy also flags older casts in dstr.rs, because char is unsigned there. I left those alone. For the clock, the scripted one in the profiler oracle is oracle_profiler_gettime_ns. The Rust profiler has its own test clock, and profiler_parity feeds both the same timestamps (3/3). audio_io and audio_io_parity linked with rust-lld and passed, 6 and 14. macOS and Windows cargo tests get a zero os_gettime_ns stub, since cocoa is not linked and the Unix shim is not built there. The ubuntu rust-test job also died on uuid/uuid.h before the tests ran. I added uuid-dev to that job. The tier2 image already has the header. soldr 0.9.31's bundled lld would not start in that image (libxml2.so.2, then libicuuc.so.74). The run used the image's rustc 1.98.1 and rustup's rust-lld. |
Tier 1 ports of the test_platform cases that hit util/platform-nix.c. The core is still todo!(). soldr cargo test -p obs-util --test platform_nix fails 9 tests: test_file_exists, test_unlink_missing_fails, test_mkdir_success_then_exists, test_mkdir_missing_parent_is_error, test_rename, test_safe_replace_with_backup, test_safe_replace_without_backup, test_opendir_readdir_closedir, test_get_abs_path_ptr_dot.
Safe core in platform::unix::nix, C shims for every symbol this file defines, and Tier 3 parity for the filesystem calls. ENABLE_RUST_LIBOBS drops util/platform-nix.c on macOS, Linux, and FreeBSD. platform-nix-dbus.c and platform-nix-portal.c stay C.
get_plugin_info is not a libobs export. The shim was, so the
Tier 2 OFF/ON symbol diff failed.
The audio and file-serializer oracles still defined
os_sleepto_ns_fast and os_safe_replace. macOS ld warns and
GNU ld rejects that. Those copies now use private names.
Local-Gate: v1 tree=66ecb2351e971af6ea4f4dd214ae0dfa5e3d0a24 secs=99 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791830479,"gate":"rust/all/fmt","host":"darwin-arm64","key":"2c582ad80bc3466a5fb27d40e33e02143bd68871078047d891ef7a403fded382","lane":"lint","parents":["6826a120c5b18d487414aff5182ec2c6a8c7feb8"],"secs":36,"stamp":"1cb7d6bd98b94dc97712aac8e1ee587f","tree":"66ecb2351e971af6ea4f4dd214ae0dfa5e3d0a24","v":1,"via":"run"}
Ci-Attestation: {"at":1791830479,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"darwin-arm64","key":"2c582ad80bc3466a5fb27d40e33e02143bd68871078047d891ef7a403fded382","lane":"lint","parents":["6826a120c5b18d487414aff5182ec2c6a8c7feb8"],"secs":36,"stamp":"a2df6d42c4e184a59c37a97533b595f2","tree":"66ecb2351e971af6ea4f4dd214ae0dfa5e3d0a24","v":1,"via":"run"}
Ci-Attestation: {"at":1791830479,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"darwin-arm64","key":"0c42c36bfa25cb98e6266df11c8d0cf9438f73613b444eec8cfd9e3c114b792f","lane":"rust-test","parents":["6826a120c5b18d487414aff5182ec2c6a8c7feb8"],"secs":21,"stamp":"8d3dd39df29be3d073a372494ce24e45","tree":"66ecb2351e971af6ea4f4dd214ae0dfa5e3d0a24","v":1,"via":"run"}
Ci-Attestation: {"at":1791830479,"gate":"cpp/linux-x64/tier2","host":"darwin-arm64","key":"d7a1d99bb3f3e20f2fd309905824ef8040f603a81233183b325c2a93497e7af1","lane":"tier2-linux","parents":["6826a120c5b18d487414aff5182ec2c6a8c7feb8"],"secs":42,"stamp":"cde49838338af7f02b6058a3b55fa4e7","tree":"66ecb2351e971af6ea4f4dd214ae0dfa5e3d0a24","v":1,"via":"run"}
The profiler oracle's scripted os_gettime_ns collided with the new
Unix shim. That clock is now oracle_profiler_gettime_ns, and the
Rust profiler reads a test clock the parity harness arms.
macOS and Windows cargo tests get a zero os_gettime_ns stub. Cocoa
is not linked there, and the Unix shim is not built.
Also define dstr_catf to oracle_dstr_catf in the platform-nix oracle,
allow the 64-bit Linux u64 casts that 32-bit and the BSDs still need,
and install uuid-dev for the Linux rust-test job.
Local-Gate: v1 tree=5e92a518c5c030ba85baeb655c86ec707650e1a0 secs=175 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791837539,"gate":"rust/all/fmt","host":"linux-x86_64","key":"7af705eff412404b50caee976fa631e8111c8217e7fa43c7fd2bc5fb71086085","lane":"lint","parents":["c6dd79c8654a995334f45943f64a044ddbcd15bf"],"secs":56,"stamp":"4bdd4ff97f851495e06c41466cac5244","tree":"5e92a518c5c030ba85baeb655c86ec707650e1a0","v":1,"via":"run"}
Ci-Attestation: {"at":1791837539,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"7af705eff412404b50caee976fa631e8111c8217e7fa43c7fd2bc5fb71086085","lane":"lint","parents":["c6dd79c8654a995334f45943f64a044ddbcd15bf"],"secs":56,"stamp":"f39923ceebc3689b5ce80154ade5d3e7","tree":"5e92a518c5c030ba85baeb655c86ec707650e1a0","v":1,"via":"run"}
Ci-Attestation: {"at":1791837539,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"092b9a16e358e4a70a9722ceebb2d86c63e35e2319800918c8892afe97d819ab","lane":"rust-test","parents":["c6dd79c8654a995334f45943f64a044ddbcd15bf"],"secs":53,"stamp":"427a3131f0c86292e1517052b8a866cc","tree":"5e92a518c5c030ba85baeb655c86ec707650e1a0","v":1,"via":"run"}
Ci-Attestation: {"at":1791837539,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"5d47d22b6c845a12f0e2c4e80c7ee0a576ea9940ddefc39a2524d8b1a8fa98be","lane":"tier2-linux","parents":["c6dd79c8654a995334f45943f64a044ddbcd15bf"],"secs":66,"stamp":"c050852e22d72dba25237d23bf2130af","tree":"5e92a518c5c030ba85baeb655c86ec707650e1a0","v":1,"via":"run"}
|
Thanks, verified 0fdcc8b on x86_64 Linux (zccache bypassed):
One non-blocking note: |
0fdcc8b to
6d8ef13
Compare
profile_start and profile_end call now_ns on every sample. The test
clock mutex was taken just to see that no test had armed it. A relaxed
atomic is the idle check, and the mutex is taken only while a test
clock is set.
Local-Gate: v1 tree=63516168b2f5350e0080bd2f5f55b792658d782e secs=104 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791838079,"gate":"rust/all/fmt","host":"darwin-arm64","key":"86e2e3a784a5cff96ac243b4b61219bfaf55f130360af730d6ba639bfb2ecc16","lane":"lint","parents":["6d8ef134bd112a3bfcd2b83394ea7e06ab74cd46"],"secs":35,"stamp":"128bb58cf8e9b6ccdb85a0112075deec","tree":"63516168b2f5350e0080bd2f5f55b792658d782e","v":1,"via":"run"}
Ci-Attestation: {"at":1791838079,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"darwin-arm64","key":"86e2e3a784a5cff96ac243b4b61219bfaf55f130360af730d6ba639bfb2ecc16","lane":"lint","parents":["6d8ef134bd112a3bfcd2b83394ea7e06ab74cd46"],"secs":35,"stamp":"693d4c5f6d209f4e56f745f6f801ea1d","tree":"63516168b2f5350e0080bd2f5f55b792658d782e","v":1,"via":"run"}
Ci-Attestation: {"at":1791838079,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"darwin-arm64","key":"8ff077a810c706d62126c4e131d910387abf1993e673f638ca303da09cb4fc65","lane":"rust-test","parents":["6d8ef134bd112a3bfcd2b83394ea7e06ab74cd46"],"secs":22,"stamp":"a34bc418b97c14285c7c5e7d269ff57b","tree":"63516168b2f5350e0080bd2f5f55b792658d782e","v":1,"via":"run"}
Ci-Attestation: {"at":1791838079,"gate":"cpp/linux-x64/tier2","host":"darwin-arm64","key":"cdd38301a1cb754061d87301074e31351aa6fb1f4e5d4f8ea1076e05904d2f42","lane":"tier2-linux","parents":["6d8ef134bd112a3bfcd2b83394ea7e06ab74cd46"],"secs":46,"stamp":"faa78990ebef10966f5bae611aed3bba","tree":"63516168b2f5350e0080bd2f5f55b792658d782e","v":1,"via":"run"}
|
The idle check is a relaxed atomic now, on top of 6d8ef13 as 405bf9d. profile_start and profile_end take the clock mutex only while a test has armed it. The flag is stored after the clock is written, still under that mutex, so a load that sees it set then takes the lock and sees the timestamps. profiler_parity is 3/3 here. Thanks for the rebase and the x86_64 run. |
os_inhibit_sleep_create/set_active must register a session inhibitor through org.freedesktop.portal.Inhibit, or through org.freedesktop.ScreenSaver when there is no portal, with the caller's reason, and set_active(false) must release it. Both services are faked on a private bus (GTestDBus starts its own dbus-daemon) served from their own thread. No display is needed. Without dbus-daemon the cases are skipped. Fails with ENABLE_RUST_LIBOBS=ON: the Rust os_inhibit_sleep_* from the platform-nix.c port (obs-rust#403) only runs xdg-screensaver reset every 30 s and makes no D-Bus call. Passes with the C build. Refs obs-rust#453. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With ENABLE_RUST_LIBOBS=ON, util/platform-nix.c is not compiled and the Rust port (obs-rust#403) provided os_inhibit_sleep_*. That version only ran xdg-screensaver reset every 30 s and ignored the reason, so the portal (platform-nix-portal.c) and session D-Bus (platform-nix-dbus.c) inhibitors were compiled but never called. On Wayland desktops (Hyprland, wlroots, GNOME) nothing stopped idle sleep or locking during a recording or stream. Move os_inhibit_sleep_* for Linux and FreeBSD out of platform-nix.c, unchanged, into util/platform-nix-inhibit.c, which both lanes compile. Drop the Rust shims, nix::Inhibit and their export entries, so libobs has one definition and the same exported symbol set in both lanes. The C oracle no longer renames the moved functions. rust/README.md and the parity test header say the function stays C. macOS (platform-cocoa.m) and Windows (platform-windows.c) are unchanged. Fixes obs-rust#453. Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=8e7cebb52a2ccab49eeffa1af7d49a8116ec88d4 secs=279 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791868099,"gate":"rust/all/fmt","host":"linux-x86_64","key":"43dcdeb829ab6f0eeadbfad56773ccd7b0a0e334ebe8665433b129819ab70360","lane":"lint","parents":["7ea103358fae5e15461faed076cc8d108a3af283"],"secs":47,"stamp":"e180dbaf8ca852d3482a8693eaedd30a","tree":"8e7cebb52a2ccab49eeffa1af7d49a8116ec88d4","v":1,"via":"run"} Ci-Attestation: {"at":1791868099,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"43dcdeb829ab6f0eeadbfad56773ccd7b0a0e334ebe8665433b129819ab70360","lane":"lint","parents":["7ea103358fae5e15461faed076cc8d108a3af283"],"secs":47,"stamp":"a3f1f2449cd5c0cb4cd3ad85cf8bbe86","tree":"8e7cebb52a2ccab49eeffa1af7d49a8116ec88d4","v":1,"via":"run"} Ci-Attestation: {"at":1791868099,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"dc918605f0cf0fa0101fe7e39bd11b1c96c378c6e755c9ea296d908d0795784b","lane":"rust-test","parents":["7ea103358fae5e15461faed076cc8d108a3af283"],"secs":157,"stamp":"cb9be05fa7c90af4c9da4645778f7ae4","tree":"8e7cebb52a2ccab49eeffa1af7d49a8116ec88d4","v":1,"via":"run"} Ci-Attestation: {"at":1791868099,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"202b36cf9323fb6a487d762530ce84f333e8cf15419de9788f8986e56992a04f","lane":"tier2-linux","parents":["7ea103358fae5e15461faed076cc8d108a3af283"],"secs":74,"stamp":"65a42fad9306b19cfaa6003094b678cf","tree":"8e7cebb52a2ccab49eeffa1af7d49a8116ec88d4","v":1,"via":"run"}
os_inhibit_sleep_create/set_active must register a session inhibitor through org.freedesktop.portal.Inhibit, or through org.freedesktop.ScreenSaver when there is no portal, with the caller's reason, and set_active(false) must release it. Both services are faked on a private bus (GTestDBus starts its own dbus-daemon) served from their own thread. No display is needed. Without dbus-daemon the cases are skipped. Fails with ENABLE_RUST_LIBOBS=ON: the Rust os_inhibit_sleep_* from the platform-nix.c port (obs-rust#403) only runs xdg-screensaver reset every 30 s and makes no D-Bus call. Passes with the C build. Refs obs-rust#453. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With ENABLE_RUST_LIBOBS=ON, util/platform-nix.c is not compiled and the Rust port (obs-rust#403) provided os_inhibit_sleep_*. That version only ran xdg-screensaver reset every 30 s and ignored the reason, so the portal (platform-nix-portal.c) and session D-Bus (platform-nix-dbus.c) inhibitors were compiled but never called. On Wayland desktops (Hyprland, wlroots, GNOME) nothing stopped idle sleep or locking during a recording or stream. Move os_inhibit_sleep_* for Linux and FreeBSD out of platform-nix.c, unchanged, into util/platform-nix-inhibit.c, which both lanes compile. Drop the Rust shims, nix::Inhibit and their export entries, so libobs has one definition and the same exported symbol set in both lanes. The C oracle no longer renames the moved functions. rust/README.md and the parity test header say the function stays C. macOS (platform-cocoa.m) and Windows (platform-windows.c) are unchanged. Fixes obs-rust#453. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* test: Check os_inhibit_sleep uses the portal and ScreenSaver D-Bus os_inhibit_sleep_create/set_active must register a session inhibitor through org.freedesktop.portal.Inhibit, or through org.freedesktop.ScreenSaver when there is no portal, with the caller's reason, and set_active(false) must release it. Both services are faked on a private bus (GTestDBus starts its own dbus-daemon) served from their own thread. No display is needed. Without dbus-daemon the cases are skipped. Fails with ENABLE_RUST_LIBOBS=ON: the Rust os_inhibit_sleep_* from the platform-nix.c port (#403) only runs xdg-screensaver reset every 30 s and makes no D-Bus call. Passes with the C build. Refs #453. Co-Authored-By: Claude Opus 5.5 <[email protected]> * libobs: Keep Linux sleep inhibition in C with Rust libobs With ENABLE_RUST_LIBOBS=ON, util/platform-nix.c is not compiled and the Rust port (#403) provided os_inhibit_sleep_*. That version only ran xdg-screensaver reset every 30 s and ignored the reason, so the portal (platform-nix-portal.c) and session D-Bus (platform-nix-dbus.c) inhibitors were compiled but never called. On Wayland desktops (Hyprland, wlroots, GNOME) nothing stopped idle sleep or locking during a recording or stream. Move os_inhibit_sleep_* for Linux and FreeBSD out of platform-nix.c, unchanged, into util/platform-nix-inhibit.c, which both lanes compile. Drop the Rust shims, nix::Inhibit and their export entries, so libobs has one definition and the same exported symbol set in both lanes. The C oracle no longer renames the moved functions. rust/README.md and the parity test header say the function stays C. macOS (platform-cocoa.m) and Windows (platform-windows.c) are unchanged. Fixes #453. Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=8e7cebb52a2ccab49eeffa1af7d49a8116ec88d4 secs=279 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791868099,"gate":"rust/all/fmt","host":"linux-x86_64","key":"43dcdeb829ab6f0eeadbfad56773ccd7b0a0e334ebe8665433b129819ab70360","lane":"lint","parents":["7ea103358fae5e15461faed076cc8d108a3af283"],"secs":47,"stamp":"e180dbaf8ca852d3482a8693eaedd30a","tree":"8e7cebb52a2ccab49eeffa1af7d49a8116ec88d4","v":1,"via":"run"} Ci-Attestation: {"at":1791868099,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"43dcdeb829ab6f0eeadbfad56773ccd7b0a0e334ebe8665433b129819ab70360","lane":"lint","parents":["7ea103358fae5e15461faed076cc8d108a3af283"],"secs":47,"stamp":"a3f1f2449cd5c0cb4cd3ad85cf8bbe86","tree":"8e7cebb52a2ccab49eeffa1af7d49a8116ec88d4","v":1,"via":"run"} Ci-Attestation: {"at":1791868099,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"dc918605f0cf0fa0101fe7e39bd11b1c96c378c6e755c9ea296d908d0795784b","lane":"rust-test","parents":["7ea103358fae5e15461faed076cc8d108a3af283"],"secs":157,"stamp":"cb9be05fa7c90af4c9da4645778f7ae4","tree":"8e7cebb52a2ccab49eeffa1af7d49a8116ec88d4","v":1,"via":"run"} Ci-Attestation: {"at":1791868099,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"202b36cf9323fb6a487d762530ce84f333e8cf15419de9788f8986e56992a04f","lane":"tier2-linux","parents":["7ea103358fae5e15461faed076cc8d108a3af283"],"secs":74,"stamp":"65a42fad9306b19cfaa6003094b678cf","tree":"8e7cebb52a2ccab49eeffa1af7d49a8116ec88d4","v":1,"via":"run"} --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Refs #153
What and why
platform-nix.cis the Unix half of the platform work on #153. The safe core isobs-util::platform::unix::nix, with a C shim for every symbol that file defines.ENABLE_RUST_LIBOBSdropsutil/platform-nix.con macOS, Linux, and FreeBSD.platform-cocoa.mstill provides the Apple clock, paths, CPU, memory, and inhibit.platform-nix-dbus.candplatform-nix-portal.cstay C.platform.cstays #262.platform-windows.cstays unclaimed.test/cmocka/test_platform.cis unchanged.get_plugin_infois not a libobs export.obs-module.ccalls it inside the library, so the shim is hidden the same way the utf8 helpers are.os_opendircopies the path (C keeps the caller's pointer). Null pointers that would crash return an error or null. Glob paths are copies freed byos_globfree.os_dir,os_cpu_usage_info, andos_inhibit_infoareBoxvalues, notbmalloc. The inhibit worker is a Rust thread, and a failed spawn is not joined. Core-count and total-memory caches take a mutex. A missing$HOMEstillbcrashes in the shim. FreeBSD total memory readshw.physmem.RED → GREEN
954275c1b.soldr cargo test -p obs-util --test platform_nixfails 9 tests againsttodo!():test_file_exists,test_unlink_missing_fails,test_mkdir_success_then_exists,test_mkdir_missing_parent_is_error,test_rename,test_safe_replace_with_backup,test_safe_replace_without_backup,test_opendir_readdir_closedir,test_get_abs_path_ptr_dot.6826a120c, then373c3de12. The follow-up hidesget_plugin_infoand gives the oracle copies ofos_sleepto_ns_fastandos_safe_replaceprivate names, so GNU ld does not see two definitions. Stamped.tier2-linux): cmocka 131 tests, 0 failed, 7 skipped, withENABLE_RUST_LIBOBSOFF and ON.test_platformpassed in both. Exported symbols identical, 1765. Lint and the Rust tests passed in the same stamp.file_existsforced to return false.test_file_existspanicked, andfile_ops_match_the_c_filefailed (left: false,right: true). Restored.target_os = "freebsd"paths (hw.physmem, dmesg.boot, the sysctl memory calls) are not compiled on this machine or in that image. There is no FreeBSD job in CI.Checklist
master