-
Notifications
You must be signed in to change notification settings - Fork 210
Fix prejoin device dropdown crashes in example app #966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughReset stale audio/video selections when device lists change; stop and clear tracks and selections when audio/video are disabled; on enabling, auto-select the first available device and start its track if none is selected. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Prejoin UI
participant DM as DeviceManager
participant TM as TrackManager
UI->>DM: request device list (_loadDevices)
DM-->>UI: return audio/video inputs
alt device list changed / missing selection
UI->>UI: clear stale _selectedAudioDevice/_selectedVideoDevice
UI->>TM: stop & nullify corresponding tracks
end
opt enabling audio/video with available inputs
UI->>UI: auto-select first device if none
UI->>TM: start track for selected device
TM-->>UI: track started
end
opt disabling audio/video
UI->>TM: stop & clear track
UI->>UI: clear selected device
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ 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)
🔇 Additional comments (3)
✏️ Tip: You can disable this entire section by setting Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
example/lib/pages/prejoin.dart (1)
83-112: Guard auto‑selection when audio/video is disabled to avoid DropdownButton crashes.
_loadDevicescan set_selectedAudioDevice/_selectedVideoDeviceeven when_enableAudio/_enableVideois false (e.g., initial load with prefs disabled or device-change events). That leaves a non‑nullvaluewhile items are[], reintroducing the “exactly one item with value” assertion.🔧 Proposed fix
- if (_audioInputs.isNotEmpty) { + if (_enableAudio && _audioInputs.isNotEmpty) { if (_selectedAudioDevice == null) { _selectedAudioDevice = _audioInputs.first; Future.delayed(const Duration(milliseconds: 100), () async { await _changeLocalAudioTrack(); setState(() {}); }); } } - if (_videoInputs.isNotEmpty) { + if (_enableVideo && _videoInputs.isNotEmpty) { if (_selectedVideoDevice == null) { _selectedVideoDevice = _videoInputs.first; Future.delayed(const Duration(milliseconds: 100), () async { await _changeLocalVideoTrack(); setState(() {}); }); } }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.changes/example-prejoin-dropdownexample/lib/pages/prejoin.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). (7)
- GitHub Check: Build for Flutter Linux
- GitHub Check: Build for Flutter Windows
- GitHub Check: Build for Flutter Web WASM
- GitHub Check: Build for Flutter iOS
- GitHub Check: Build for Flutter Web
- GitHub Check: Build for Flutter macOS
- GitHub Check: Build for Flutter Android
🔇 Additional comments (3)
.changes/example-prejoin-dropdown (1)
1-1: Changelog entry looks good.example/lib/pages/prejoin.dart (2)
116-127: Good: clearing selection on disable and re-selecting on enable.
This aligns the dropdown value with enabled state.
132-143: Good: audio toggle now keeps selection consistent.
Clearing on disable and re‑selecting on enable is the right behavior.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
example/lib/pages/prejoin.dart (1)
87-112: Stop and clear tracks when no devices remain after a device-change event.If a device disappears and the list becomes empty, the selection is cleared but the existing track can remain active, leaving preview/join state referencing a stale device. Stopping and clearing the track in that case keeps state consistent.
🛠️ Proposed fix
if (_selectedAudioDevice != null && !_audioInputs.contains(_selectedAudioDevice)) { _selectedAudioDevice = null; } + if (_selectedAudioDevice == null && _audioInputs.isEmpty) { + await _audioTrack?.stop(); + _audioTrack = null; + } if (_selectedVideoDevice != null && !_videoInputs.contains(_selectedVideoDevice)) { _selectedVideoDevice = null; } + if (_selectedVideoDevice == null && _videoInputs.isEmpty) { + await _videoTrack?.stop(); + _videoTrack = null; + }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
example/lib/pages/prejoin.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). (7)
- GitHub Check: Build for Flutter Linux
- GitHub Check: Build for Flutter Web
- GitHub Check: Build for Flutter Web WASM
- GitHub Check: Build for Flutter macOS
- GitHub Check: Build for Flutter Android
- GitHub Check: Build for Flutter Windows
- GitHub Check: Build for Flutter iOS
🔇 Additional comments (2)
example/lib/pages/prejoin.dart (2)
119-126: LGTM: video toggle now keeps selection and track state aligned.
135-142: LGTM: audio toggle now keeps selection and track state aligned.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
example/lib/pages/prejoin.dart (1)
102-121: Guard async callbacks withmountedbefore callingsetState.
_loadDevicesawaits async work and schedules delayed callbacks; if the widget is disposed in between,setStatewill throw. Addmountedchecks to avoid post-dispose updates.🔧 Suggested fix
- Future.delayed(const Duration(milliseconds: 100), () async { - await _changeLocalAudioTrack(); - setState(() {}); - }); + Future.delayed(const Duration(milliseconds: 100), () async { + if (!mounted) return; + await _changeLocalAudioTrack(); + if (mounted) setState(() {}); + }); } } ... - Future.delayed(const Duration(milliseconds: 100), () async { - await _changeLocalVideoTrack(); - setState(() {}); - }); + Future.delayed(const Duration(milliseconds: 100), () async { + if (!mounted) return; + await _changeLocalVideoTrack(); + if (mounted) setState(() {}); + }); } } - setState(() {}); + if (mounted) setState(() {});
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
example/lib/pages/prejoin.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). (7)
- GitHub Check: Build for Flutter macOS
- GitHub Check: Build for Flutter Linux
- GitHub Check: Build for Flutter Web WASM
- GitHub Check: Build for Flutter iOS
- GitHub Check: Build for Flutter Web
- GitHub Check: Build for Flutter Windows
- GitHub Check: Build for Flutter Android
🔇 Additional comments (1)
example/lib/pages/prejoin.dart (1)
87-96: No changes needed—MediaDevice already implements value-based equality.
MediaDeviceoverridesoperator==to compare all four fields (deviceId,kind,label,groupId), soList.contains()works correctly. The original code is sound and does not require the suggesteddeviceId-matching refactor.Likely an incorrect or invalid review comment.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.