Skip to content

ObsModel: studio mode, transitions, transforms, activity and levels (steps 4 and 5) - #96

Merged
tinodo merged 9 commits into
mainfrom
model/steps-4-5
Nov 11, 2026
Merged

tinodo merged 9 commits into
mainfrom
model/steps-4-5

Conversation

@tinodo

@tinodo tinodo commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

Steps 4 and 5 of making ObsModel complete (stacked on the pull request of steps 1 to 3: merge that one first).

  • Step 4: studio mode, the preview scene and the scene transitions (obs.Transitions).
  • Step 5: the transform of a scene item, its blend mode and copies of scene items; whether inputs are on the air and shown; the levels of the audio. What OBS Studio sends many times a second is opt-in (ObsModelOptions.HighVolume, off by default), so an application that does not ask pays nothing for it.
  • A fix of a live test: the activity test waits for what OBS Studio does a moment after a transition.

Everything is additive. The messages of the commits follow.

Add studio mode, the preview scene and the scene transitions to ObsModel (step 4 of making it complete)

ObsModel now has:

  • studio mode: SetStudioModeEnabledAsync (IsStudioModeEnabled was there already), PreviewScene (null while
    studio mode is off), ObsScene.IsPreview and ObsScene.SwitchToPreviewAsync. OBS Studio makes the program scene
    the preview scene when studio mode is switched on and sends no event for it, so the model reads it then, and
    when it connects with studio mode on (and again on a new connection).
  • Transitions (ObsTransitions, ObsTransition): Current, Duration and IsRunning are part of the model, with the
    events Started, Ended and VideoEnded. The calls SetCurrentAsync and SetDurationAsync return when the model
    shows the change, TriggerAsync when a transition has started; GetAllAsync, GetKindsAsync, GetSettingsAsync,
    SetSettingsAsync, GetProgressAsync and SetTBarPositionAsync ask and are not kept. A scene can bring a
    transition of its own (ObsTransitionOverride): GetTransitionOverrideAsync, SetTransitionOverrideAsync and
    ClearTransitionOverrideAsync.
  • The program scene is the new scene from the start of a transition: OBS Studio answers a question about it
    with the scene that it goes to at once and announces it when the transition has ended, so the model reads it
    when a transition starts, and SwitchToAsync returns while the transition runs.

The model subscribes to the transition events (identify mask 1535) and reads the current transition when it
connects. A refusal to say the current transition is believed only when it repeats. A transition that is
cancelled ends without its video ending, which counts as its end, except for a stinger.

Measured with OBS Studio 33.0.0 (LiveTransitionTests): what a trigger does while a transition runs (it starts
another one in the first moment, while the position is still 0), the duration that belongs to the transitions,
the overrides, the T-bar, and that removing the program scene while studio mode is on stalls OBS Studio.

The simulation has studio mode, the preview scene and transitions (SimStudioModeTests); the engine, the model
and the live tests cover them, and the live comparison of the model with OBS Studio compares studio mode, the
preview scene, the current transition, its duration and whether one runs, and waits for OBS Studio to be idle.

Add the transform of a scene item, its blend mode, copies of scene items and ObsHighVolume to ObsModel (step 5a of making it complete)

ObsModel now has:

  • ObsModelOptions.HighVolume (ObsHighVolume, None by default): what the model follows of what OBS Studio sends many
    times a second, which every subscribed client pays for. ObsHighVolume.Transforms makes the model follow the
    transform of every scene item and subscribe to SceneItemTransformChanged (identify mask 1535 | 524288).
  • The transform of a scene item: ObsSceneItem.Transform (SceneItemTransform?, null unless the model follows the
    transforms; PropertyChanged and Changed tell), GetTransformAsync (asks OBS Studio, always) and SetTransformAsync
    (a SceneItemTransformUpdate; returns when the model shows the change, or when OBS Studio has answered if the model
    does not follow). SceneItemTransform has value equality now.
  • The blend mode: GetBlendModeAsync and SetBlendModeAsync (asked and not kept: OBS Studio announces no change of it).
  • DuplicateAsync(destination): a copy on top of the scene, returned when the model shows it, with the crop (the last
    step that OBS Studio announces). ObsModel.SceneItemSelected (ObsSceneItemEventArgs) says that an item was selected;
    one that is selected before the model has told of it is told after it.

The engine keeps the transform as a cell of the item, handles SceneItemTransformChanged and SceneItemSelected, and
acts on an event of a high-volume type only when it is asked to follow it. The publisher tells what happened after the
objects of the pass are published.

Measured with OBS Studio 33.0.0 (LiveGeometryTests, LiveGeometryModelTests): a change of the position, scale, rotation,
alignment and bounds is announced at once; a crop and the size of a source only for a scene that OBS Studio renders
(a model that follows the transforms is behind for the others until they are, so SetTransformAsync and DuplicateAsync
read the scene again); a change with a crop is two events; a blend mode that is set sends the transform again, which
is no change; the size of an item is the size of its source times the scale. DuplicateSceneItem makes the copy in the
scene of the original when the destination is given by its UUID alone (obs-websocket reads the destination only when
the request has its name, and then the UUID wins), so the model gives both; the article about requests tells the plain
client to give the name.

