Consolidate smart source websocket subscriptions. (Rebased) - #6029
Open
michelinewu wants to merge 12 commits into
Open
Consolidate smart source websocket subscriptions. (Rebased)#6029michelinewu wants to merge 12 commits into
michelinewu wants to merge 12 commits into
Conversation
…s, fire-and-forget vision running check.
BundleMonFiles updated (1)
Unchanged files (3)
Total files change -251B 0% Final result: ✅ View report in BundleMon website ➡️ |
wesrupert
reviewed
Jul 17, 2026
Co-authored-by: Wes Rupert <wesrupert@users.noreply.github.com>
Co-authored-by: Wes Rupert <wesrupert@users.noreply.github.com>
Co-authored-by: Wes Rupert <wesrupert@users.noreply.github.com>
wesrupert
reviewed
Jul 17, 2026
| UserService, | ||
| WebsocketService, | ||
| } from 'app-services'; | ||
| import { VisionService } from 'services/vision'; |
Contributor
There was a problem hiding this comment.
Suggested change
| import { VisionService } from 'services/vision'; |
wesrupert
reviewed
Jul 17, 2026
Co-authored-by: Wes Rupert <wesrupert@users.noreply.github.com>
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.
Consolidate smart source websocket subscriptions
Note
Replaces Consolidate smart source websocket subscriptions. #5899
Issue
Each
SmartBrowserSourceManagerindependently subscribed to the websocket and calledvisionService.ensureRunning()on init. With N smart browser sources active, this created N parallel RxJS subscriptions to the samevisionEvent/userStateUpdatedevents and N redundant Vision startup calls.Fix
Moved event forwarding and Vision startup out of
SmartBrowserSourceManagerand intoReactiveDataService, which already held a single socket subscription:ReactiveDataServicenow forwardsvisionEvent/userStateUpdatedevents to every smart source viaforwardEventToSources().ensureVisionRunning(), which readsisRunning/isStartingfrom local state and only callsvisionService.ensureRunning()when Vision is not already up.SmartBrowserSourceManagerloses its ownsocketSubsubscription, itsWebsocketServiceinjection, and itsdestroy()unsubscribe.Smart-source lookup helpers (
SourcesService)Added two helpers used by the centralized path:
hasSmartSources()— cheap existence check (Array.someonpropertiesManagerType === 'smartBrowserSource'); used to guard Vision startup on login and on scene-collection switch so we don't start Vision for collections with no smart sources.getSmartSources()— filters the source models bypropertiesManagerTypebefore constructingSourceinstances, so the hot fan-out path (forwardEventToSources, which can fire frequently while live) avoids buildingSourceobjects for non-smart sources.What changed
ReactiveDataService)getSmartSources()→obsSource.sendMessage()visionService.ensureRunning()on startuphasSmartSources()) and on first source registration, skipped when Vision is already running/startingdestroy()/ unsubscribe overheadsocketSub.unsubscribe()per source)All of the above runs in the worker window — the invisible renderer that hosts the services layer and the OBS backend.
WebsocketService,VisionService,SourcesService, andReactiveDataServiceare all singleton services, andsocketEventis a plain RxJSSubjectonWebsocketService, so these subscriptions andsendMessage()/ensureRunning()calls are in-process RxJS / OBS calls, not per-source IPC. The win is eliminating redundant in-process subscriptions and duplicate Vision startup work, plus a single centralized fan-out — not a reduction in IPC crossings.Files touched
app/services/reactive-data/index.ts— centralized subscription + forwarding,ensureVisionRunning(),forwardEventToSources(), login/collection-switch guards.app/services/sources/properties-managers/smart-browser-source-manager.ts— removed per-source subscription, injection, anddestroy().app/services/sources/sources.ts— addedgetSmartSources()andhasSmartSources().