Skip to content

fix: synchronize video stats shared with UI threads - #439

Merged
zackees merged 2 commits into
masterfrom
fix/175-video-stats-race
Oct 13, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/175-video-stats-race

Conversation

@zackees

@zackees zackees commented Oct 13, 2026

Copy link
Copy Markdown
Member

Fixes #175.

The graphics thread now publishes total/lagged frames and FPS/frame time through a private mutex-backed stats object. The four public getters use the same object. Output start and stop logging reads both frame counts in one snapshot, so those consumers also avoid the race. The C API and exported symbol set are unchanged.

RED commit: bc52867d5 introduced a concurrent reader/writer test against the unlocked helper. cc -std=c11 -O1 -g -fsanitize=thread -fno-omit-frame-pointer test/cmocka/test_video_stats_race.c -lpthread reported three data races and exited 66.

GREEN commit: 769e32465 added locking and connected the production fields and consumers. The same ThreadSanitizer test exits 0. The test is registered in the C suite and its checks remain active with NDEBUG.

Validation: ./lint, ./unittest (142 C tests with Rust OFF and ON), and the stamped local gate passed. OFF and ON exported the same 1766 symbols. Head: dd3bed040e43.

Local-Gate: v1 tree=bd62d3376d49eeb5a69d8c4e9ce1450c48fdeaf6 secs=112 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791861355,"gate":"rust/all/fmt","host":"linux-x86_64","key":"d5fffa016b8c3a1269ccc5e000f173d96380f56a319cef69a6e070c346554d73","lane":"lint","parents":["bc52867d5e24d82e2afd900867d5ebd4ba46dfba"],"secs":16,"stamp":"7f29b3b0f387776c4b54315bca8b9a9b","tree":"bd62d3376d49eeb5a69d8c4e9ce1450c48fdeaf6","v":1,"via":"run"}
Ci-Attestation: {"at":1791861355,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"d5fffa016b8c3a1269ccc5e000f173d96380f56a319cef69a6e070c346554d73","lane":"lint","parents":["bc52867d5e24d82e2afd900867d5ebd4ba46dfba"],"secs":16,"stamp":"b38a37aaebe672d723d59ad794b9eefd","tree":"bd62d3376d49eeb5a69d8c4e9ce1450c48fdeaf6","v":1,"via":"run"}
Ci-Attestation: {"at":1791861355,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"d828136e85bb94e10ae94aa79ebb3a6e4789e7c8c021f424dfc75b45b8d14859","lane":"rust-test","parents":["bc52867d5e24d82e2afd900867d5ebd4ba46dfba"],"secs":41,"stamp":"db64e765580e2c850c8aeed0d656a0c7","tree":"bd62d3376d49eeb5a69d8c4e9ce1450c48fdeaf6","v":1,"via":"run"}
Ci-Attestation: {"at":1791861355,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"b94376261666d093499fac534192bbb7d5c7be074ca942c28e6fd04f2ce18e00","lane":"tier2-linux","parents":["bc52867d5e24d82e2afd900867d5ebd4ba46dfba"],"secs":54,"stamp":"9b0cc81c6a4865d7dea26b29b8248df7","tree":"bd62d3376d49eeb5a69d8c4e9ce1450c48fdeaf6","v":1,"via":"run"}
@zackees
zackees merged commit 7cf6f39 into master Oct 13, 2026
10 checks passed
@zackees
zackees deleted the fix/175-video-stats-race branch October 13, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: libobs: video stats (fps, frame time, total/lagged frames) raced between graphics and UI threads

1 participant