Skip to content

Conversation

@marcin-bazyl
Copy link
Collaborator

COMPLETES #SPARK-629490

This pull request addresses

If reachability is till being done in the background when we create a media connection, gathering of local candidates is very slow on Firefox, this delays meeting join and sometimes even causes Homer to timeout and join to fail.

by making the following changes

Stopping reachability when we create a media connection, this is after we've already sent the reachability results to the backend, so continuing reachability doesn't add value.

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 where tested

unit tests

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.

@marcin-bazyl marcin-bazyl requested review from a team as code owners March 7, 2025 15:25
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 7, 2025

📝 Walkthrough

Walkthrough

The pull request introduces changes to manage reachability checks during media connection setup within meetings. A call to a new method, stopReachability, is added in the media connection process to halt ongoing reachability checks before establishing a new connection. In parallel, a new public method stopReachability is introduced in the Reachability class to facilitate the termination of active checks. This method logs the stoppage, aborts any running checks, emits an event, and reports this state via metrics, which now include an aborted flag. The test suites have been updated to verify both normal and aborted scenarios during reachability operations. Overall, the modifications adjust the meeting setup process to address issues with prolonged reachability checks, particularly in environments like Firefox.

Possibly related PRs

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

yarn install v1.22.22
[1/4] Resolving packages...
warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-import-resolver-typescript > [email protected]: Glob versions prior to v9 are no longer supported
warning [email protected]: Glob versions prior to v9 are no longer supported
warning intern > [email protected]: Glob versions prior to v9 are no longer supported
warning intern > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jasmine > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > jest-cli > jest-config > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > [email protected]: Glob versions prior to v9 are no longer supported
warning mocha > [email protected]: Glob versions prior to v9 are no longer supported
warning mocha > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning [email protected]: 16.1.1
warning sinon > @sinonjs/samsam > [email protected]: This package is deprecated. Use the optional chaining (?.) operator instead.
warning wd > archiver > [email protected]: Glob versions prior to v9 are no longer supported
warning wd > [email protected]: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.

(For a CapTP with native promises, see @endo/eventual-send and @endo/captp)
warning wd > [email protected]: request has been deprecated, see request/request#3142
warning wd > archiver > archiver-utils > [email protected]: Glob versions prior to v9 are no longer supported
warning wd > request > [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
warning wd > request > [email protected]: this library is no longer supported
warning @babel/cli > [email protected]: Glob versions prior to v9 are no longer supported
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning @babel/[email protected]: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
warning @babel/polyfill > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning @babel/runtime-corejs2 > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning babel-plugin-lodash > [email protected]: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-19ad0e34-db83-4bd8-8859-a155a915e78a > [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning workspace-aggregator-19ad0e34-db83-4bd8-8859-a155a915e78a > [email protected]: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-19ad0e34-db83-4bd8-8859-a155a915e78a > [email protected]: 16.1.1
warning workspace-aggregator-19ad0e34-db83-4bd8-8859-a155a915e78a > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning workspace-aggregator-19ad0e34-db83-4bd8-8859-a155a915e78a > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning workspace-aggregator-19ad0e34-db83-4bd8-8859-a155a915e78a > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning workspace-aggregator-19ad0e34-db83-4bd8-8859-a155a915e78a > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning workspace-aggregator-19ad0e34-db83-4bd8-8859-a155a915e78a > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning workspace-aggregator-19ad0e34-db83-4bd8-8859-a155a915e78a > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning workspace-aggregator-19ad0e34-db83-4bd8-8859-a155a915e78a > @babel/[email protected]: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
[2/4] Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version "^14 || ^16 || ^17 || ^18 || ^19". Got "22.9.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5a8c246 and 830b29b.

📒 Files selected for processing (4)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (1 hunks)
  • packages/@webex/plugin-meetings/src/reachability/index.ts (3 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (7 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/reachability/index.ts (9 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build Packages
🔇 Additional comments (18)
packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (7)

246-249: Test setup correctly includes the new stopReachability stub

The addition of the stopReachability stub to the reachability mock object ensures that tests using this mock won't fail when the real implementation calls this method.


2096-2099: Mock reachability object properly updated with stopReachability method

This change appropriately adds the stub for the new stopReachability method to the mocked reachability object in this test case.


2516-2519: Good test coverage for the new stopReachability functionality

The added assertion correctly verifies that the Meeting class calls stopReachability during media connection setup, which is the core of the fix for the reachability process issue.


2712-2715: Mock object properly updated for error handling tests

Appropriate addition of the stopReachability stub to the reachability mock in the error handling test scenario.


2921-2924: Consistent mocking approach for reachability object

The addition of the stopReachability stub maintains consistency with other mock implementations throughout the test file.


3216-3219: Mock properly extended for ice candidate tests

The reachability mock object is correctly updated with the stopReachability stub in the ice candidate handling test case.


3721-3724: Comprehensive test coverage with updated mocks

The addition of the stopReachability stub to this nested test case ensures that all code paths using the reachability object are properly tested.

packages/@webex/plugin-meetings/src/meeting/index.ts (1)

6722-6724: Approved: Performance improvement by stopping unnecessary reachability checks

This is a good optimization that prevents ongoing reachability checks from slowing down the gathering of local candidates, which is particularly beneficial on Firefox where these checks can lead to timeouts and failures. The well-placed comment clearly explains the reason for this change.

packages/@webex/plugin-meetings/src/reachability/index.ts (5)

262-286: Well-designed implementation of stopReachability

The new method provides a clean way to stop ongoing reachability checks when they're no longer needed. This addresses the issue described in PR objectives where ongoing checks can slow down Firefox performance when joining meetings.


269-273: Good defensive coding practice

Checking for the existence of overallTimer before proceeding is a smart approach to ensure the method only takes action when there's an actual reachability process in progress.


283-284: Thorough cleanup of resources and notification of state change

Making sure to send metrics with the aborted flag and resolve the promise ensures that the system accurately reflects the state and doesn't leave hanging promises.


669-669: Clean method signature update

Adding the optional aborted parameter with a default value maintains backward compatibility while adding the needed functionality.


680-680: Metrics properly updated with abort status

The inclusion of the abort status in metrics data will allow for better analysis of reachability checks performance and behavior patterns.

packages/@webex/plugin-meetings/test/unit/spec/reachability/index.ts (5)

1053-1053: Metrics test updated to match implementation

The test correctly updates the expected metrics object to include the new aborted flag.


1932-2011: Thorough tests for the new stopReachability method

The new test suite provides good coverage of the stopReachability method, testing both the active and inactive reachability scenarios. This ensures the method behaves correctly under different conditions.


1951-1998: Complete verification of method behavior

This test thoroughly verifies all aspects of the stopReachability method:

  • Event emission
  • Metrics sending with the correct abort flag
  • Calling abort on cluster reachability instances
  • Not initiating fallback reachability

2000-2010: Edge case testing

Testing the behavior when no reachability is in progress is important to ensure the method doesn't cause errors when called unnecessarily.


2654-2675: Proper verification of aborted flag in metrics

This test ensures that the aborted flag is correctly set to true in metrics when specified, which is crucial for accurate monitoring and analysis.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this 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.

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.

@marcin-bazyl marcin-bazyl added the validated If the pull request is validated for automation. label Mar 7, 2025
@aws-amplify-us-east-2
Copy link

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

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

Copy link
Contributor

@adhmenon adhmenon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM.
Small doubt, since we are stopping the checks - let's assume some more resilient candidate pairs arrive slowly (edge case) - in that scenario, since we stop the connectivity checks, we don't get these candidates and essentially we will essentially be using a connection which is less optimal. Would this cause any major latency issues? Curious to know...

Copy link
Contributor

@sreenara sreenara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question about the way we're getting webex object.

: undefined;

// ongoing reachability checks slow down new media connections especially on Firefox, so we stop them
this.getWebexObject().meetings.reachability.stopReachability();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question. Why do we have this.getWebexObject() here but I'm seeing instances of this.webex in other places, for example the line above (6719).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's really the same thing, I think getWebexObject() was added later, so some newer code calls it, older code uses this.webex. TBH, I'm not sure why the function was added in the first place

@k-wasniowski
Copy link
Contributor

Changes LGTM. Small doubt, since we are stopping the checks - let's assume some more resilient candidate pairs arrive slowly (edge case) - in that scenario, since we stop the connectivity checks, we don't get these candidates and essentially we will essentially be using a connection which is less optimal. Would this cause any major latency issues? Curious to know...

Once we do a join, we would have provide reachability results gathered up to the sending point of the media request. All pairs gathered later was just for information, and was not signaled to the Locus.

@marcin-bazyl marcin-bazyl merged commit 4d27154 into webex:next Mar 11, 2025
22 of 23 checks passed
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.

4 participants