The simulation has transforms, blend modes, copies and the checks of obs-websocket 5.7.6 (read from its source), and
keeps them when a scene collection is saved. The replay of the events tolerates a transition that a switch of the scene
collection cut off, and the walks make a media input before they play one and ask for the id of an item that is there.

ObsModel follows whether inputs are on the air and shown (step 5b)

ObsHighVolume.Activity (and All = Transforms | Activity) makes the model read GetSourceActive for
every input and subscribe to InputActiveStateChanged and InputShowStateChanged. ObsInput.IsActive
and IsShowing are bool? (null unless followed); PropertyChanged and Changed tell each by itself.
A model that does not ask sends no request for it and does not subscribe.

Engine: an activity cell and scope per input, a read kind, event handlers (an event beats an older
read, a read sent after an event beats the event), an input is announced when its activity is
known, and a connection that was lost reads it again.

Checked with OBS Studio 33.0.0 / obs-websocket 5.7.6 (LiveActivityTests): a scene that goes on the
air puts its inputs on the air when the transition starts, the old scene's inputs go off after it
ends; nested scenes; the two events come in no fixed order; nothing is said of an input that OBS
destroys; in studio mode a copy of the program scene is on the air (what is done to the scene
itself does not reach it), the preview scene shows its inputs and does not put them on the air.

Simulation: SimWorld.Activity.cs (reachability through enabled items and nested scenes, a copy
of the scene on the air in studio mode), GetSourceActive, the two events, an invariant that the
stored state is what the scenes make it. Also: the preview scene is announced first when studio
mode is switched off (measured), and a scene removed during a studio-mode transition is not made
the preview scene (a latent bug that a shifted random stream reached).

Tests: engine (23), model (8), simulation (25), over the simulation (7 theories, 10 whole-stack),
live observation and live model (the model equals GetSourceActive after every step). Mutation
checks: ignoring the events, a read applied as an event, IsComplete without the activity, a missed
hook in the simulation, no copy in studio mode: all caught.

ObsModel follows the levels of the audio (step 5c)

ObsHighVolume.AudioLevels (and All = Transforms | Activity | AudioLevels) makes the model subscribe
to InputVolumeMeters. ObsInput.Levels (ObsAudioLevels?: the Input and its Channels, each an
ObsChannelLevel with Magnitude, Peak, InputPeak and their dB values) is what OBS Studio said of the
input in its last message: null unless followed and listed. ObsModel.AudioLevels
(ObsAudioLevelsEventArgs: Levels, Ended) says that new levels came. A model that does not ask does
not subscribe.

The levels are a stream and not state, so they bypass the engine: the receive loop of the client
maps each message to the inputs by UUID (ModelAudioLevels), writes ObsInput.Levels, and wakes ONE
notification that tells what changed since it last ran, with the newest levels. A handler that is
slower than OBS Studio gets the newest levels; the queue never fills; a message that says what the
previous one said is not told; the end of the connection takes all levels. ModelNotifier got
TryEnqueue (does it queue as it is?) and a Dropped hook (a notification that a context refused).

Checked with OBS Studio 33.0.0 / obs-websocket 5.7.6 (LiveLevelsTests, read in the source of
obs-websocket too): a message every 50 ms, also when empty; it lists the inputs that are on the
air and have audio, in the order of activation (the same set as IsActive and HasAudio); a muted
input is listed with magnitude and peak 0 and the peak of the input unchanged; the volume scales
magnitude and peak; an input that plays nothing is listed with zeros; the first message that lists
an input has no channels; a mono file is two channels; the first message with audio can say a
peak that is far too high (1.9 often, 2.7e20 once).

Simulation: SimWorld.Levels.cs (a tick sends a message; the order of activation; the volume and
mute applied as OBS does; the first message without channels), a walk op, an invariant that the
list is the inputs that are on the air and have audio. The weight of SetInputAudioTracks was raised
because the shifted random stream starved it.

Tests: model (10) and direct (8) for the levels, notifier (2), simulation (10), whole stack over the
simulation (19 incl. theories: Ideal, Real, Hostile; a lost connection; a switch of the scene
collection; levels and activity agree), live observation and live model (a tone of known loudness:
mono, stereo, mute, volume, pause, program switch, a slow handler). Mutation checks: no session
check, changes always told, no coalescing, ended not removed when listed again, flag never reset,
duplicates counted twice, Dropped hook not wired, end of connection takes nothing: all caught.

Make the live activity test wait for what OBS Studio does a moment after a transition (follow-up of step 5b/5c)

A full live run after step 5c failed once in LiveActivityModelTests: the test asserted that the input of the old
scene was off the air right after AssertModelEqualsObsAsync, but OBS Studio takes those inputs off the air a moment
after the transition has ended, so both the model and OBS Studio could still say that the input was on it (the
comparison passed, the expectation did not). The three places where an input goes off the air after a transition
(a cut, the transition button of studio mode, a fade) now wait for it, bounded, and compare again.

events.md: the high-volume events section points to ObsModelOptions.HighVolume.

Tests: four tests of the model that raced with the machine, each made to wait for what it is about

