Skip to content

libobs: Make the transition flags and actual size atomic - #3669

Merged
vpacher merged 1 commit into
masterfrom
fix/3570-transition-fields
Nov 5, 2026
Merged

vpacher merged 1 commit into
masterfrom
fix/3570-transition-fields

Conversation

@vpacher

@vpacher vpacher commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Refs #3570

What and why

transitioning_audio, transitioning_video and transition_actual_cx, _cy are read and written on the graphics and audio threads and by any caller. Some of those places hold no lock: transition_active(), scene_transition_active(), the source size getters, and the tick's write after it drops the lock.

These four fields are now atomic at every read and write. Atomics need no check of the lock order. The logic does not change.

Risk: a reader can see a new cx with an old cy for one call, as it could before. A flag can change between two reads in one function, as it could before. This PR removes the data race, not those orderings.

Not in this PR, so Refs: transition_manual_* and transition_mode. They need the transition lock and a check of the lock order, including the ported Rust that reaches them through the seam.

Expected effect of the old code: a transition that starts or ends one tick off, or a wrong size for one read. I did not measure a user-visible change, so there is no features ledger line.

RED → GREEN

ThreadSanitizer does not run on PRs, so this evidence is local (hybrid libobs, the sanitizer build). There is no RED commit: existing tests show the race. 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 with these fields in the top frame master with this PR
transitioning_audio, transitioning_video 15, 18, 19 0, 0, 0
transition_actual_cx, _cy 6, 8, 8 0, 0, 0

One more pass on the final commit: 0 and 0. All tests pass. The next nightly confirms this on CI.

The final commit leaves 59 reports in these tests: 44 inside Mesa's software GL library, 8 on the other transition fields of #3570, and 7 lock order reports. The count of lock order reports does not change with this PR.

  • 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.

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 (N/A: the existing tests show the race, the evidence is the ThreadSanitizer pass above)
  • 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: not a port)

🤖 Generated with Claude Code

transitioning_audio, transitioning_video and transition_actual_cx, _cy are
read and written on the graphics and audio threads and by any caller, in
places with no lock: transition_active(), scene_transition_active(), the
size getters, and the tick's write after it drops the lock. They are now
atomic at every read and write. Atomics need no check of the lock order.

The ThreadSanitizer reports on these fields go from 15-19 and 6-8 per pass
to 0 over 3 passes of 8 tests.

Refs #3570.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=76012f43f1331e2a391c4b45c13354095194f9b2 secs=316 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a
Ci-Attestation: {"at":1793869337,"gate":"rust/all/fmt","host":"linux-x86_64","key":"24bc7bc0846b7cd529fa421dd12b7c0667fdab7090f0d7cf52face19381ff872","lane":"lint","parents":["8340c7ead785b162d185d9af397054624de30a77"],"secs":80,"stamp":"1f56058a633d76eb170c689d1d357caf","tree":"76012f43f1331e2a391c4b45c13354095194f9b2","v":1,"via":"run"}
Ci-Attestation: {"at":1793869337,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"24bc7bc0846b7cd529fa421dd12b7c0667fdab7090f0d7cf52face19381ff872","lane":"lint","parents":["8340c7ead785b162d185d9af397054624de30a77"],"secs":80,"stamp":"ec218d670c55ddbff0ef641ac2b6ef9f","tree":"76012f43f1331e2a391c4b45c13354095194f9b2","v":1,"via":"run"}
Ci-Attestation: {"at":1793869337,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"792a2e74d36d793e590a2f8b4ddbdcbfa21766c0dcb1de1dc2edf2a0d355dc09","lane":"rust-test","parents":["8340c7ead785b162d185d9af397054624de30a77"],"secs":89,"stamp":"c7ef50273b066c9beb59edc873b75db2","tree":"76012f43f1331e2a391c4b45c13354095194f9b2","v":1,"via":"run"}
Ci-Attestation: {"at":1793869337,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"e2c4408ebe1a2a8d4d35ae4da160f48805d32a4c4bb2483ecbb1cffe13c27874","lane":"cross","parents":["8340c7ead785b162d185d9af397054624de30a77"],"secs":62,"stamp":"09752669fb309f52fab29dc24d5cc8b5","tree":"76012f43f1331e2a391c4b45c13354095194f9b2","v":1,"via":"run"}
Ci-Attestation: {"at":1793869337,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"e2c4408ebe1a2a8d4d35ae4da160f48805d32a4c4bb2483ecbb1cffe13c27874","lane":"cross","parents":["8340c7ead785b162d185d9af397054624de30a77"],"secs":62,"stamp":"3f7ea4e8b9149741512c894d3b86e1cc","tree":"76012f43f1331e2a391c4b45c13354095194f9b2","v":1,"via":"run"}
Ci-Attestation: {"at":1793869337,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"e2c4408ebe1a2a8d4d35ae4da160f48805d32a4c4bb2483ecbb1cffe13c27874","lane":"cross","parents":["8340c7ead785b162d185d9af397054624de30a77"],"secs":62,"stamp":"31f64dc256d9619c6298db3e6f1ad708","tree":"76012f43f1331e2a391c4b45c13354095194f9b2","v":1,"via":"run"}
Ci-Attestation: {"at":1793869337,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"e2c4408ebe1a2a8d4d35ae4da160f48805d32a4c4bb2483ecbb1cffe13c27874","lane":"cross","parents":["8340c7ead785b162d185d9af397054624de30a77"],"secs":62,"stamp":"1509143a89481a037998564b2f6956ed","tree":"76012f43f1331e2a391c4b45c13354095194f9b2","v":1,"via":"run"}
Ci-Attestation: {"at":1793869337,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"8c1206a4872ac9c9bdbec36810c624bc994804d9cb66392b73cb27ee7099cc44","lane":"tier2-linux","parents":["8340c7ead785b162d185d9af397054624de30a77"],"secs":316,"stamp":"797ee48caac173282f78a1658ec50e22","tree":"76012f43f1331e2a391c4b45c13354095194f9b2","v":1,"via":"run"}
@vpacher
vpacher enabled auto-merge November 5, 2026 09:11
@vpacher
vpacher added this pull request to the merge queue Nov 5, 2026
Merged via the queue into master with commit b30e5b6 Nov 5, 2026
39 checks passed
@vpacher
vpacher deleted the fix/3570-transition-fields branch November 5, 2026 09:35
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.

1 participant