Skip to content

Conversation

@holzgeist
Copy link
Contributor

@holzgeist holzgeist commented Aug 26, 2025

This PR improves handling of processors:

  • properly stop processors on track stop (avoids keeping camera on even after track ended)
  • add more parameters to copyWith when copying camera capture options
  • emit TrackStreamUpdatedEvent on processor changes to allow widgets to update accordingly

I'm currently working on a federated plugin to add support for virtual backgrounds and blurring on web, iOS and Android. This PR contains required changes/bug fixes I found during development

Summary by CodeRabbit

  • New Features

    • Camera capture configuration now includes focus mode and exposure mode options for enhanced control
    • Track processing now supports processor configuration during capture setup
  • Improvements

    • Enhanced processor cleanup and lifecycle management when stopping tracks to prevent resource leaks
    • Track processing operations now properly handle asynchronous execution for improved reliability

✏️ Tip: You can customize this high-level summary in your review settings.

@holzgeist
Copy link
Contributor Author

I'll try to get the tests to pass later today, but they don't seem to be related to my changes

@holzgeist
Copy link
Contributor Author

I checked that the tests run through locally, all the other breaking stuff should be unrelated to my PR.

Does anyone know what's up with dart formatter? On some of my repos it keeps finding stuff to format without any other changes 🤷

@hiroshihorie hiroshihorie self-requested a review December 9, 2025 15:40
@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

Changes enhance track processing infrastructure by introducing asynchronous processor lifecycle management, nullable track restoration in setProcessedTrack, and expanding camera capture options with focus and exposure mode parameters.

Changes

Cohort / File(s) Summary
Processor Lifecycle Management
lib/src/track/local/local.dart
LocalTrack.stop() now halts associated processor; setProcessor uses ProcessorOptions with track kind; setProcessedTrack calls are awaited; stopProcessor clears processed track; TrackProcessorUpdateEvent now carries processor instance alongside track; conditional import for processor_native removed
Track Switching and Restoration
lib/src/track/track.dart
setProcessedTrack signature changed to async Future accepting nullable track; supports installing new processed tracks and restoring original tracks with await-based async handling; emits TrackStreamUpdatedEvent after processing
Camera Capture Configuration
lib/src/track/options.dart
CameraCaptureOptions.copyWith extended with focusMode, exposureMode, and processor parameters; parameter reordering implemented; from() constructor now propagates processor from source options

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Processors stop with grace and care,
Tracks swap async through the air,
Restore the old when new is gone,
Events now know which process shone!
Focus sharp, exposure bright—
Camera options burning bright!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: improving processor handling through better lifecycle management and event emissions across multiple related files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70d4d1f and 0c04eea.

📒 Files selected for processing (3)
  • lib/src/track/local/local.dart
  • lib/src/track/options.dart
  • lib/src/track/track.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Build for Flutter Web
  • GitHub Check: Build for Flutter Web WASM
  • GitHub Check: Build for Flutter Linux
  • GitHub Check: Build for Flutter macOS
  • GitHub Check: Build for Flutter Android
  • GitHub Check: Build for Flutter Windows
🔇 Additional comments (6)
lib/src/track/track.dart (1)

225-244: LGTM - Async processor track management with nullable restoration.

The implementation correctly handles both setting a processed track and restoring the original. One minor observation: the null check on line 230 is redundant since _originalTrack was just assigned from the non-nullable _mediaStreamTrack on line 228.

Consider whether removeTrack/addTrack failures should be caught to prevent inconsistent state, though the current approach may be acceptable if you want such failures to propagate.

lib/src/track/local/local.dart (3)

146-152: LGTM - Defensive processor cleanup on track stop.

Good addition of error handling when stopping the processor. Note that when called from stop(), setProcessedTrack(null) inside stopProcessor() will be a partial no-op since Track.stop() already nulled _originalTrack, so the restoration branch won't execute. This is fine for cleanup purposes but worth being aware of.


263-271: LGTM - Proper async handling and ProcessorOptions construction.

The ProcessorOptions now correctly includes the kind field, and setProcessedTrack is properly awaited to match its new async signature.


297-298: LGTM - Track restoration on processor stop.

Correctly calls setProcessedTrack(null) to restore the original track state and emit the update event when the processor is stopped.

lib/src/track/options.dart (2)

73-83: LGTM - Processor propagation in factory constructor.

The processor is now correctly forwarded from the source captureOptions, ensuring processor configuration is preserved when creating CameraCaptureOptions from a VideoCaptureOptions.


111-130: LGTM - Complete copyWith implementation.

The copyWith method now properly includes all fields (focusMode, exposureMode, params, processor), ensuring no configuration is lost when copying options. This aligns well with the broader processor handling improvements.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

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.

3 participants