Three runs of the CI of the stack failed on one test each, on three systems, and each passed on the other two: a race of the test, found and shown with the same test run many times, and not a flaw of the model.

  • ModelActivityTests.TheActivity_IsReadAgain_AfterTheConnectionIsMadeAgain: the test subscribed to Resynchronized after the connection was made and waited for the first one. The first read is announced after ConnectAsync
    has returned (the documentation of Resynchronized says so: add your handler before you connect), so the first announcement could be the one that the test took for the second read, and the camera was not off the air yet
    (macOS, 37 ms). The test subscribes before it connects (CallFixture.StartAsync and ModelRig.ConnectedAsync take what to subscribe to first), waits for the first announcement, and then for the second.
    ModelAudioLevelsTests.AHandlerThatIsSlowerThanOBSStudio had the same subscription, and asserted that Resynchronized was not raised at all: it counts the one of the first read now, and asserts that there is no other.
  • ModelAudioLevelsSessionTests.WhenTheContextRefusesTheNotification: the test waited until the notifier counted nothing as waiting, which happens a moment before the notifier tells the producer that it dropped the
    notification, so the next levels could come in between and find a notification still queued, and none was ever posted (Windows, a timeout of ten seconds). It waits for the callback that says so, as the test of the notifier does.
  • ModelGeometryOverSimulationTests.SetTransformAsync_IsShownByTheModel_WhenTheCallReturns (Hostile): the simulation delays events behind later responses, so the events of the first change can come after the read that
    followed the second, and for a moment say what the transform was before it (seen: rotation 0 for 150 ms, with OBS Studio holding 45, while the model had been read as equal a moment before). The model shows the right transform as soon as
    they have come, which the test now waits for, instead of asserting the equality in the instant in which it was asked.

Related issue

None.

Checklist

  • I followed the existing code style and patterns in neighboring files.
  • I added/updated XML doc comments for public API changes.
  • I added tests covering this change (or explained why none are needed).
  • I updated README.md if public API or behavior changed.
  • dotnet test OBSClient.Tests/OBSClient.Tests.csproj passes locally (any OS). The WinUI 3 test app is built by the WinUI 3 job of CI.

Validation

Each step was built and tested when it was committed (Release build without warnings, the unit suite green). The whole stack was checked at its last commit: unit suite 2225 passed, 82 skipped (the live tests), 0 failed. The live suite against a private --portable copy of OBS Studio 33.0.0 (obs-websocket 5.7.6) was 92 passed, 0 failed, and the coverage as CI measures it 96.0% of the lines and 92.0% of the branches of the hand-written code (floor 88 and 77), both at the commit of step 7; both are measured again on the final code before the release. dotnet pack and tools/verify-package.py pass; the docs build has no warnings and no broken link. CI repeats the build and the tests on Linux, Windows and macOS.

The last commits of each pull request answer what CI and the review found: the review of the first pull request (six findings, each fixed at its cause and covered by a test that fails without the fix), and tests that raced with a slow machine (each made to wait for what it is about, shown by running them many times, also with several copies at once on two cores).

@tinodo
tinodo force-pushed the model/steps-4-5 branch 2 times, most recently from a762127 to de03f1c Compare November 11, 2026 17:40
Base automatically changed from model/steps-1-3 to main November 11, 2026 17:52
@tinodo
tinodo requested a balanced review from Copilot November 11, 2026 18:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

A critical notification failure path can incorrectly clear the audio pending flag, allowing duplicate callbacks and potentially overflowing the notification queue.

5 open issues
What changed in this PR

Extends ObsModel with studio-mode controls, transitions, and opt-in tracking of scene-item transforms, input activity, and audio levels, building on the existing synchronized OBS client model.

Changes:

  • Adds preview-scene controls, transition state, and per-scene transition overrides.
  • Introduces optional high-volume tracking with coalesced audio-level notifications.
  • Expands simulation, model, and live-test coverage, updates documentation, and improves asynchronous test waits.
