Repository navigation
libobs: Make the transition flags and actual size atomic - #3669
Merged
Merged
Conversation
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"}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #3570
What and why
transitioning_audio,transitioning_videoandtransition_actual_cx,_cyare 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
cxwith an oldcyfor 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_*andtransition_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_releaseandtest_transition_audio_rescale:transitioning_audio,transitioning_videotransition_actual_cx,_cyOne 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.
transitiontests pass.Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change measured)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag changes)🤖 Generated with Claude Code