Cache latest frame to support multiple concurrent consumers - #54
Open
oliviamiller wants to merge 2 commits into
Open
Cache latest frame to support multiple concurrent consumers#54oliviamiller wants to merge 2 commits into
oliviamiller wants to merge 2 commits into
Conversation
…rames Previously every get_images call pulled a sample directly from the appsink, which dequeues it: with N consumers each frame went to exactly one caller and everyone else blocked until the next frame arrived (up to 1/frame_rate seconds). Now the appsink new-sample callback stores each frame in a shared latest-frame cache and consumers read the cache, so any number of clients get the most recent frame immediately. Follows the pattern used by viam-camera-realsense: frames are stamped with their actual capture time (now reported as captured_at), and get_images throws if the cached frame is older than 3 frame intervals so a stalled pipeline surfaces as an error instead of serving a stale image. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
oliviamiller
marked this pull request as ready for review
August 24, 2026 15:16
Naveed Jooma (njooma)
approved these changes
Aug 24, 2026
|
Don't have hardware, but code looks reasonable |
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.
Right now
get_imagespulls straight from the appsink, and pulling a sampleconsumes it. So with more than one consumer, whoever asks first takes the
frame and everyone else sits waiting for the next one — at 1 fps that's seconds of
waiting per client.
This changes it so the appsink callback keeps the newest frame in a cache and
get_imagesjust reads from that. Any number of clients can grab the latestframe without stealing it from each other. Same approach as realsense and orbbec modules.