Skip to content

Conversation

@AdvancedImagingUTSW
Copy link
Collaborator

When in live mode, drain any queued frames from show_img_pipe so only the most recent image is processed, preventing visible display lag from a pipe backlog. Count dropped frames, log a debug message when frames are dropped, and include dropped frames in images_received. Preserve existing handling for the "stop" sentinel and non-int image ids.

When in live mode, drain any queued frames from show_img_pipe so only the most recent image is processed, preventing visible display lag from a pipe backlog. Count dropped frames, log a debug message when frames are dropped, and include dropped frames in images_received. Preserve existing handling for the "stop" sentinel and non-int image ids.
@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.52%. Comparing base (56b9a0c) to head (b450929).

Files with missing lines Patch % Lines
src/navigate/controller/controller.py 50.00% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1173   +/-   ##
========================================
  Coverage    52.51%   52.52%           
========================================
  Files          197      197           
  Lines        23976    23985    +9     
========================================
+ Hits         12592    12597    +5     
- Misses       11384    11388    +4     
Flag Coverage Δ
unittests 52.52% <50.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds frame dropping logic to prevent display lag during live image acquisition. When the image processing pipeline cannot keep up with the frame rate, queued frames accumulate in the pipe, causing visible lag. The PR addresses this by draining old frames and displaying only the most recent frame when in live mode.

Changes:

  • Added frame draining logic in live mode that skips queued frames to process only the most recent one
  • Added counter and debug logging for dropped frames
  • Updated images_received to include dropped frames in the total count

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

image=self.data_buffer[image_id]
)
images_received += 1
images_received += 1 + dropped_frames
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including dropped_frames in images_received may be semantically incorrect. The variable name suggests it counts images that were actually received and processed, but dropped frames are explicitly NOT processed (they're skipped to reduce lag). This could lead to confusion or incorrect reporting of how many images were actually displayed. Consider whether images_received should only count processed images, and track dropped frames separately if needed for reporting purposes.

Suggested change
images_received += 1 + dropped_frames
images_received += 1

Copilot uses AI. Check for mistakes.
Comment on lines 1221 to 1228
if mode == "live":
# Drain queued frames so we only process the most recent one.
# This prevents the pipe backlog from causing visible display lag.
while self.show_img_pipe.poll():
image_id = self.show_img_pipe.recv()
dropped_frames += 1
if image_id == "stop" or not isinstance(image_id, int):
break
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new frame dropping logic in live mode is not covered by the existing test_capture_image test, which mocks poll() to always return False. Consider adding test cases that verify the frame dropping behavior when multiple frames are queued, including edge cases like receiving "stop" or non-int image_ids while draining.

Copilot uses AI. Check for mistakes.
@AdvancedImagingUTSW
Copy link
Collaborator Author

@annie-xd-wang - We now include another safeguard which should prevent a laggy display. @conorhughmcfadden has tested it, and it appears to be functional. Camera display no longer lags significantly.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@AdvancedImagingUTSW AdvancedImagingUTSW merged commit f4a086c into develop Feb 4, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants