bug: [React Native] InCallManager is started per meeting but never stopped
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- react-native, typescript
- Domain
- mobile
Research direction
Start with lib/module/NativeAudioManager.js, lib/module/LocalMediaHandler.js, and lib/module/ReactHooks.js, tracing where audio starts and where meeting teardown runs. Check the native Android and iOS stop signatures, then verify cleanup across leave, a second meeting, stage leave and return, and a connected meeting hot-swap. Done means audio resources are released and restarted correctly without an older client stopping a newer meeting's audio.
Written by the indexing model from the issue text.
Description
Package: @cloudflare/realtimekit-react-native 2.0.0 (same code in 2.0.1-staging.0).
What happens
The LocalMediaHandler constructor calls NativeAudioManager.start({ media: 'video' }), but NativeAudioManager.stop() is never called anywhere in lib/. Neither destruct() nor cleanUpEvents() calls it. After a meeting ends:
- Android:
InCallManagerModule.start()acquires a partial wake lock, requests audio focus and setsdefaultAudioMode(MODE_IN_COMMUNICATION). All three stay active afterleave(), so the device can stay in call mode and other apps' audio can stay ducked. - iOS:
RNInCallManagerkeeps_audioSessionInitialized = YES, the VideoChat session and the idle-timer override. On the next meeting,startreturns early (if (_audioSessionInitialized) return;), so the audio session is not set up again.
There is also a latent signature mismatch. iOS exports stop:(NSString *)busytoneUriType, but NativeAudioManager.stop() passes {} on iOS. Once stop is actually called, debug builds raise a JSON→NSString conversion error.
How to observe (derived from the source; not captured on a device)
- Join a meeting, then
meeting.leave(). - Android:
adb shell dumpsys audioshould still show the communication mode, andadb shell dumpsys powershould still list the wake lock. - iOS: start a second meeting in the same app session.
startshould return at the_audioSessionInitializedcheck, leaving the session as the previous meeting set it.
Suggested fix
Stop the audio manager when local media is torn down and before a new client is created, and pass a string on iOS:
--- a/lib/module/NativeAudioManager.js
+++ b/lib/module/NativeAudioManager.js
@@ -14,7 +14,7 @@
if (media === 'audio') _InCallManager.setVoiceCallMode();
}
stop() {
- Platform.OS === 'android' ? _InCallManager.stop() : _InCallManager.stop({});
+ Platform.OS === 'android' ? _InCallManager.stop() : _InCallManager.stop('');
}
async getIsWiredHeadsetPluggedIn() {
try {
--- a/lib/module/LocalMediaHandler.js
+++ b/lib/module/LocalMediaHandler.js
@@ -880,6 +880,7 @@
this.stopVideoTrack();
this.stopScreenShareTracks();
if (Platform.OS === 'android') this.#appStateSubscription?.remove();
+ NativeAudioManager.stop();
}
stopAudioTrack() {
this.rawAudioTrack?.stop();
--- a/lib/module/ReactHooks.js
+++ b/lib/module/ReactHooks.js
@@ -9,6 +9,7 @@
import { deviceChangeListener } from './LocalMediaUtils';
import { broadcastEmitter } from './LocalMediaHandler';
import LocalMediaHandler from './LocalMediaHandler';
+import NativeAudioManager from './NativeAudioManager';
/**
* Public configuration for the Android meeting foreground service.
@@ -157,6 +158,7 @@
function cleanUpEvents() {
webRTCModuleEmitter.removeAllListeners('audioSamples');
deviceChangeListener.removeAllListeners('onAudioDeviceChanged');
+ NativeAudioManager.stop();
BackgroundTimer.stop();
try {
if (Platform.OS === 'android') {
This is a minimal fix with two known limits:
destruct()also runs when the server moves the participant off stage (stage.leave()→cleanupSelf). With this patch, InCallManager is not restarted if the participant comes back on stage with the same handler. A complete fix probably needssetupAudioStreamto callstartagain when needed. We haven't tested the stage case.InCallManageris a process-wide singleton. If the previous client'sleave()finishes after a new meeting has started (e.g. during the connected-meetings hot-swap inuseRealtimeKitClient), itsdestruct()stops the new meeting's audio manager. Tracking which handler started it would avoid this.
- Dominant language
- TypeScript
- Stars
- 74
- Forks
- 26
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/realtimekit-ui
-
bug: [React Native/Android] KeepAliveService never starts when CAMERA is not granted (Android 14+)Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/realtimekit-ui#208 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
cloudflare/realtimekit-ui#205 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
cloudflare/realtimekit-ui#198 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
cloudflare/realtimekit-ui#167 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
cloudflare/realtimekit-ui#164 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
All issues in cloudflare/realtimekit-ui
Similar issues
-
area: batch
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
inabagumi/shinju-date#7294 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
streaming-video-technology-alliance/common-media-library#700 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
vercel-labs/ui#809 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
KrisCris/village-in-the-shade-guide#75 ·
Maintainers usually reply within 1 day
-
bot:ai-assisted component:platform-js status:untriaged
Difficulty 1/5 Under an hour Newbie friendliness 74/100
midnightntwrk/platform-js#38 ·