Skip to content
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(plugin-meetings): skip empty ice candidates for Firefox #4003

Conversation

k-wasniowski
Copy link
Contributor

@k-wasniowski k-wasniowski commented Nov 25, 2024

PART OF #SPARK-584958

This pull request addresses

Added skipping of empty ice candidates.

by making the following changes

Skip empty ice candidates counting

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

Tested with JS-SDK

I certified that

  • I have read and followed contributing guidelines

  • I discussed changes with code owners prior to submitting this pull request

  • I have not skipped any automated checks

  • All existing and new tests passed

  • I have updated the documentation accordingly


Make sure to have followed the contributing guidelines before submitting.

Summary by CodeRabbit

  • New Features

    • Enhanced handling of ICE candidates during media connection setup, ensuring only valid candidates are counted.
    • Expanded event handling for locus updates, including video mute status and participant state changes.
  • Bug Fixes

    • Improved error handling for media-related actions to prevent issues with invalid media stream states.
  • Refactor

    • Reorganized import statements for clarity and improved the overall structure of the Meeting class for better readability and maintainability.

@k-wasniowski k-wasniowski requested review from a team as code owners November 25, 2024 10:24
Copy link

coderabbitai bot commented Nov 25, 2024

Walkthrough

The changes in this pull request enhance the handling of ICE candidates within the Meeting class by modifying the ICE_CANDIDATE event handler to include stricter validation for the candidate property. Additionally, the meeting/index.js file has undergone reorganization and improvements in error handling, state management, and event handling related to media connections and meeting controls. These updates aim to improve code clarity and robustness without altering the overall structure of the Meeting class.

Changes

File Path Change Summary
packages/@webex/plugin-meetings/src/meeting/index.ts Updated ICE_CANDIDATE event handler to check that candidate is defined and non-empty before counting.
packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js Reorganized import statements for clarity. Updated constructor for correct correlation ID handling. Enhanced media connection handling in addMedia and unpublishStreams methods. Improved error handling and expanded event listeners for locus updates.

Possibly related PRs

Suggested reviewers

  • marcin-bazyl
  • szotrabh
  • edvujic

🐰 In the meadow, we hop and play,
With ICE candidates brightening our day.
We check each one, both strong and true,
Counting the valid, just for you!
So let’s gather round, and cheer with glee,
For robust connections, as happy as can be! 🌼


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@k-wasniowski k-wasniowski changed the title fix: skip empty ice candidates for Firefox fix(plugin-meetings): skip empty ice candidates for Firefox Nov 25, 2024
@k-wasniowski k-wasniowski added the validated If the pull request is validated for automation. label Nov 25, 2024
Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (7)
packages/@webex/plugin-meetings/src/meeting/index.ts (2)

6324-6325: Use optional chaining for cleaner null checks

The null checks can be simplified using optional chaining for better readability.

