Consolidate smart source websocket subscriptions.#5899
Open
michelinewu wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR consolidates Smart Browser Source websocket event handling and Vision startup coordination into ReactiveDataService to avoid per-source websocket subscriptions (and the associated IPC overhead) in the renderer process.
Changes:
- Added a
SourcesViews.getSmartSources()helper to retrieve smart browser sources bypropertiesManagerType. - Removed per-source websocket subscription +
visionService.ensureRunning()startup fromSmartBrowserSourceManager. - Subscribed once in
ReactiveDataServiceto forwardvisionEvent/userStateUpdatedevents to all smart sources, and added a guard to reduce redundant Vision startup calls.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| app/services/sources/sources.ts | Adds a view helper to find smart browser sources by manager type for centralized fan-out. |
| app/services/sources/properties-managers/smart-browser-source-manager.ts | Removes per-source websocket subscription and Vision startup, leaving URL normalization only. |
| app/services/reactive-data/index.ts | Centralizes websocket forwarding to smart sources and introduces guarded Vision startup logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
BundleMonFiles added (4)
Total files change +12.56MB Final result: ✅ View report in BundleMon website ➡️ |
…s, fire-and-forget vision running check.
gettinToasty
approved these changes
May 6, 2026
wesrupert
approved these changes
May 6, 2026
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.
Use ReactiveDataService for smart source socket events
Issue
Each
SmartBrowserSourceManagerindependently subscribed to the websocket and calledvisionService.ensureRunning()on init. With N smart browser sources active, this created N parallel socket subscriptions all listening for the samevisionEvent/userStateUpdatedevents and N redundant Vision startup calls.Fix
Moved event forwarding and Vision startup out of
SmartBrowserSourceManagerand intoReactiveDataService, which already had a single socket subscription.Performance comparison
sendMessagecalls per eventvisionService.ensureRunning()calls on startupdestroy()/ unsubscribe overheadsocketSub.unsubscribe()per source)Renderer process performance
SmartBrowserSourceManagerruns in the renderer process. EverywebsocketService.socketEventsubscription it created was backed by an IPC listener — each incoming websocket event triggered a separate IPC message delivery for each subscribed source.With the subscription consolidated into
ReactiveDataService(main process side), the IPC crossing happens once per event regardless of how many smart sources are loaded. The renderer receives a single delivery;forwardEventToSources()then fans out viaobsSource.sendMessage(), which is a synchronous in-process call with no further IPC overhead.Additionally, each
visionService.ensureRunning()call from a source manager on init crossed the IPC boundary to check and start Vision. TheensureVisionRunning()guard readsisRunning/isStartingfrom local state before calling through, eliminating redundant IPC round-trips when Vision is already up.