Skip to content

fix: release VideoCapture natively, keep its sink and report start errors - #519

Merged
devopvoid merged 3 commits into
mainfrom
fix/video-capture-lifecycle
Nov 1, 2026
Merged

devopvoid merged 3 commits into
mainfrom
fix/video-capture-lifecycle

Conversation

@devopvoid

Copy link
Copy Markdown
Owner
  • dispose() deletes the native capture through a now virtual VideoCaptureBase destructor, which stops capture and detaches the sink first.
  • The capture owns its sink and only lends it to WebRTC, so the sink and its global ref are freed and a start() after stop() still delivers frames. Replacing the sink while running deregisters the old one first.
  • On macOS, the capturer's delegate is detached under @synchronized before the capture goes away (stopping is asynchronous), and the sink is guarded by a mutex.
  • Errors are thrown as values instead of pointers; start() without a device throws IllegalStateException, other failures keep their message.

…rors

dispose() now deletes the capture through a virtual destructor, which stops
capture and detaches the sink. The capture owns its sink and only lends it to
WebRTC, so it is freed and survives a stop/start cycle. Errors are thrown as
values; start() without a device throws IllegalStateException.
Thrown as pointers, they reached Java as "Unhandled Exception" and leaked.
…ecycle

# Conflicts:
#	webrtc-jni/src/main/cpp/src/JNI_VideoCapture.cpp
@devopvoid
devopvoid merged commit ef6174a into main Nov 1, 2026
25 checks passed
@devopvoid
devopvoid deleted the fix/video-capture-lifecycle branch November 1, 2026 23:42
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