Skip to content

common: Add pre call bandwidth test - #1068

Open
thyal wants to merge 1 commit into
mainfrom
thomas/PAN-2733-bandwidth-testing-feature
Open

common: Add pre call bandwidth test#1068
thyal wants to merge 1 commit into
mainfrom
thomas/PAN-2733-bandwidth-testing-feature

Conversation

@thyal

@thyal thyal commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Description

Lets consumers measure a user's connection to the Whereby media servers before they join a room, so they can warn about a bad network up front.

core
PreCallTestClient, via client.getPreCallTest():

const preCallTest = client.getPreCallTest();

// runs for 15s by default; pass { durationSeconds } to change it (minimum 10)
const result = await preCallTest.startTest();

if (result?.warning) {
    console.log("Degraded connection", result.details);
}

// or drive your UI from state instead of awaiting
preCallTest.subscribeStatus((status) => {
    console.log("Pre-call test:", status); // idle | running | completed | failed
});

browser-sdk, the usePreCallTest hook:

import { usePreCallTest } from "@whereby.com/browser-sdk/react";

function MyNetworkCheck() {
    const { state, actions } = usePreCallTest();
    const { status, result, error } = state;

    return (
        <div>
            <button onClick={() => actions.startTest()} disabled={status === "running"}>
                {status === "running" ? "Testing…" : "Test my connection"}
            </button>

            {status === "completed" && result.success && <p>Your connection looks good.</p>}
            {status === "completed" && result.warning && (
                <p>Your connection may struggle: {result.details.recvAvailableBitrate.to
            )}
            {status === "failed" && <p>Could not test your connection: {error.message}</
        </div>
    );
}

success means no problems found. warning means the test completed but the connection is degraded — flags in details say which check tripped (lowRecvAvailableBitrate, highSendLoss, highRecvLoss). failed means no verdict at all, with error explaining why.

Network-only by design — no camera/mic/speaker steps, since those are user self-report rcover how to build those on top of useLocalMedia.

Summary:

Related Issue:

Testing

  1. pnpm build && pnpm dev
  2. Go to the Examples / Pre call test, bandwidth test story
  3. Run the test
  4. Verify that it works correctly (you can also check the network calls)
  5. Throttle connection, and repeat the test
  6. Verify that it shows degraded network

Screenshots/GIFs (if applicable)

image image

Checklist

  • My code follows the project's coding standards.
  • Prefixed the PR title and commit messages with the service or package name
  • I have written unit tests (if applicable).
  • I have updated the documentation (if applicable).
  • By submitting this pull request, I confirm that my contribution is made
    under the terms of the MIT license.

Additional Information

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bac13d5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@whereby.com/browser-sdk Minor
@whereby.com/core Minor
@whereby.com/assistant-sdk Patch
@whereby.com/react-native-sdk Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@thyal
thyal requested a review from a team July 29, 2026 10:11
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.

1 participant