-      if (event.candidate && event.candidate.candidate && event.candidate.candidate.length > 0) {
+      if (event.candidate?.candidate?.length > 0) {
🧰 Tools
🪛 Biome (1.9.4)

[error] 6325-6325: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


6324-6326: Add comment explaining empty candidate handling

Consider adding a comment explaining why we skip empty ICE candidates, as this is specifically handling Firefox behavior.

+      // Skip empty ICE candidates that may be emitted by Firefox
       if (event.candidate && event.candidate.candidate && event.candidate.candidate.length > 0) {
         this.iceCandidatesCount += 1;
       }
🧰 Tools
🪛 Biome (1.9.4)

[error] 6325-6325: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (5)

3814-3819: The change looks good, but add a test to verify the behavior.

The change to use the provided headers from the mocked join request response is fine.

Consider adding a test case that verifies the expected behavior - that the trackingid from the mocked join response headers is set correctly on the LocusMediaRequest instance.


4012-4015: Refactor to extract common logic into a helper function.

The logic for handling a microphone stream with ended readyState is duplicated for camera, screen share audio and screen share video streams.

Consider extracting this into a common helper function that takes the stream type and correlationId as parameters. This will reduce code duplication and improve maintainability.

function handleEndedStream(streamType, correlationId) {
  assert.throws(
    () => meeting.publishStreams(localStreams),
    `Attempted to publish ${streamType} stream with ended readyState, correlationId=${correlationId}`
  );
}

Then replace the duplicated code blocks with calls to this helper:

handleEndedStream('microphone', meeting.correlationId);

4358-4358: Remove commented out code.

Remove the commented out line //calling handleDeviceLogging with audioEnaled as true adn videoEnabled as false.
Commented out code should not be checked in. If this comment is important, rephrase it and keep it, otherwise just delete it.


4365-4365: Fix typo in comment.

Fix the typo in the comment: //calling handleDeviceLogging audioEnabled as true videoEnabled as false.
It should be //calling handleDeviceLogging with audioEnabled as true and videoEnabled as false.


9174-9174: Remove extra blank line.

Remove the extra blank line before the assert.calledWith(meeting.webinar.updateWebcastUrl, newLocusResources); line to be consistent with the rest of the code.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e8a8fc0 and 17ca490.

📒 Files selected for processing (2)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (2 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (15 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/@webex/plugin-meetings/src/meeting/index.ts

[error] 6325-6325: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (10)
packages/@webex/plugin-meetings/src/meeting/index.ts (1)

6324-6326: LGTM! Proper handling of empty ICE candidates

The core logic change correctly handles empty ICE candidates by checking for both existence and non-empty content before incrementing the counter. This fixes the issue with Firefox's ICE candidate handling.

🧰 Tools
🪛 Biome (1.9.4)

[error] 6325-6325: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (9)

93-94: Looks good, the empty ICE candidate is now skipped.

The change correctly skips counting empty ICE candidates.


380-383: Verify the callStateForMetrics is set correctly when correlation ID is not provided.

The change looks correct. When the correlation ID is not provided in the constructor, it uses the meeting ID as the correlation ID and sets it in callStateForMetrics.

To verify, check that when joining a meeting without providing a correlation ID:

  1. The meeting's correlationId property is set to the meeting ID
  2. The callStateForMetrics object has the correct correlationId and sessionCorrelationId

4028-4031: ****

This comment is a duplicate of the previous one for microphone stream. Please refer to that comment for the refactoring suggestion.


4044-4047: ****

This comment is a duplicate of the previous one for microphone stream. Please refer to that comment for the refactoring suggestion.


4060-4063: ****

This comment is a duplicate of the previous one for microphone stream. Please refer to that comment for the refactoring suggestion.


6293-6308: The error handling for MeetingInfoV2WebinarRegistrationError looks good.

The change correctly handles the MeetingInfoV2WebinarRegistrationError by:

  1. Rejecting with a WebinarRegistrationError
  2. Setting meeting.meetingInfo to the meeting info from the error
  3. Setting meeting.meetingInfoFailureCode and meeting.meetingInfoFailureReason appropriately

7023-7026: Verify the callStateForMetrics is updated correctly when setting a new correlationId.

The change looks correct. When setCorrelationId is called with a new correlation ID, it updates both the correlationId property and the callStateForMetrics.correlationId.

To verify, check that after calling meeting.setCorrelationId(newCorrelationId):

  1. meeting.correlationId is set to newCorrelationId
  2. meeting.callStateForMetrics.correlationId is also set to newCorrelationId

7777-7781: The check for not collecting empty or null ICE candidates looks good.

The change correctly skips incrementing meeting.iceCandidatesCount when the ICE candidate is an empty string or null.


Line range hint 12332-12355: The LOCAL_UNMUTE_REQUIRED event handling looks good.

The changes look good:

  1. It correctly triggers the MEETING_SELF_UNMUTED_BY_OTHERS event with the unmuteAllowed payload
  2. It calls meeting.audio.handleServerLocalUnmuteRequired with the right arguments

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-4003.d3m3l2kee0btzx.amplifyapp.com

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (1)
packages/@webex/plugin-meetings/src/meeting/index.ts (1)

6324-6324: Consider using optional chaining for better readability

The validation logic is good but can be made more concise using optional chaining. This maintains the same null/undefined safety while being more readable.

-if (event.candidate && event.candidate.candidate && event.candidate.candidate.length > 0) {
+if (event.candidate?.candidate?.length > 0) {
  this.iceCandidatesCount += 1;
}

Consider also adding a comment explaining that this check is needed specifically for Firefox which can emit empty ICE candidates.

🧰 Tools
🪛 Biome (1.9.4)

[error] 6324-6324: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 17ca490 and f658c40.

📒 Files selected for processing (1)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/@webex/plugin-meetings/src/meeting/index.ts

[error] 6324-6324: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (1)
packages/@webex/plugin-meetings/src/meeting/index.ts (1)

6326-6328: LGTM! Consider using optional chaining for more concise validation.

The additional validation for empty ICE candidates is a good defensive programming practice, especially for Firefox compatibility. The code can be made slightly more concise using optional chaining.

-        if (event.candidate && event.candidate.candidate && event.candidate.candidate.length > 0) {
+        if (event.candidate?.candidate?.length > 0) {
           this.iceCandidatesCount += 1;
         }
🧰 Tools
🪛 Biome (1.9.4)

[error] 6326-6326: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d930b89 and 699f723.

📒 Files selected for processing (2)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (1 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js
🧰 Additional context used
🪛 Biome (1.9.4)
packages/@webex/plugin-meetings/src/meeting/index.ts

[error] 6326-6326: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

@k-wasniowski k-wasniowski merged commit c4ba3e5 into webex:next Nov 26, 2024
12 checks passed
@k-wasniowski k-wasniowski deleted the fix-ice-candidates-skip-firefox-empty-candidate branch November 26, 2024 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validated If the pull request is validated for automation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants