You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(channels): preserve buffers still owned by an earlier frame - #5473
The clockless and SPI legacy bridges can route a frame to a different driver while the previous driver still owns the shared ChannelData. The new driver's READY state does not release the previous frame's buffer. Check ChannelData ownership again after the bounded wait and skip encoding while the buffer remains in use.
Both focused sanitizer tests reproduced the unsafe enqueue before the fix.
Changed-file lint passed.
Final sanitizer, full host C++, and ESP32-C6 RMT loopback validation are running.
Summary by CodeRabbit
Bug Fixes
Improved handling of frames while a previous transfer is still in progress. New frames are now held until the data is available, or dropped if the transfer does not become ready, helping prevent outdated or overlapping frame data from being sent.
Updated behavior across both standard and SPI bridge channels so busy buffers are not reused prematurely.
CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.
Parsing warnings: 1
Validation error: Unrecognized key: "enabled" at "reviews.pre_merge_checks"
If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Walkthrough
Both slim bridge controllers now drop a frame if the driver is not ready or the channel data remains in use after the readiness wait. Tests cover busy-buffer handling, fallback behavior, and retrying after the data becomes available.
Changes: In-flight channel data guard
Layer / File(s)
Summary
Guard channel data before reuse src/fl/channels/slim_bridge_controller.h, src/fl/channels/slim_spi_bridge_controller.h, tests/unit/fl/channels/slim_bridge_controller.cpp, tests/unit/fl/channels/spi_channel.cpp
Both controllers drop a frame if readiness fails or channel data remains in use. Tests check that busy data is not reused or enqueued, and that a retry can enqueue after the data becomes available.
This change stops a frame from overwriting a buffer that an earlier driver still owns when the bridge routes to a different driver. No concrete defect remains in the production change. The only open comments are optional test-style suggestions.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the fix type and scope and states the main change: buffers still owned by an earlier frame are preserved. The changeset rechecks ChannelData ownership after the bounded wait in SlimBri…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the fix type and scope and states the main change: buffers still owned by an earlier frame are preserved. The changeset rechecks ChannelData ownership after the bounded wait in SlimBridgeController::showPixels and SlimSpiBridgeController::showPixels, and drops the frame when the buffer remains in use. The title is specific and matches the primary change. Its 63-character length is acceptable.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 2
tests/unit/fl/channels/spi_channel.cpp: 1
613-613: Trivial · Maintainability & Code Quality · Heavy lift
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Exercise SPI ownership through a real driver.
SpiCaptureMock::poll() always returns READY and never releases ownership. These direct flag writes test the guard but cannot test actual driver completion. Use a real driver implementation to acquire ownership, complete the frame, and release ownership before the successful retry.
As per coding guidelines, “No mocks — test real implementations.”
398-399: Trivial · Maintainability & Code Quality · Heavy lift
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Use a real driver for the ownership regression.
The added case uses SlimBridgeMockDriver and sets ownership directly. The later manual release bypasses the completion path that must make fallback recovery possible. Add a regression with a real driver implementation that acquires and releases ownership. Verify buffer preservation during ownership and successful fallback after completion.
As per coding guidelines, “No mocks — test real implementations.”
Reviewing files that changed from the base of the PR and between ec53bae and b36530c.
Files selected for processing: 4
src/fl/channels/slim_bridge_controller.h
src/fl/channels/slim_spi_bridge_controller.h
tests/unit/fl/channels/slim_bridge_controller.cpp
tests/unit/fl/channels/spi_channel.cpp
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
Change in examples/Blink per target. The left number is this PR's image flash / attributed RAM in bytes; the colored delta is the change from the merge base (red ↑ is larger, green ↓ is smaller, Same is unchanged).
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
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.
Summary
The clockless and SPI legacy bridges can route a frame to a different driver while the previous driver still owns the shared ChannelData. The new driver's READY state does not release the previous frame's buffer. Check ChannelData ownership again after the bounded wait and skip encoding while the buffer remains in use.
Follow-up to #5356.
Validation
Summary by CodeRabbit