Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reset atem upon connection #307

Merged
merged 4 commits into from
Dec 6, 2023
Merged

Conversation

mint-dewit
Copy link
Contributor

This is a bug fix.

Expected behaviour

The atem integration will initiate correctly and enforce its state.

Observed behaviour

The atem integration does a state diff before it has connected to the actual device. This returns no commands. The State Handler than transitions to this state and expects it to be current.

Once the device is connected, a resetResolver is called. This does not reset the state itself causing it to diff against an incorrect current state and will again return no commands

Proposed fix

Add a method to update the current state in the State Handler on the context. In addition, chane the resetState context method to change the current state to undefined

@mint-dewit mint-dewit requested a review from a team November 30, 2023 09:34
@codecov-commenter
Copy link

codecov-commenter commented Nov 30, 2023

Codecov Report

Attention: 8 lines in your changes are missing coverage. Please review.

Comparison is base (006c8e8) 40.77% compared to head (83a8945) 40.75%.

Files Patch % Lines
...eline-state-resolver/src/service/DeviceInstance.ts 16.66% 5 Missing ⚠️
...line-state-resolver/src/integrations/atem/index.ts 25.00% 3 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           release51     #307      +/-   ##
=============================================
- Coverage      40.77%   40.75%   -0.03%     
=============================================
  Files            105      105              
  Lines          10001    10009       +8     
  Branches        2463     2464       +1     
=============================================
+ Hits            4078     4079       +1     
- Misses          5387     5394       +7     
  Partials         536      536              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

},

resetToState: async (state: any) => {
await this._stateHandler.setCurrentState(state)
await this._stateHandler.clearFutureStates()
this.emit('resetResolver')
Copy link
Member

Choose a reason for hiding this comment

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

This isn't something to fix now, but doesn't calling this.emit('resetResolver') result in clearing the state of every device and rebuilding it all from the timeline again?
That feels like a rather heavy operation to do whenever a device manages to connect, especially as the states returned by the resolver will not be different to before.
Perhaps something in each service could cache the states as given by the resolver, so that resetState and resetToState can reuse those instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, i think we have enough data in the statehandler class to just handle rebuilding the device states and diffs in there without going to the conductor. Definitely one to consider.

resetState: () => Promise<void>

/** Reset the tracked device state to "state" and notify the conductor to reset the resolver */
resetToState: (state: any) => Promise<void> // todo - types?
Copy link
Member

Choose a reason for hiding this comment

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

Unresolved TODO
I agree it would be good to have the type of the state to be known here. It will probably be a bit sprawling, but should be easy enough to do as a generic parameter to this interface

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My initial worry was that we already use a lot of generics and it does become a bit of a sprawl but in this case it's only a few places that need to be aware actually.

@mint-dewit mint-dewit merged commit f2474b9 into release51 Dec 6, 2023
36 checks passed
@Julusian Julusian deleted the fix/atem-reset-on-conn branch June 27, 2024 09:42
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.

3 participants