10000
Skip to content

Camera not fully released after stop_stream() on macOS (v0.10.10) - Firefox cannot detect release #224

@alekslovesonome

Description

@alekslovesonome

Camera device not fully released after stop_stream() on macOS - Firefox cannot detect release

Description

When using the AVFoundation backend on macOS, the camera hardware is not properly released after calling stop_stream(). While most applications (Chrome, Safari, other browsers) correctly detect that the camera is available, Firefox specifically cannot access the camera until the Rust process exits.

This indicates that stop_stream() is not properly releasing the camera at the OS level.

Environment

  • OS: macOS
  • Nokhwa version: 0.10.10
  • Backend: AVFoundation
  • Rust version: 1.83+

Steps to Reproduce

  1. Start a Rust application using nokhwa camera
  2. Call camera.open_stream()
  3. Call camera.stop_stream() and drop(camera)
  4. Try to access the camera from Firefox (e.g., webrtc.github.io/samples)

Expected behavior: Firefox should immediately detect the camera is available.

Actual behavior:

  • ✅ The same Rust process can restart and reuse the camera
  • Chrome, Safari, other browsers can access the camera
  • Firefox cannot access the camera
  • ✅ After Rust process exits, Firefox can access the camera

Why This Matters

Firefox appears to be more strict about camera ownership detection than other browsers. The fact that Firefox CAN access the 5B4A camera immediately after the process exits (but NOT after stop_stream()) proves that stop_stream() is not properly releasing the camera at the OS/system level.

Investigation

After stop_stream() and Drop, the AVFoundation objects have high retain counts:

  • AVCaptureDevice: retainCount = 12 → 11 (after release)
  • AVCaptureDeviceInput: retainCount = 7 → 6 (after release)
  • AVCaptureSession: retainCount = 2 → 1 (after release)
  • AVCaptureVideoDataOutput: retainCount = 3 → 2 (after release)

The retain counts remain > 0, meaning the objects are still alive and the camera may still be marked as "in use" by the process at some system level that Firefox checks.

Impact

Users cannot:

  • Immediately switch to Firefox for web calls

They must force-quit the Rust app for Firefox to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0