File Description
README.md Updates the model’s supported-feature overview.
OBSClient/​Model/​ObsTransitionOverride.cs Adds the scene transition-override snapshot.
OBSClient/​Model/​ObsTransition.cs Adds transition metadata snapshots.
OBSClient/​Model/​ObsSceneItemEventArgs.cs Adds scene-item event arguments.
OBSClient/​Model/​ObsSceneItem.cs Exposes tracked transforms and change detection.
OBSClient/​Model/​ObsScene.Writes.cs Adds preview switching and transition-override operations.
OBSClient/​Model/​ObsScene.cs Exposes preview-scene status.
OBSClient/​Model/​ObsModelOptions.cs Adds high-volume tracking options.
OBSClient/​Model/​ObsModel.StudioMode.cs Adds studio-mode control.
OBSClient/​Model/​ObsModel.Events.cs Adds selection and audio-level notifications.
OBSClient/​Model/​ObsModel.cs Integrates transitions, preview state, and subscriptions.
OBSClient/​Model/​ObsInput.cs Exposes activity and audio levels.
OBSClient/​Model/​ObsHighVolume.cs Defines opt-in tracking flags.
OBSClient/​Model/​ObsChannelLevel.cs Represents channel levels and decibel values.
OBSClient/​Model/​ObsChangedEventArgs.cs Supports transition change descriptions.
OBSClient/​Model/​ObsAudioLevelsEventArgs.cs Describes current and ended audio levels.
OBSClient/​Model/​ObsAudioLevels.cs Adds immutable per-input level snapshots.
OBSClient/​Model/​ModelView.cs Includes the preview scene in published state.
OBSClient/​Model/​ModelPublisher.cs Publishes new state and resolves item notifications.
OBSClient/​Model/​ModelNotifier.cs Reports notification admission and dropped posts.
OBSClient/​Model/​ModelHost.cs Configures subscriptions and routes audio levels.
OBSClient/​Model/​ModelAudioLevels.cs Maps, coalesces, and delivers meter updates.
OBSClient/​Model/​Engine/​TransitionInfo.cs Adds internal transition metadata.
OBSClient/​Model/​Engine/​Nodes.cs Stores activity, transforms, and pending selections.
OBSClient/​Model/​Engine/​ModelEngine.Views.cs Exposes new state and filters optional events.
OBSClient/​Model/​Engine/​ModelEngine.Snapshot.cs Extends snapshots with tracked state.
OBSClient/​Model/​Engine/​ModelEngine.Model.cs Handles activity readiness and preview removal.
OBSClient/​Model/​Engine/​ModelEngine.cs Schedules new reads and tracks synchronization.
OBSClient/​Model/​Engine/​ModelEngine.Collections.cs Resets collection-specific transition and preview state.
OBSClient/​Model/​Engine/​ModelChange.cs Defines new state-change kinds.
OBSClient/​Classes/​SceneItemTransform.cs Implements transform value equality.
OBSClient.Tests/​TestSupport/​TransformTexts.cs Formats transforms for precise comparisons.
OBSClient.Tests/​Simulation/​SimWorld.Levels.cs Simulates audio-meter ticks and ordering.
OBSClient.Tests/​Simulation/​SimWorld.Json.cs Serializes stored geometry and blend modes.
OBSClient.Tests/​Simulation/​SimWorld.Geometry.cs Simulates transforms, blending, and duplication.
OBSClient.Tests/​Simulation/​SimWorld.Collections.cs Preserves geometry across collection saves.
OBSClient.Tests/​Simulation/​SimWorld.Checks.cs Extends snapshots and activity invariants.
OBSClient.Tests/​Simulation/​SimWorld.Activity.cs Simulates source activity and studio-mode copies.
OBSClient.Tests/​Simulation/​SimView.cs Includes geometry and activity in comparisons.
OBSClient.Tests/​Simulation/​SimSnapshot.cs Extends simulation snapshot data and equality.
OBSClient.Tests/​Simulation/​SimShapeTests.cs Expands protocol-shape coverage checks.
OBSClient.Tests/​Simulation/​SimShape.cs Defines new event shapes and response exceptions.
OBSClient.Tests/​Simulation/​SimRequest.cs Adds explicit request-refusal support.
OBSClient.Tests/​Simulation/​SimReplay.cs Replays activity, preview, and transition events.
OBSClient.Tests/​Simulation/​SimProtocol.cs Defines additional subscription categories.
OBSClient.Tests/​Simulation/​SimObsRequestTests.cs Renames the initial studio-mode test.
OBSClient.Tests/​Simulation/​SimObs.cs Routes new events and exposes meter snapshots.
OBSClient.Tests/​Simulation/​SimLevelsTests.cs Tests simulated meter behavior.
OBSClient.Tests/​Simulation/​SimExternal.cs Exposes new simulated user operations.
OBSClient.Tests/​Simulation/​SimEntities.cs Stores geometry, activity, and meter state.
OBSClient.Tests/​Model/​ModelSimRig.cs Compares optional transforms and activity.
OBSClient.Tests/​Model/​ModelSettingsOverSimulationTests.cs Waits for asynchronous change notifications.
OBSClient.Tests/​Model/​ModelRig.cs Supports new reads and pre-connect handlers.
OBSClient.Tests/​Model/​ModelNotifierTests.cs Tests admission and dropped-post reporting.
OBSClient.Tests/​Model/​ModelEventTests.cs Checks opt-in subscription combinations.
OBSClient.Tests/​Model/​ModelEngineSimulationTests.cs Adds optional-state random-walk coverage.
OBSClient.Tests/​Model/​ModelEngineRetentionTests.cs Keeps retention testing independent of preview reads.
OBSClient.Tests/​Model/​ModelEngineEventTests.cs Covers newly handled engine events.
OBSClient.Tests/​Model/​ModelAudioLevelsSessionTests.cs Tests level-session isolation and notification recovery.
OBSClient.Tests/​Model/​ModelActivityTests.cs Tests activity state, events, and reconnection.
OBSClient.Tests/​Model/​ModelActivityOverSimulationTests.cs Tests activity through the full simulated stack.
OBSClient.Tests/​Model/​EngineHarness.cs Supplies fake transition, geometry, and activity responses.
OBSClient.Tests/​Model/​CallFixture.cs Supports subscriptions before connection.
OBSClient.Tests/​Live/​LiveModel.cs Compares new state and waits for idle transitions.
OBSClient.Tests/​Live/​LiveGeometryModelTests.cs Exercises geometry operations against OBS Studio.
docs/​articles/​two-ways.md Updates model capabilities and tracking costs.
docs/​articles/​requests.md Documents geometry validation and duplication behavior.
docs/​articles/​events.md Links high-volume events to model options.
CHANGELOG.md Records the new APIs and observed OBS behavior.

