Skip to content

Sync desktop/ from omi-desktop (474e1e1f)#4963

Closed
m13v wants to merge 1 commit intomainfrom
sync/desktop-20260222-172718
Closed

Sync desktop/ from omi-desktop (474e1e1f)#4963
m13v wants to merge 1 commit intomainfrom
sync/desktop-20260222-172718

Conversation

@m13v
Copy link
Copy Markdown
Contributor

@m13v m13v commented Feb 22, 2026

Automated sync from omi-desktop at 474e1e1f.

This PR was created by the sync pipeline.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a major refactoring of the AI chat bridge, unifying on a single ACP (Agent Client Protocol) bridge and removing the legacy ClaudeAgentBridge. This significantly simplifies the architecture. The PR also includes substantial improvements to the Tasks UI, introducing local-first operations for better performance, drag-and-drop reordering, and a new background investigation feature. Key reliability fixes have been implemented, including watchdogs to prevent hung ffmpeg processes in the video encoder and to avoid resource leaks from multiple capture timers. Overall, this is an excellent update that enhances performance, reliability, and user experience across the application.

Comment on lines +945 to 946
captureTimer?.invalidate()
captureTimer = Timer.scheduledTimer(withTimeInterval: RewindSettings.shared.captureInterval, repeats: true) { [weak self] _ in
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

This is a critical fix for preventing a resource leak. Without invalidating the existing captureTimer before creating a new one, multiple timers could be created and run concurrently, especially if handleDisplayChange is called multiple times in quick succession. This would lead to excessive CPU usage and memory consumption from redundant frame captures. Adding captureTimer?.invalidate() ensures that only one capture timer is active at any given time.

Comment on lines +553 to 570
// Terminate ffmpeg process forcefully.
// Use SIGTERM first, then SIGKILL after 2s if it doesn't respond.
// ffmpeg can get stuck in disk I/O when the system is under memory pressure,
// causing SIGTERM to be ignored (process is in uninterruptible sleep in the kernel).
// Without the SIGKILL fallback, zombie ffmpeg processes accumulate and eventually
// push the app's memory to 7GB+, making the entire system unresponsive.
if let process = ffmpegProcess {
process.terminate()
let pid = process.processIdentifier
process.terminate() // SIGTERM
ffmpegProcess = nil
Task.detached(priority: .background) {
try? await Task.sleep(nanoseconds: 2_000_000_000)
if process.isRunning {
logError("VideoChunkEncoder: ffmpeg still running 2s after SIGTERM — force killing PID \(pid)")
kill(pid, SIGKILL)
}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

This is a critical reliability improvement. The previous implementation with just process.terminate() sends a SIGTERM, which can be ignored by a process stuck in an uninterruptible state (e.g., disk I/O under heavy memory pressure). Without the SIGKILL fallback, a hung ffmpeg process could block this actor indefinitely, leading to resource leaks and causing the entire frame capture pipeline to fail. This watchdog mechanism ensures the process is forcefully cleaned up, preventing such deadlocks.

@m13v m13v closed this Feb 23, 2026
@m13v m13v deleted the sync/desktop-20260222-172718 branch February 23, 2026 03:31
@github-actions
Copy link
Copy Markdown
Contributor

Hey @m13v 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our roadmap and vision

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community! 💜

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.

1 participant