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

[BUG] Hue & Saturation mode transition failed #36772

Open
xshuqun opened this issue Dec 10, 2024 · 3 comments
Open

[BUG] Hue & Saturation mode transition failed #36772

xshuqun opened this issue Dec 10, 2024 · 3 comments
Labels
bug Something isn't working darwin needs triage

Comments

@xshuqun
Copy link

xshuqun commented Dec 10, 2024

Reproduction steps

Facing a problem with Adaptive Lighting transiting to another color option

Some information about DUT:

  1. DUT is using FreeRTOS and LwIP.
  2. Thread priority: CHIP is 2 and LwIP is 9.
  3. Messages received at through LwIP and has higher priority, so Postevent will take place.

After investigating the SDK, I observed the following:

  1. The DUT is set to Adaptive Lighting by selecting it on the Homekit GUI.
  2. Homekit sends a CommandRequest for moveToColorTemp and DUT handles callback updateTempCommand to set color temp.
  3. Once the transition stabilizes, the DUT continuously triggers updateTempCommand.
  4. A HueSaturation color option is selected on the Homekit GUI.
  5. Homekit sends a CommandRequest moveToHueAndSaturation and DUT receives it + register timer with scheduleTimerCallbackMs for updateHueSatCommand.
  6. Some Messages (for ReadRequest or other request) are received, which triggers PostEvent and added to the task queue (duplicate message packets are also observed).
  7. The DUT enters RunEventLoop and continuously processes the task queue.
  8. Homekit sends a CommandRequest to stopAllColorTransitions (sent by Apple on time, regardless of whether the DUT has completed the transition, I assumed).
  9. The DUT handles stopAllColorTransitions and cancels/stops all ongoing timers for color control.
  10. The DUT fails to complete the color transition.

Basically, before the DUT is able to handle the active timer, Homekit has sent another CommandRequest to stop all color transition and cancel all the timers.

Expected outcome:

  1. The DUT is set to Adaptive Lighting by selecting it on the Homekit GUI.
  2. Homekit sends a CommandRequest for moveToColorTemp and DUT handles callback updateTempCommand to set color temp.
  3. A HueSaturation color option is selected on the Homekit GUI.
  4. Homekit sends a CommandRequest moveToHueAndSaturation and DUT receives it + register timer with scheduleTimerCallbackMs for updateHueSatCommand.
  5. DUT triggers callback updateHueSatCommand and change Hue + Saturation.

I have attached the DUT with analysis of how FreeRTOS queue is being handled.
[1] DUT_adaptive_lighting_success_logs.txt
[2] DUT_adaptive_lighting_failed_logs.txt

This is a slight video on the operation using Homekit:
[1] https://github.com/user-attachments/assets/9edbafef-4ed0-4b2d-9e3c-dfbea94c19ca

Bug prevalence

always

GitHub hash of the SDK that was being used

master

Platform

ameba

Platform Version(s)

No response

Anything else?

No response

@xshuqun xshuqun added bug Something isn't working needs triage labels Dec 10, 2024
@xshuqun xshuqun changed the title [BUG] Adaptive Lighting mode to Hue & Saturation mode transition failed [BUG] Hue & Saturation mode transition failed Dec 10, 2024
@bzbarsky-apple
Copy link
Contributor

@xshuqun So are you claiming this is a problem with the server (and if so, what exactly is the problem), or with the client (HomeKit) sending the wrong commands?

@xshuqun
Copy link
Author

xshuqun commented Dec 12, 2024

@xshuqun So are you claiming this is a problem with the server (and if so, what exactly is the problem), or with the client (HomeKit) sending the wrong commands?

@bzbarsky-apple Apparently, I think the server hit a corner case where there is insufficient time to execute the necessary command.
However, whether the client is sending these command correctly, I am uncertain.

I had provided details in the description, where server (using FreeRTOS) has to clear its queue before handling active timer, but before the server could handle the timer, it was cancelled by the next command sent by the client.

I would like some advise if this can be handled in another way or other solutions? (e.g., Like handling the active timer first and clearing the queue?)

@bzbarsky-apple
Copy link
Contributor

@xshuqun Honestly, to me it sounds like the client is doing something wrong (stopping transitions before they have finished) and that you should report this issue to Apple....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working darwin needs triage
Projects
None yet
Development

No branches or pull requests

2 participants