Skip to content

fix: report zero volume from useTrackVolume - #469

Closed
RaphaelFakhri wants to merge 1 commit into
livekit:mainfrom
RaphaelFakhri:fix/use-track-volume-silence
Closed

RaphaelFakhri wants to merge 1 commit into
livekit:mainfrom
RaphaelFakhri:fix/use-track-volume-silence

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Fixes useTrackVolume so it reports silence.

The native volume processors emit volume: 0 when a track is silent or muted. The event handler checked event.volume for truthiness, so a value of 0 was ignored and the hook kept returning the last non-zero volume. A level meter built on the hook stays stuck at its last level after the speaker stops.

The handler now only skips events where volume is null or undefined.

This change also:

  • Adds a jest test that emits a non-zero volume followed by 0 and expects the hook to return 0. The test fails on the previous code.
  • Adds react-test-renderer as a dev dependency to render the hook in the test.
  • Sets the jest testEnvironment to node. With the react-native preset environment, jest 30 fails to start with this._moduleMocker.clearMocksOnScope is not a function because the preset resolves its own older jest-mock.
  • Excludes __tests__ from tsconfig.build.json so yarn typescript and the build ignore test files.
  • Adds a changeset.

Test plan:

  • yarn jest fails before the source change (1 failed) and passes after (1 passed).
  • yarn lint and yarn typescript pass.

@changeset-bot

changeset-bot Bot commented Sep 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 69dfd23

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

This PR includes changesets to release 1 package
Name Type
@livekit/react-native 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

@CLAassistant

CLAassistant commented Sep 29, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

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.

2 participants