Review effort: Balanced

Comment thread OBSClient/Model/ModelNotifier.cs Resolved
Comment thread OBSClient.Tests/Live/LiveModel.cs Resolved
Comment thread OBSClient/Model/ModelHost.cs Resolved
tinodo and others added 8 commits November 11, 2026 19:55
…del (step 4 of making it complete)

ObsModel now has:

- studio mode: SetStudioModeEnabledAsync (IsStudioModeEnabled was there already), PreviewScene (null while
  studio mode is off), ObsScene.IsPreview and ObsScene.SwitchToPreviewAsync. OBS Studio makes the program scene
  the preview scene when studio mode is switched on and sends no event for it, so the model reads it then, and
  when it connects with studio mode on (and again on a new connection).
- Transitions (ObsTransitions, ObsTransition): Current, Duration and IsRunning are part of the model, with the
  events Started, Ended and VideoEnded. The calls SetCurrentAsync and SetDurationAsync return when the model
  shows the change, TriggerAsync when a transition has started; GetAllAsync, GetKindsAsync, GetSettingsAsync,
  SetSettingsAsync, GetProgressAsync and SetTBarPositionAsync ask and are not kept. A scene can bring a
  transition of its own (ObsTransitionOverride): GetTransitionOverrideAsync, SetTransitionOverrideAsync and
  ClearTransitionOverrideAsync.
- The program scene is the new scene from the start of a transition: OBS Studio answers a question about it
  with the scene that it goes to at once and announces it when the transition has ended, so the model reads it
  when a transition starts, and SwitchToAsync returns while the transition runs.

The model subscribes to the transition events (identify mask 1535) and reads the current transition when it
connects. A refusal to say the current transition is believed only when it repeats. A transition that is
cancelled ends without its video ending, which counts as its end, except for a stinger.

Measured with OBS Studio 33.0.0 (LiveTransitionTests): what a trigger does while a transition runs (it starts
another one in the first moment, while the position is still 0), the duration that belongs to the transitions,
the overrides, the T-bar, and that removing the program scene while studio mode is on stalls OBS Studio.

The simulation has studio mode, the preview scene and transitions (SimStudioModeTests); the engine, the model
and the live tests cover them, and the live comparison of the model with OBS Studio compares studio mode, the
preview scene, the current transition, its duration and whether one runs, and waits for OBS Studio to be idle.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ems and ObsHighVolume to ObsModel (step 5a of making it complete)

ObsModel now has:

- ObsModelOptions.HighVolume (ObsHighVolume, None by default): what the model follows of what OBS Studio sends many
  times a second, which every subscribed client pays for. ObsHighVolume.Transforms makes the model follow the
  transform of every scene item and subscribe to SceneItemTransformChanged (identify mask 1535 | 524288).
- The transform of a scene item: ObsSceneItem.Transform (SceneItemTransform?, null unless the model follows the
  transforms; PropertyChanged and Changed tell), GetTransformAsync (asks OBS Studio, always) and SetTransformAsync
  (a SceneItemTransformUpdate; returns when the model shows the change, or when OBS Studio has answered if the model
  does not follow). SceneItemTransform has value equality now.
- The blend mode: GetBlendModeAsync and SetBlendModeAsync (asked and not kept: OBS Studio announces no change of it).
- DuplicateAsync(destination): a copy on top of the scene, returned when the model shows it, with the crop (the last
  step that OBS Studio announces). ObsModel.SceneItemSelected (ObsSceneItemEventArgs) says that an item was selected;
  one that is selected before the model has told of it is told after it.

The engine keeps the transform as a cell of the item, handles SceneItemTransformChanged and SceneItemSelected, and
acts on an event of a high-volume type only when it is asked to follow it. The publisher tells what happened after the
objects of the pass are published.

Measured with OBS Studio 33.0.0 (LiveGeometryTests, LiveGeometryModelTests): a change of the position, scale, rotation,
alignment and bounds is announced at once; a crop and the size of a source only for a scene that OBS Studio renders
(a model that follows the transforms is behind for the others until they are, so SetTransformAsync and DuplicateAsync
read the scene again); a change with a crop is two events; a blend mode that is set sends the transform again, which
is no change; the size of an item is the size of its source times the scale. DuplicateSceneItem makes the copy in the
scene of the original when the destination is given by its UUID alone (obs-websocket reads the destination only when
the request has its name, and then the UUID wins), so the model gives both; the article about requests tells the plain
client to give the name.

