fix(base/tracks): prevent crash when starting screenshare with audio and null local audio#16983
fix(base/tracks): prevent crash when starting screenshare with audio and null local audio#16983AmoghParmar wants to merge 2 commits intojitsi:masterfrom
Conversation
… when local audio is missing
|
Hi, thanks for your contribution! |
Hi! I have signed and submitted the ICLA as an individual contributor today (Feb 23, 2026). Looking forward to the review! Thanks. |
| const localTracks = conference.getLocalTracks() || []; | ||
| const hasAudioTrack = localTracks.some((t: any) => t.getType() === 'audio'); | ||
|
|
||
| if (hasAudioTrack) { |
There was a problem hiding this comment.
Why is this hasAudioTrack check needed here? The else block will be executed only when localAudio doesn't exist. Also, addTrack internally calls replaceTrack so using one or the other doesn't make any difference.
There was a problem hiding this comment.
Thanks for the review! You were right, I've simplified the else block by removing the redundant hasAudioTrack check and unnecessary replaceTrack(null, ...) call.
I've also addressed the root cause in actions.any.ts. When replaceLocalTrack is called with oldTrack = null during mic change while screen sharing, it now calls conference.addTrack(newTrack) instead of conference.replaceTrack(null, newTrack) to avoid the "no transceiver for old: null" error.
There was a problem hiding this comment.
Can you let me know the steps to reproduce the "no transceiver for old: null" error. The library should handle this case when replaceTrack is called with oldTrack=null. I am not reproducing any of these issues.
There was a problem hiding this comment.
Helloo @jallamsetty1, to reproduce this issue:
- Firstly we need to create a meeting with another participant.
- After that we need to block microphone permissions from the browser settings.
- Then, Start screen sharing with "Share Tab Audio" enabled.
This triggers the error. I was able to reproduce this on Linux (not just Windows as mentioned in the original issue #16846).
If the library already handles the oldTrack = null case internally, I can revert the actions.any.ts change and keep only the actions.web.ts null guard fix. Please let me know!
There was a problem hiding this comment.
Nope, I am not able to reproduce the issue using the above steps. Audio share works as expected even when the users microphone permissions are revoked mid call. Are you able to attach a video showing how you are reproducing it?
There was a problem hiding this comment.
Hello @jallamsetty1, I was able to reproduce the issue.
Please find the attached screen recording below.
Steps followed:
- Created a new test meeting
- Copied the link and opened in another browser as another participant
- From the moderator window, shared the entire screen with "Share Tab Audio" enabled
Error appears: "Replace track failed - no transceiver for old: null"
Reproduced on: Linux (Chrome)
JITSI-error.webm
Could you please confirm if this reproduction is valid? Should I keep both actions.web.ts and actions.any.ts fixes, or revert actions.any.ts?
… when local audio is missing
31fc94c to
de22b1e
Compare
Fixes #16846
This pull request resolves a critical runtime error (
TypeError: Cannot read properties of null (reading 'setEffect')) that occurs when a user initiates screen sharing with audio while their local microphone is blocked or disconnected.Previously, the application would crash because it attempted to apply an audio mixer effect to a
nulllocal audio track. This change implements proper null safety and improves WebRTC track handling by falling back toaddTrack()when no existing transceiver is found.Testing done
Manual verification was performed on a local development environment to ensure stability.
Manual testing steps:
nulllocal audio state.Verified:
conference.addTrack()instead ofreplaceTrack(null, ...).Screenshots (UI changes only)
Before
After
Proposed changelog entries
Files changed
actions.web.ts- null guard on localAudio before calling setEffect()actions.any.ts- handle null oldTrack in replaceLocalTrack by using addTrack instead of replaceTrackProposed changelog category
/label bug, base/tracks
Submitter checklist
fix(base/tracks)scope.npm run lintwas executed and passed with no errors.Desired reviewers
@saghul @jallamsetty1