Commit facedf2
committed
fix: critical video feed mismatch and VideoForwarder resource leaks
CRITICAL FIXES:
1. Video Feed Mismatch (LLM getting wrong video)
- When YOLO/video processors are used, LLM was receiving empty processed track
- Root cause: shared_forwarder was created from RAW track but LLM was given processed track
- Fix: Create separate forwarders for raw and processed video tracks
- Now LLM correctly receives YOLO-annotated frames when using pose detection
2. VideoForwarder Resource Leaks
- Consumer tasks were never removed from _tasks set (memory leak)
- Fix: Add task.add_done_callback(self._task_done) to clean up tasks
- Producer exceptions were silently swallowed
- Fix: Log and re-raise exceptions for proper error handling
3. Race Condition in VideoForwarder.stop()
- Used list() snapshot for cancellation but original set for gather()
- Fix: Use tasks_snapshot consistently throughout stop()
4. Multiple start() Protection
- No guard against calling start() multiple times
- Fix: Add _started flag and early return with warning
5. Missing VideoForwarder Cleanup in Agent
- Forwarders were created but never stopped on agent.close()
- Fix: Track all forwarders and stop them in close() method
These fixes prevent resource leaks, ensure correct video routing, and improve
error visibility for production debugging.1 parent fbc1759 commit facedf2
File tree
2 files changed
+80
-28
lines changed- agents-core/vision_agents/core
- agents
- utils
2 files changed
+80
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
305 | 314 | | |
306 | 315 | | |
307 | 316 | | |
| |||
579 | 588 | | |
580 | 589 | | |
581 | 590 | | |
582 | | - | |
| 591 | + | |
583 | 592 | | |
584 | | - | |
| 593 | + | |
585 | 594 | | |
586 | 595 | | |
587 | 596 | | |
588 | | - | |
| 597 | + | |
589 | 598 | | |
590 | | - | |
591 | | - | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
592 | 606 | | |
593 | | - | |
| 607 | + | |
594 | 608 | | |
595 | | - | |
596 | | - | |
597 | 609 | | |
598 | | - | |
599 | | - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
600 | 625 | | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
606 | 630 | | |
607 | 631 | | |
608 | 632 | | |
609 | 633 | | |
610 | | - | |
| 634 | + | |
611 | 635 | | |
612 | 636 | | |
613 | | - | |
| 637 | + | |
614 | 638 | | |
615 | 639 | | |
616 | 640 | | |
617 | 641 | | |
618 | 642 | | |
619 | | - | |
| 643 | + | |
620 | 644 | | |
621 | 645 | | |
622 | 646 | | |
| |||
628 | 652 | | |
629 | 653 | | |
630 | 654 | | |
631 | | - | |
632 | | - | |
| 655 | + | |
| 656 | + | |
633 | 657 | | |
634 | 658 | | |
635 | 659 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
31 | 36 | | |
32 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
33 | 40 | | |
34 | 41 | | |
| 42 | + | |
| 43 | + | |
35 | 44 | | |
36 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
37 | 49 | | |
38 | | - | |
39 | | - | |
| 50 | + | |
| 51 | + | |
40 | 52 | | |
41 | 53 | | |
42 | 54 | | |
| |||
45 | 57 | | |
46 | 58 | | |
47 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
48 | 73 | | |
49 | 74 | | |
50 | 75 | | |
| |||
53 | 78 | | |
54 | 79 | | |
55 | 80 | | |
56 | | - | |
57 | | - | |
58 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
59 | 84 | | |
60 | 85 | | |
61 | 86 | | |
| |||
165 | 190 | | |
166 | 191 | | |
167 | 192 | | |
| 193 | + | |
168 | 194 | | |
169 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
0 commit comments