The simulation has transforms, blend modes, copies and the checks of obs-websocket 5.7.6 (read from its source), and
keeps them when a scene collection is saved. The replay of the events tolerates a transition that a switch of the scene
collection cut off, and the walks make a media input before they play one and ask for the id of an item that is there.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
ObsHighVolume.Activity (and All = Transforms | Activity) makes the model read GetSourceActive for
every input and subscribe to InputActiveStateChanged and InputShowStateChanged. ObsInput.IsActive
and IsShowing are bool? (null unless followed); PropertyChanged and Changed tell each by itself.
A model that does not ask sends no request for it and does not subscribe.

Engine: an activity cell and scope per input, a read kind, event handlers (an event beats an older
read, a read sent after an event beats the event), an input is announced when its activity is
known, and a connection that was lost reads it again.

Checked with OBS Studio 33.0.0 / obs-websocket 5.7.6 (LiveActivityTests): a scene that goes on the
air puts its inputs on the air when the transition starts, the old scene's inputs go off after it
ends; nested scenes; the two events come in no fixed order; nothing is said of an input that OBS
destroys; in studio mode a copy of the program scene is on the air (what is done to the scene
itself does not reach it), the preview scene shows its inputs and does not put them on the air.

Simulation: SimWorld.Activity.cs (reachability through enabled items and nested scenes, a copy
of the scene on the air in studio mode), GetSourceActive, the two events, an invariant that the
stored state is what the scenes make it. Also: the preview scene is announced first when studio
mode is switched off (measured), and a scene removed during a studio-mode transition is not made
the preview scene (a latent bug that a shifted random stream reached).

Tests: engine (23), model (8), simulation (25), over the simulation (7 theories, 10 whole-stack),
live observation and live model (the model equals GetSourceActive after every step). Mutation
checks: ignoring the events, a read applied as an event, IsComplete without the activity, a missed
hook in the simulation, no copy in studio mode: all caught.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
ObsHighVolume.AudioLevels (and All = Transforms | Activity | AudioLevels) makes the model subscribe
to InputVolumeMeters. ObsInput.Levels (ObsAudioLevels?: the Input and its Channels, each an
ObsChannelLevel with Magnitude, Peak, InputPeak and their dB values) is what OBS Studio said of the
input in its last message: null unless followed and listed. ObsModel.AudioLevels
(ObsAudioLevelsEventArgs: Levels, Ended) says that new levels came. A model that does not ask does
not subscribe.

The levels are a stream and not state, so they bypass the engine: the receive loop of the client
maps each message to the inputs by UUID (ModelAudioLevels), writes ObsInput.Levels, and wakes ONE
notification that tells what changed since it last ran, with the newest levels. A handler that is
slower than OBS Studio gets the newest levels; the queue never fills; a message that says what the
previous one said is not told; the end of the connection takes all levels. ModelNotifier got
TryEnqueue (does it queue as it is?) and a Dropped hook (a notification that a context refused).

Checked with OBS Studio 33.0.0 / obs-websocket 5.7.6 (LiveLevelsTests, read in the source of
obs-websocket too): a message every 50 ms, also when empty; it lists the inputs that are on the
air and have audio, in the order of activation (the same set as IsActive and HasAudio); a muted
input is listed with magnitude and peak 0 and the peak of the input unchanged; the volume scales
magnitude and peak; an input that plays nothing is listed with zeros; the first message that lists
an input has no channels; a mono file is two channels; the first message with audio can say a
peak that is far too high (1.9 often, 2.7e20 once).

Simulation: SimWorld.Levels.cs (a tick sends a message; the order of activation; the volume and
mute applied as OBS does; the first message without channels), a walk op, an invariant that the
list is the inputs that are on the air and have audio. The weight of SetInputAudioTracks was raised
because the shifted random stream starved it.

Tests: model (10) and direct (8) for the levels, notifier (2), simulation (10), whole stack over the
simulation (19 incl. theories: Ideal, Real, Hostile; a lost connection; a switch of the scene
collection; levels and activity agree), live observation and live model (a tone of known loudness:
mono, stereo, mute, volume, pause, program switch, a slow handler). Mutation checks: no session
check, changes always told, no coalescing, ended not removed when listed again, flag never reset,
duplicates counted twice, Dropped hook not wired, end of connection takes nothing: all caught.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ter a transition (follow-up of step 5b/5c)

A full live run after step 5c failed once in LiveActivityModelTests: the test asserted that the input of the old
scene was off the air right after AssertModelEqualsObsAsync, but OBS Studio takes those inputs off the air a moment
after the transition has ended, so both the model and OBS Studio could still say that the input was on it (the
comparison passed, the expectation did not). The three places where an input goes off the air after a transition
(a cut, the transition button of studio mode, a fade) now wait for it, bounded, and compare again.

events.md: the high-volume events section points to ObsModelOptions.HighVolume.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
… to wait for what it is about

Three runs of the CI of the stack failed on one test each, on three systems, and each passed on the other two: a race of the test, found and shown with the same test run many times, and not a flaw of the model.

- ModelActivityTests.TheActivity_IsReadAgain_AfterTheConnectionIsMadeAgain: the test subscribed to Resynchronized after the connection was made and waited for the first one. The first read is announced after ConnectAsync
  has returned (the documentation of Resynchronized says so: add your handler before you connect), so the first announcement could be the one that the test took for the second read, and the camera was not off the air yet
  (macOS, 37 ms). The test subscribes before it connects (CallFixture.StartAsync and ModelRig.ConnectedAsync take what to subscribe to first), waits for the first announcement, and then for the second.
  ModelAudioLevelsTests.AHandlerThatIsSlowerThanOBSStudio had the same subscription, and asserted that Resynchronized was not raised at all: it counts the one of the first read now, and asserts that there is no other.
- ModelAudioLevelsSessionTests.WhenTheContextRefusesTheNotification: the test waited until the notifier counted nothing as waiting, which happens a moment before the notifier tells the producer that it dropped the
  notification, so the next levels could come in between and find a notification still queued, and none was ever posted (Windows, a timeout of ten seconds). It waits for the callback that says so, as the test of the notifier does.
- ModelGeometryOverSimulationTests.SetTransformAsync_IsShownByTheModel_WhenTheCallReturns (Hostile): the simulation delays events behind later responses, so the events of the first change can come after the read that
  followed the second, and for a moment say what the transform was before it (seen: rotation 0 for 150 ms, with OBS Studio holding 45, while the model had been read as equal a moment before). The model shows the right transform as soon as
  they have come, which the test now waits for, instead of asserting the equality in the instant in which it was asked.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…our tests wait for the record of a change

The model is current before it has told of a change: the properties are set by the loop of the model, and the records and the PropertyChanged events are raised a moment later by the notifier, on a thread of its own. The tests
that looked at a record or at what a handler was told right after the property changed passed on a quick machine, and failed on the runners of CI (one test in each run, never the same one):

- ModelRig.ConnectedAsync returns after Resynchronized, which is raised after everything that the first read made the model tell (the documentation says that the first read is announced after ConnectAsync has returned, and
  that a handler is to be added before the connection). A test that added its handlers right after it was told some of the first read: ModelCanvasesTests counted the PropertyChanged events of the canvases and got the
  "All" and "Main" of the first read in front of the one that it was about (macOS, step 7). The tests that need the first read in their handlers subscribe before the connection (the beforeConnect of the rig).
- ModelTransitionTests.SwitchingStudioModeOn asserted the record of the preview scene as soon as the preview scene was there (Ubuntu: "Filter not matched in collection"), and so did one test of the activity, one of the
  geometry and one of the settings over the simulation, after ConvergedAsync (which says that the model is what OBS Studio holds, not that the notifier has told of it). They wait for the record.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…is kept alive, the notification that was dropped, and three tests

Copilot's review of the second pull request had five findings. Four are fixed at their cause, each with a test that fails without the fix, and one is a limit of the simulation that is written down where the simulation has it.

- The levels of an input that OBS Studio removed and keeps alive. obs-websocket makes the meter of an input when it is activated and takes it away when it is deactivated, not when it is removed, so an input that was removed and is kept alive for a scene item that is on the air goes on being listed in InputVolumeMeters. The levels looked the inputs up in ObsModel.Inputs, which leaves out the ones that are Detached, so the next message ended the levels of such an input although OBS Studio still listed it. The view of the model has the inputs that OBS Studio still has (ModelView.AllInputs: the live ones, then the ones that are kept alive, the same array for as long as the set is the same), and the levels look the inputs up there.
- The notification that the context refused. ModelNotifier told the producer of the audio levels that a notification was dropped, for any notification, and the producer took it for its own and let the next levels queue another one while its own was still waiting in the context: the same levels were told twice. Dropped is given the notification now, and the producer lets go of what it waits for only when it is its own.
- The helper of the live tests that waits for an OBS Studio that is idle (AssertModelEqualsObsAsync) passed when the time was up while a transition still ran, as the model equalled OBS Studio. A transition that still runs when the time is up is a failure with that as the reason.
- ModelActivityOverSimulationTests.AnInputThatOBSStudioMakes_HasItsActivity_WhenTheModelTellsOfIt took what the notifier had told as soon as the model showed the input: on a busy machine the notification of the input (and the ones of the first read) were not told yet. It waits for the notification of the input.
- The simulation does not model that the private copy that studio mode puts on the air holds a reference to its sources (an input that loses its last scene item while the copy shows it is destroyed at once there, and stays alive in OBS Studio until the copy ends). It is written down in SimWorld.Activity.cs. It changes what the simulation announces in that one corner, and nothing of the library.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 18:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread OBSClient/Model/ModelPublisher.cs Resolved
Comment thread OBSClient/Model/ObsScene.Writes.cs Resolved
…ne item waits for its item, and a scene that is kept alive

Copilot's review of the push with the fixes of the first round had three findings more, all of code that was there before it. Each is fixed at its cause, with a test that fails without the fix.

