You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
libobs: os_sleep_ms(1) becomes Sleep(0) on Windows 8+, turning 1 ms retry loops into yield-spins #1274
os_sleep_ms subtracts 1 ms on Windows 8+ before calling Sleep, so os_sleep_ms(1) becomes Sleep(0). Sleep(0) only yields: on an idle machine a loop that "sleeps 1 ms" between retries spins at ~100% of one core.
C: libobs/util/platform-windows.c.h:365-371
Rust port (exported in place of the C one): rust/obs-util/src/platform/windows/host.rs:719-724
if (get_winver() >= 0x0602&&duration>0)
duration--;
Sleep(duration);
This is inherited from upstream OBS ("windows 8+ appears to have decreased sleep precision"). Callers that pass 1 are the spin sites in the sibling issues (Lua graphics lock, AMF input retry, AJA output thread).
Fix: never turn a positive duration into 0 (e.g. if (duration > 1) duration--;), in both the C and Rust versions, with the Tier 3 parity test updated to match. Optionally, use a high-resolution waitable timer for short sleeps.
Test: a Windows unit test showing that os_sleep_ms(1) in a loop runs well under ~1000 iterations per second (a yield-spin runs hundreds of thousands); plus Tier 1/3 coverage of the new rule.
Claiming. Plan: never turn a positive duration into 0 (duration > 1 → duration--) in both libobs/util/platform-windows.c.h and rust/obs-util/src/platform/windows/host.rs, keeping the Rust port in parity with the C (or listing it as an intentional difference if the oracle is the pristine upstream C). RED: a Windows test that os_sleep_ms(1) in a loop stays well under ~1000 iterations per second, plus a Tier 1 test of the duration rule.
Activity
zackees commentedon Oct 17, 2026
Claiming. Plan: never turn a positive duration into 0 (
duration > 1→duration--) in bothlibobs/util/platform-windows.c.handrust/obs-util/src/platform/windows/host.rs, keeping the Rust port in parity with the C (or listing it as an intentional difference if the oracle is the pristine upstream C). RED: a Windows test thatos_sleep_ms(1)in a loop stays well under ~1000 iterations per second, plus a Tier 1 test of the duration rule.libobs, obs-util: os_sleep_ms(1) no longer becomes Sleep(0) on Windows (