screenpipe icon indicating copy to clipboard operation
screenpipe copied to clipboard

adding health_check and auto recovery/restart for macos

Open kushagra21-afk opened this issue 5 months ago • 2 comments

name: Audio Stability Fixes about: Submit changes for macOS audio recovery system title: "[AUDIO] Fix macOS audio device recovery" labels: 'bugfix, audio'

Description

Implemented core logic for macOS audio device recovery when devices randomly stop during long sessions (>48h). Addresses silent failures in CoreAudio/ScreenCaptureKit.

Changes

  • Added zombie state detection via heartbeat monitoring
  • Implemented 3-stage recovery process:
    1. Soft restart (reinitialize stream)
    2. Device-level reset (CoreAudio)
    3. Full pipeline restart (fallback)
  • Added recovery metrics tracking
// Key addition to AudioManager
impl AudioManager {
    pub async fn hard_reset_device(&self, device_name: &str) -> Result<()> {
        self.stop_device(device_name).await?;
        
        // macOS-specific cleanup
        #[cfg(target_os = "macos")]
        macos_audio::release_device_resources(device_name).await?;
        
        let device = parse_audio_device(device_name)?;
        self.start_device(&device).await?;
        
        info!("Hard reset completed for {}", device_name);
        Ok(())
    }
}

Notes

  • Logs available via tracing subscribers
  • Metrics exposed via AudioManager::recovery_stats()

/claim https://github.com/mediar-ai/screenpipe/issues/1626

kushagra21-afk avatar Jul 18 '25 21:07 kushagra21-afk

🧪 testing bounty created!

a testing bounty has been created for this PR: view testing issue

testers will be awarded $20 each for providing quality test reports. please check the issue for testing requirements.

github-actions[bot] avatar Jul 18 '25 21:07 github-actions[bot]

does it work? how can you prove it

louis030195 avatar Aug 13 '25 16:08 louis030195