Repository navigation
Conversation
This branch has not been deployed
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.
Small one, found while working on the secure video controller but not specific to it.
What happens
ControllerStorage.restoreControllercallscontroller.deserialize(), and most controllers restore their state throughupdateCharacteristic. That emitsCHANGE. A controller listening on its own characteristics (or on a service it shares with another controller) reports a state change from inside the restore,handleStateChangeserialises the controller mid-way and overwrites the stored data with the partially restored state. Whatever the controller restores after that point is gone on the next save.CameraControllerdoesn't trip over this because its listeners only react to HAP writes, but anySerializableControllerthat usesCHANGElisteners does.Fix
A
restoringflag onControllerStorage, set arounddeserialize()and around the initial restore loop ininit(). State changes reported while it's set are ignored. The characteristics keep their restored values, only the write-back is skipped.Test
ControllerStorage.spec.tsrestores a controller that reports a state change halfway through itsdeserialize()and checks that the stored data is still complete, and that a real state change afterwards is picked up as usual.