Skip to content

test: wait for fresh ticks in test_source_profiler_run (GREEN, Fixes #6043) - #6044

Merged
rdoupe merged 1 commit into
masterfrom
fix/source-profiler-run-stale-tick
Dec 1, 2026
Merged

rdoupe merged 1 commit into
masterfrom
fix/source-profiler-run-stale-tick

Conversation

@rdoupe

@rdoupe rdoupe commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #6043.

a_timed_run_ends_and_names_the_slow_plugin failed on master's push run of 9f3d2f0 (https://github.com/obs-rust/obs-studio/actions/runs/46582379780, source_profiler_fill_result(slow_source(), &r) is not false at line 262); the next push run passed.

Cause. tick_event is an auto event that the ticker signals every frame. Nobody waits on it during the one-second timed run, so it stays set, and the wait_frames(1) after the run's finished signal returned at once. The case then read the profiler while the video thread could still be between run_finished and the store that turns the profiler off.

Change. wait_frames clears tick_event before it waits, so it waits for ticks that come after the call. Test-only; no libobs change.

Evidence (linux-validate image, this worktree's kept build volume, test_source_profiler_run run 5 times per library):

variant hybrid libobs C reference
RED: master's test + probe (200 ms sleep in its run_finished handler, on the video thread) 0/5 pass, all at line 262 0/5 pass, all at line 262
GREEN: this change + the same probe 5/5 5/5
this change, no probe 5/5 5/5

The probe was only in throwaway copies of the test; it is not committed.

Test cost: no new tests; the case's run time is unchanged (one frame more at most).

🤖 Generated with Claude Code

…6043)

tick_event is an auto event the ticker signals every frame. During the
one-second timed run nobody waits on it, so it stays set, and the
wait_frames(1) after the run's finished signal returned at once instead of
letting the collection that sent the signal turn the profiler off. The
case then read the profiler while the video thread could still be between
run_finished and the enabled store, and failed on a loaded runner.

wait_frames now clears the event first, so it waits for ticks that come
after the call.

RED: a probe copy sleeping 200 ms in the run_finished handler fails master's
test 5/5 on hybrid libobs and 5/5 on the C reference (line 262); with this
change it passes 5/5 on both, and 5/5 on both without the probe.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ci-Attestation: {"at":1796108346,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":78,"stamp":"f8aa5dd16baa522917be8181a148ad02","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108346,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":78,"stamp":"602d6dbdc3486ba6a62dd42579afe648","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108346,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":78,"stamp":"5443187a4ed293d78723f6cff2830447","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108346,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":78,"stamp":"b48241c2142223c6dac90afa94b961a0","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108267,"gate":"general/all/client-lint","host":"linux-x86_64","key":"a49bac31fad352063449bd290466e7491b1783304eb125c463f99ae0739632b8","lane":"client-lint","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":92,"stamp":"783383e9db072668e5ac54d155f49ab9","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108346,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":78,"stamp":"b1a643ac304d533b2c48c808eb81b0eb","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108268,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"a49bac31fad352063449bd290466e7491b1783304eb125c463f99ae0739632b8","lane":"client-lint","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":92,"stamp":"f79c1e448dc6b72f97d46f883bd3f7d0","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108268,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"a49bac31fad352063449bd290466e7491b1783304eb125c463f99ae0739632b8","lane":"client-lint","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":92,"stamp":"81673a4f1643351dc7456915efb44c89","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108268,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"a49bac31fad352063449bd290466e7491b1783304eb125c463f99ae0739632b8","lane":"client-lint","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":92,"stamp":"8103a2fe0c0818216b5378048b5df88b","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108268,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"a49bac31fad352063449bd290466e7491b1783304eb125c463f99ae0739632b8","lane":"client-lint","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":92,"stamp":"8417f5181b50fa3bbde4cd593c59dfd8","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108267,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"a49bac31fad352063449bd290466e7491b1783304eb125c463f99ae0739632b8","lane":"client-lint","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":92,"stamp":"2a34d0ec01111ca21fbe2febe00920dd","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108267,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"a49bac31fad352063449bd290466e7491b1783304eb125c463f99ae0739632b8","lane":"client-lint","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":92,"stamp":"3c1035234f4d63b446c5df02497f1642","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108268,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"a49bac31fad352063449bd290466e7491b1783304eb125c463f99ae0739632b8","lane":"client-lint","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":92,"stamp":"8b0030c21c38d7d177c60e6c770aea52","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108268,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"a49bac31fad352063449bd290466e7491b1783304eb125c463f99ae0739632b8","lane":"client-lint","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":92,"stamp":"73b126fe2ef5696abda165e56a7aa787","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108268,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"a49bac31fad352063449bd290466e7491b1783304eb125c463f99ae0739632b8","lane":"client-lint","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":92,"stamp":"68ccf36c399c45621585ab43b953a1e0","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108268,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"a49bac31fad352063449bd290466e7491b1783304eb125c463f99ae0739632b8","lane":"client-lint","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":92,"stamp":"bd8d9b738967c55175d738ac4e394194","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108267,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"a49bac31fad352063449bd290466e7491b1783304eb125c463f99ae0739632b8","lane":"client-lint","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":92,"stamp":"a6b2e813b196bd2dace52c9bf92d3eab","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108267,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"a49bac31fad352063449bd290466e7491b1783304eb125c463f99ae0739632b8","lane":"client-lint","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":92,"stamp":"012cbc38095385fc81739f4471fa85cd","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}
Ci-Attestation: {"at":1796108724,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"bfdd2d578f6f969f2da6f25e08070051f656db3f566a6a2d06b50327b145f9c4","lane":"client-test-x86_64-unknown-linux-gnu","parents":["0ed5d58b808f89f383dc61422d5fe35c1754e180"],"secs":377,"stamp":"ec835ebb3e1d771388d02fc5b936ae91","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"0ed5d58b808f89f383dc61422d5fe35c1754e180","coverage":"all-tracked-applicable-files","diff":["test/cmocka/test_source_profiler_run.c"],"head":"45694b89872fd0e59772fb9152ee2c4aced245c0","tools":{"orchestrator-python":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]","schema-dependencies":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]\n{'jsonschema': '4.26.0', 'json_source_map': '1.0.5'}","uv":"uv 0.13.5 (x86_64-unknown-linux-gnu)","xmllint":"xmllint: using libxml version 21504-GITv2.15.4\n   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ICU ISO8859X Regexps Automata RelaxNG Schemas Schematron Modules Debug Zlib"},"tracked-digest":"be8f204ee73e856eeba0ac93cb4cb04792015571a14e3d46a8aa61832d0ad520","tree":"6819cd5728bbb73e6030c5c5d9903c83c005cc69"}}
@rdoupe
rdoupe requested a review from zackees as a code owner December 1, 2026 07:05
@rdoupe
rdoupe enabled auto-merge December 1, 2026 07:15

@zackees zackees left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coordinator review: LGTM. This edits an existing C test, so to note why it's allowed: the change fixes the test's own synchronization, not a port's behaviour. wait_frames now resets the auto event first, so a tick left set during the timed run can't satisfy the wait before any frame has passed. It's 5 lines added, in vpacher's own recent test_source_profiler_run.c, and no assertion changes. Auto-merge on.

@rdoupe
rdoupe added this pull request to the merge queue Dec 1, 2026
Merged via the queue into master with commit 0ea57f2 Dec 1, 2026
53 checks passed
@rdoupe
rdoupe deleted the fix/source-profiler-run-stale-tick branch December 1, 2026 07:47
wininusthefirst pushed a commit to wininusthefirst/obs-studio that referenced this pull request Dec 4, 2026
…bs-rust#6047) (obs-rust#6050)

wait_frames() in test_source_profiler, _gpu, _late and _totals waits on
tick_event, an auto event that every tick signals. A tick that nobody
waited for leaves it set, and the next wait_frames(n) then waits for one
tick fewer (obs-rust#6043). Clear the event before the loop, as obs-rust#6044 does in
test_source_profiler_run.

Defensive: the current calls do not get a stale tick. A probe that times
the first wait of each call measured about one frame in all 15 calls,
on hybrid libobs and the C reference.

docs/knowledge/timing-tests.md gets the lesson (obs-rust#6043, obs-rust#6047).

Test-only: no libobs change, no assertion changes.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

test_source_profiler_run: a_timed_run_ends_and_names_the_slow_plugin races the profiler turning off

2 participants