-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix WebRTC for Firefox by ignoring empty ice candidates #21908
Conversation
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.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
WalkthroughWalkthroughThe changes involve an update to the ICE candidate handling logic within the Changes
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 1
src/components/ha-web-rtc-player.ts
Outdated
@@ -109,7 +109,7 @@ class HaWebRtcPlayer extends LitElement { | |||
let candidates = ""; // Build an Offer SDP string with ice candidates | |||
const iceResolver = new Promise<void>((resolve) => { | |||
peerConnection.addEventListener("icecandidate", async (event) => { | |||
if (!event.candidate) { | |||
if (!(event.candidate && event.candidate.candidate)) { |
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.
Refine ICE candidate handling and consider using optional chaining.
The modification at line 112 enhances the robustness of the ICE candidate handling by ensuring that the promise resolves only when there are no valid candidates available. This is a crucial fix for the issue with Firefox and empty ICE candidates.
Additionally, consider using optional chaining to simplify the condition and improve code safety:
- if (!(event.candidate && event.candidate.candidate)) {
+ if (!event.candidate?.candidate) {
This change will make the code more readable and prevent potential null reference errors.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if (!(event.candidate && event.candidate.candidate)) { | |
if (!event.candidate?.candidate) { |
Tools
Biome
[error] 112-112: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
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.
@coderabbitai updated as per 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.
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.
Thank you so much for fixing this long standing issue with the Firefox webrtc. Many nest + firefox users will very much appreciate this.
Can you change the PR description to something like "Fix WebRTC for Firefox by ignoring empty ice candidates"? Something with propper capitalization.
Tagging for review for a future patch release candidate. |
Proposed change
Not adding empty candidate into offer sdp to avoid smartdevicemanagement google api returns 500 internal server error
Type of change
Example configuration
Additional information
Error handling WebRTC offer: Nest API error: Error from API: 500: INTERNAL: Internal error encountered.: Internal Server Error core#103924
It has to combine with Workaround for Nest SDP answer bugs to pass firefox validation allenporter/python-google-nest-sdm#1115 release
in order to have nest cam working in Firefox
Checklist
If user exposed functionality or configuration variables are added/changed:
Summary by CodeRabbit