-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[CameraAVSettings] Change response generation to be based on completion of physical PTZ actions #40565
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
base: master
Are you sure you want to change the base?
[CameraAVSettings] Change response generation to be based on completion of physical PTZ actions #40565
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the PTZ command handling to be asynchronous, using a callback to signal the completion of physical device movements. This change aligns with specification requirements and improves the handling of concurrent commands by introducing a 'Busy' state. The implementation introduces a PhysicalPTZCallback
interface and correctly updates the delegate methods and server logic. The changes are well-structured and address the goals outlined in the description. I have a few suggestions to improve maintainability and fix a minor issue in the example implementation.
...pp/linux/src/clusters/camera-avsettingsuserlevel-mgmt/camera-avsettingsuserlevel-manager.cpp
Show resolved
Hide resolved
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
...a-av-settings-user-level-management-server/camera-av-settings-user-level-management-server.h
Outdated
Show resolved
Hide resolved
PR #40565: Size comparison from 900f8c0 to 78dfce8 Full report (29 builds for bl602, bl702, bl702l, cc32xx, efr32, nrfconnect, psoc6, qpg, stm32, telink, tizen)
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #40565 +/- ##
==========================================
- Coverage 50.72% 50.69% -0.03%
==========================================
Files 1356 1356
Lines 99337 99410 +73
Branches 12876 12902 +26
==========================================
+ Hits 50390 50399 +9
- Misses 48947 49011 +64 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
PR #40565: Size comparison from 900f8c0 to e07ad8c Full report (57 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
…trayer/connectedhomeip into cameravsettings-issue-40491
This reverts commit b474d9c.
This reverts commit b474d9c.
PR #40565: Size comparison from 233d3f7 to 7e5a2c7 Full report (33 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, nrfconnect, psoc6, qpg, realtek, stm32, telink)
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the handling of physical PTZ commands to be asynchronous, using a callback to signal completion. This is a significant improvement, aligning with the specification requirements and allowing for better handling of busy states. A new MovementState
attribute is introduced to track the camera's physical movement, which is a great addition for state management. The changes are comprehensive, updating the server implementation, example applications, and test scripts accordingly.
My review has identified a few areas for improvement. There are a couple of potential null pointer dereferences in the example/stub code that should be addressed for robustness. I also found an inconsistency in how the new MovementState
attribute is updated, which could lead to reporting issues. Additionally, there are several typos in comments and documentation that should be corrected for clarity. The Python test updates are well-implemented to handle the new asynchronous flow, though I noticed a minor copy-paste error in one of the test scripts.
...s/all-clusters-app/all-clusters-common/src/camera-av-settings-user-level-management-stub.cpp
Outdated
Show resolved
Hide resolved
...pp/linux/src/clusters/camera-avsettingsuserlevel-mgmt/camera-avsettingsuserlevel-manager.cpp
Outdated
Show resolved
Hide resolved
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
.../linux/include/clusters/camera-avsettingsuserlevel-mgmt/camera-avsettingsuserlevel-manager.h
Outdated
Show resolved
Hide resolved
...pp/linux/src/clusters/camera-avsettingsuserlevel-mgmt/camera-avsettingsuserlevel-manager.cpp
Outdated
Show resolved
Hide resolved
...pp/linux/src/clusters/camera-avsettingsuserlevel-mgmt/camera-avsettingsuserlevel-manager.cpp
Outdated
Show resolved
Hide resolved
...a-av-settings-user-level-management-server/camera-av-settings-user-level-management-server.h
Outdated
Show resolved
Hide resolved
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
...a-av-settings-user-level-management-server/camera-av-settings-user-level-management-server.h
Outdated
Show resolved
Hide resolved
...a-av-settings-user-level-management-server/camera-av-settings-user-level-management-server.h
Outdated
Show resolved
Hide resolved
src/app/zap-templates/zcl/data-model/chip/camera-av-settings-user-level-management-cluster.xml
Show resolved
Hide resolved
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
// | ||
DeviceLayer::SystemLayer().ScheduleLambda([callback] { callback->OnPhysicalMovementComplete(Status::Success); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, so if the cluster gets torn down while this lambda is pending.... It's pretty dangerous for apps to copy this pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would the preferred pattern be for the all-clusters stub?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have a few options (both here and in CameraAVSettingsUserLevelManager over in camera-app):
- Keep track of the cluster lifetime somehow in the app code, check that it's alive inside the lambda/timer callback before invoking things on it.
- Fix
CameraAvSettingsUserLevelMgmtServer
tomDelegate.SetServer(nullptr)
inCameraAvSettingsUserLevelMgmtServer
(probably a good idea anyway, to avoid use-after-free), then check thatGetServer()
is not null when the lambda runs or the timer fires. Of course that then pushes the problem a bit further out: you have to make sure the delegate you call GetServer() on is not destroyed at that point.
PR #40565: Size comparison from 233d3f7 to 9ecd726 Full report (37 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
|
PR #40565: Size comparison from 233d3f7 to b2e2a5f Full report (37 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
|
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
@@ -72,98 +72,96 @@ CHIP_ERROR CameraAvSettingsUserLevelMgmtServer::Init() | |||
|
|||
// All of the attributes are dependent on Feature Flags being set, ensure that this is the case | |||
// | |||
if (SupportsOptAttr(OptionalAttributes::kMptzPosition)) | |||
if (SupportsOptAttr(OptionalAttributes::kMptzPosition) != |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a followup: instead of having this setup where the cluster can be mis-configured, why not just remove the concept of OptionalAttributes::kMptzPosition and use the feature flags directly instead wherever it's being used right now?
Same for the other bits.
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
...av-settings-user-level-management-server/camera-av-settings-user-level-management-server.cpp
Outdated
Show resolved
Hide resolved
...a-av-settings-user-level-management-server/camera-av-settings-user-level-management-server.h
Outdated
Show resolved
Hide resolved
// | ||
DeviceLayer::SystemLayer().ScheduleLambda([callback] { callback->OnPhysicalMovementComplete(Status::Success); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have a few options (both here and in CameraAVSettingsUserLevelManager over in camera-app):
- Keep track of the cluster lifetime somehow in the app code, check that it's alive inside the lambda/timer callback before invoking things on it.
- Fix
CameraAvSettingsUserLevelMgmtServer
tomDelegate.SetServer(nullptr)
inCameraAvSettingsUserLevelMgmtServer
(probably a good idea anyway, to avoid use-after-free), then check thatGetServer()
is not null when the lambda runs or the timer fires. Of course that then pushes the problem a bit further out: you have to make sure the delegate you call GetServer() on is not destroyed at that point.
Co-authored-by: Boris Zbarsky <[email protected]>
PR #40565: Size comparison from 233d3f7 to 4c6a936 Increases above 0.2%:
Full report (16 builds for efr32, esp32, nrfconnect, nxp, telink)
|
…trayer/connectedhomeip into cameravsettings-issue-40491
Summary
Spec requires that the status response to a command that physically changes PTZ occurs once the physical move has completed. The code was doing this by having the app sit and spin on the event loop till this was completed. Which could be some time. Change the code so that the app leverages a callback provided by the server once the command has been executed physically. Also allows for more coherent support of the Busy response (i.e. sent when a command is in process). Additionally a new attribute (MovementState) has been added in the spec, include the Alchemy regenerated XML and new Zap regen. Update the cluster to support this attribute and it's logic with respect to PTZ commands (physical).
Update test scripts to subscribe to MovementState.
Testing
Re-run the updated AVSUM tests via the Python Runner.
Verify via Chip Tool that a subsequent command is rejected with Busy prior to the initial PTZ command initiated action completing. .
Readability checklist
The checklist below will help the reviewer finish PR review in time and keep the
code readable:
descriptive
“When in Rome…”
rule (coding style)
See: Pull Request Guidelines