Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion apps/web/src/hooks/useWebRTCSFU.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ class MockRoom {

let mockRoomInstance: MockRoom;

// Capture the Room constructor options so we can assert adaptiveStream is off.
const { roomCtorSpy } = vi.hoisted(() => ({ roomCtorSpy: vi.fn() }));

vi.mock('livekit-client', () => ({
Room: vi.fn().mockImplementation(() => {
Room: vi.fn().mockImplementation((opts: unknown) => {
roomCtorSpy(opts);
mockRoomInstance = new MockRoom();
return mockRoomInstance;
}),
Expand Down Expand Up @@ -167,4 +171,16 @@ describe('useWebRTCSFU', () => {
expect(thirdStream?.getAudioTracks()).toHaveLength(0);
expect(thirdStream?.getVideoTracks()).toHaveLength(1);
});

it('creates the room with adaptiveStream disabled so screen-share video is not paused', async () => {
await act(async () => {
renderHook(() => useWebRTCSFU({ sessionId: 'session-1', participantId: 'viewer-1' }));
await Promise.resolve();
await Promise.resolve();
await Promise.resolve();
await Promise.resolve();
});

expect(roomCtorSpy).toHaveBeenCalledWith(expect.objectContaining({ adaptiveStream: false }));
});
});
10 changes: 8 additions & 2 deletions apps/web/src/hooks/useWebRTCSFU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,15 @@ export function useWebRTCSFU({
data: { token: string; url: string; roomName: string };
};

// Create and connect room
// Create and connect room.
// adaptiveStream pauses video tracks that livekit doesn't see attached to
// a visible element via track.attach(). We render through a manually built
// MediaStream on a <video> srcObject, so livekit never registers the
// element and would pause the screen-share video — audio keeps flowing,
// video stays black. Disable it: the viewer always shows the one presenter
// stream, so there's nothing to adaptively pause.
const room = new Room({
adaptiveStream: true,
adaptiveStream: false,
dynacast: true,
});

Expand Down
Loading