- A selection of a scene item that was lost, and selections that overtook each other. An item that is made is selected at once, and the application is told of the selection after it was told that the item exists. The engine held the selection back until it had announced the item; but the item is published to the application only when its source is (a new input is complete after its settings were read, which can be some reads after the item list was), so the selection was let go of before the item was there, and the notification found no item and did nothing. And the engine had one place for the selection of each item, so a selection of an item that waited was told after the selection of an item that the application knew, which was selected later. The engine says what happened as it happens now (for an item that it has), and ModelPublisher keeps the selections that wait, in the order of arrival, until the application has been told of their item: a selection that waits holds back the selections after it, one of an item that is gone is dropped (it was removed, or the scene collection was left), and no more than 1000 wait.
- SetTransitionOverrideAsync of a scene that was removed and is kept alive. The call lets such a scene through (it exists), but it took the scene for gone when OBS Studio said that it has no transition of that name (600): the call ended with ObsRemovedException with the state Gone, and the model was reconciled as if the scene were gone. A scene is gone when its State is Gone, so the refusal is an ObsResponseException for a scene that is kept alive too, as it is for a live scene.

Tests: ASelection_OfANewItemThatTheModelCannotTellOfYet_IsToldOf_WhenTheItemIs and TheSelections_AreToldOf_InTheOrderOfArrival_AlsoWhenTheFirstOneWaitsForItsItem (OBS Studio is not ready to give the settings of the new input, so the item is read and its source is not complete), ATransitionForAScene_ThatOBSStudioDoesNotHave_IsAnObsResponseException_AlsoForARemovedSceneThatIsKeptAlive, and the engine test of a selection before the item is announced says now that the engine passes it on at once, and only once.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 19:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The transition-read logic counts unrelated failures toward repeated refusals, which can incorrectly clear the current transition and stop retries until another event triggers a read.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

High severity Track consecutive no-transition refusals separately from retry attempts

OBSClient/​Model/​Engine/​ModelEngine.Reads.cs:781

Two NotReady replies or failed reads followed by a single transient refusal satisfy this condition because all retries increment scope.Attempts. The branch then publishes a null current transition and completes the read without retrying, potentially leaving the model without a transition until another event triggers a read. Track consecutive refusals indicating no transition separately from retry attempts, resetting that streak on other outcomes and session or collection changes.

Medium severity Replace repeated linear input checks with a per-message HashSet

OBSClient/​Model/​ModelAudioLevels.cs:124

The duplicate check here and the membership check at line 144 scan levels linearly, performing n² identity comparisons for n inputs present in consecutive messages. This work runs twenty times a second on the client's receive loop under _gate, increasing processing time for large active audio graphs. Use a per-message HashSet<ObsInput> for both membership checks, retaining the list for output order.

3 resolved since last review

Review effort: Balanced

@tinodo
tinodo merged commit 2fe457a into main Nov 11, 2026
14 checks passed
@tinodo
tinodo deleted the model/steps-4-5 branch November 11, 2026 19:28
tinodo added a commit that referenced this pull request Nov 11, 2026
…6 and 7) (#97)

Steps 6 and 7 of making `ObsModel` complete, on top of steps 1 to 5 (#95 and #96). Everything is additive.

**Step 6a, profiles and scene collections.** `obs.Profiles` and `obs.SceneCollections` show which profile is current, which scene collection is loaded, and the names of all in the order of OBS Studio (`INotifyPropertyChanged`, and a record for `Changed`). `SetCurrentAsync` and `CreateAsync` (both) and `RemoveAsync` (profiles) return when the model shows the change, and for a scene collection when the model has read it: OBS Studio answers `SetCurrentSceneCollection` when it has loaded the collection, so the call waits as long as `SynchronizationTimeout` when that is more than `WriteTimeout`. The lists are read, never taken from an event. A switch of the scene collection reads everything again and what the application holds is `Gone`; the model also takes a switch from a read of the list that names another collection (the events were lost or are late), and the late events of that switch are not a second one. A collection that the user renamed is the same collection.

**Step 6b, the settings of OBS Studio itself.** Video settings, the stream service, the folder for recordings, the parameters of a profile and the persistent data: each call asks or tells and ends when OBS Studio has answered, in the order of the calls. OBS Studio announces no change of any of it, so the model keeps none of it.

**Step 7, canvases.** `obs.Canvases` (`ObsCanvases`, `ObsCanvas` snapshots, `GetVideoSettingsAsync`), checked against OBS Studio 33.0.0 with a script that makes, renames and removes canvases. A canvas that OBS Studio removed leaves the model at once, however long OBS Studio goes on listing it. A snapshot is of the scene collection that was loaded when it was made: after a switch it is of a canvas that is gone, also when the collection that is loaded has a canvas with the same UUID (the main canvas has the same in every collection).

Also in this pull request: the settings of a filter that a server says changed are told to the application, a preview scene that a server refuses for good is none, a value that is null is an `ArgumentNullException` for the persistent data, and the live tests (the activity test waits for four more inputs, the test of the main canvas needs permission to change OBS Studio, the test of the scene collections loads the collection that was loaded when it ends).

**The review of the pull request, 6 findings in three rounds,** all fixed at their cause with a test that fails without the fix. The scene collection calls were done when the list said the name, also on a model that still held the scenes of the old collection (the model took a switch from the events alone): a read that names another collection is a switch now, and the events that come late for it are not a second one. `CreateAsync` ended with a weaker check than the one that says the model shows the change. A canvas snapshot of a collection that was left no longer gives the video of the canvas that has the same UUID in the collection that is loaded. The live fixture that changes OBS Studio needs permission to, and the live test that loads another collection loads the first one again when it ends.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants