Skip to content

libobs: Lock the transition tick's manual step, make the set size atomic - #3698

Merged
vpacher merged 2 commits into
masterfrom
fix/3570-transition-manual
Nov 5, 2026
Merged

vpacher merged 2 commits into
masterfrom
fix/3570-transition-manual

Conversation

@vpacher

@vpacher vpacher commented Nov 5, 2026

Copy link
Copy Markdown
Member

Fixes #3570

What and why

obs_transition_tick() read the mode and the manual fields and wrote transition_manual_val with no lock, while obs_transition_start(), obs_transition_set(), obs_transition_get_time(), the load and the manual setters hold transition_mutex. The tick is ported, so the C and rust/obs-source both change: the tick now holds the lock around the manual step. While it holds the lock, the step calls only calc_torquef(), so the lock order does not change.

transition_cx, _cy are read and written with no lock, in obs_transition_set_size() and on the graphics thread. They are now atomic at every read and write, as transition_actual_cx, _cy are since #3669. The Rust code reaches them through the seam, so it does not change.

Risk: a reader can see a new cx with an old cy for one call, as it could before. The tick takes transition_mutex one more time per frame, for a short time.

With #3640 and #3669 this completes #3570. Expected effect of the old code: a manual transition that is one tick off. I did not measure a user-visible change, so there is no features ledger line.

RED → GREEN

  • RED, the first commit: the Tier 1 fake panics when the mode or a manual field is read without transition_mutex, and tick_order and the copy of the C expect the lock. 5 of the 25 transition_size tests fail with transition_mode without transition_mutex.
  • GREEN, the second commit: all pass.

ThreadSanitizer does not run on PRs, so this evidence is local (hybrid libobs, the sanitizer build). 3 passes each of test_group_hide_transition_audio, test_item_transition_empty_source, test_source_transition_size, test_source_transition_slots, test_source_transition_access, test_transition_recursive_destination, test_transition_load_release and test_transition_audio_rescale:

Reports master with this PR
Top frames on these fields 11, 15, 13 0, 0, 0
All reports 58, 61, 59 51, 51, 51
Lock order reports 7, 7, 7 7, 7, 7

The 51 left are 44 reports inside Mesa's software GL library and the 7 lock order reports, which this PR does not change. All tests pass. The next nightly confirms this on CI.

  • Local gate: all Linux lanes passed (Tier 2 against hybrid and the C reference).
  • Windows (local MSVC build, hybrid and C reference): 1795 exports identical, 23 transition, scene item and group Tier 2 tests pass on both DLLs, Rust transition tests pass.
  • Real app (UI, protocol output or logging changes): not applicable.
  • Test cost: no new tests. The changed fake adds no time.

Checklist

  • Base is master (or the description starts with a Stacked: note)
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change measured)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): built with scripting ON (PR CI builds no OBS app: run gh workflow run ci.yml --ref <branch> for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag changes)
  • Intentional differences from C listed in the parity test header and rust/README.md (ports) (not applicable: the C and the Rust change together)

🤖 Generated with Claude Code

vpacher and others added 2 commits November 5, 2026 18:45
RED: the fake transition panics when the mode or a manual field is read
without transition_mutex. tick() holds no lock there, so 5 of the 25
transition_size tests fail.

Refs #3570.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
obs_transition_tick() read the mode and the manual fields and wrote
transition_manual_val with no lock. Every other reader and writer holds
transition_mutex. The tick now holds it around the step, in the C and in
obs-source. While it holds the lock, the step calls only calc_torquef().

transition_cx and _cy are read and written with no lock, so they are now
atomic, as transition_actual_cx and _cy are. The Rust code reaches them
through the seam.

Refs #3570.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=37348618c8a0c44da6c30748bea37507506ab44f secs=326 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a
Ci-Attestation: {"at":1793901064,"gate":"rust/all/fmt","host":"linux-x86_64","key":"9d9af652fee7f3dc497dcbd7599c124b6826abe944f416cdcd4e76c0f6a110e7","lane":"lint","parents":["82fb4357cd193cc70dd7cb5960196f7a799b1518"],"secs":89,"stamp":"5e074d09fa28bdf6f6b405d78f9a5c22","tree":"37348618c8a0c44da6c30748bea37507506ab44f","v":1,"via":"run"}
Ci-Attestation: {"at":1793901064,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"9d9af652fee7f3dc497dcbd7599c124b6826abe944f416cdcd4e76c0f6a110e7","lane":"lint","parents":["82fb4357cd193cc70dd7cb5960196f7a799b1518"],"secs":89,"stamp":"96c151438e5040baec1056671675dc38","tree":"37348618c8a0c44da6c30748bea37507506ab44f","v":1,"via":"run"}
Ci-Attestation: {"at":1793901064,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"9c3720ac33f433ae84c8a5b3be894893e20a5597f8705365f674c73648d596df","lane":"rust-test","parents":["82fb4357cd193cc70dd7cb5960196f7a799b1518"],"secs":99,"stamp":"6cf0c2cf42f3a79d0fd4c56f6bd60b72","tree":"37348618c8a0c44da6c30748bea37507506ab44f","v":1,"via":"run"}
Ci-Attestation: {"at":1793901064,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"b3fac1526f67d96d8e7dca85ea9abc4725cabc4e435a75dece17733319f95992","lane":"cross","parents":["82fb4357cd193cc70dd7cb5960196f7a799b1518"],"secs":74,"stamp":"577ab3991b5529391adaaae2b4a41128","tree":"37348618c8a0c44da6c30748bea37507506ab44f","v":1,"via":"run"}
Ci-Attestation: {"at":1793901064,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"b3fac1526f67d96d8e7dca85ea9abc4725cabc4e435a75dece17733319f95992","lane":"cross","parents":["82fb4357cd193cc70dd7cb5960196f7a799b1518"],"secs":74,"stamp":"fb8c320e5c41be094cca2008e60330f9","tree":"37348618c8a0c44da6c30748bea37507506ab44f","v":1,"via":"run"}
Ci-Attestation: {"at":1793901064,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"b3fac1526f67d96d8e7dca85ea9abc4725cabc4e435a75dece17733319f95992","lane":"cross","parents":["82fb4357cd193cc70dd7cb5960196f7a799b1518"],"secs":74,"stamp":"c38ea55bb564ba77e0d7cf5ac542a5eb","tree":"37348618c8a0c44da6c30748bea37507506ab44f","v":1,"via":"run"}
Ci-Attestation: {"at":1793901064,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"b3fac1526f67d96d8e7dca85ea9abc4725cabc4e435a75dece17733319f95992","lane":"cross","parents":["82fb4357cd193cc70dd7cb5960196f7a799b1518"],"secs":74,"stamp":"dffdd8ccb8b36e3342617a02319aea85","tree":"37348618c8a0c44da6c30748bea37507506ab44f","v":1,"via":"run"}
Ci-Attestation: {"at":1793901064,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"68eb2f262ffec86db69dd85b1a892353feddb2a0f9de746a2b787ac11865bbea","lane":"tier2-linux","parents":["82fb4357cd193cc70dd7cb5960196f7a799b1518"],"secs":326,"stamp":"0b70eb877fb3f31159e58025d50dc204","tree":"37348618c8a0c44da6c30748bea37507506ab44f","v":1,"via":"run"}
@vpacher
vpacher requested a review from zackees as a code owner November 5, 2026 17:54
@vpacher
vpacher enabled auto-merge November 5, 2026 17:55
@vpacher
vpacher added this pull request to the merge queue Nov 5, 2026
Merged via the queue into master with commit 5e1a820 Nov 5, 2026
39 checks passed
@vpacher
vpacher deleted the fix/3570-transition-manual branch November 5, 2026 18:18
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: transition state is shared between threads without transition_mutex

1 participant