Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(large-video): Prevents unnecessary updates when container is hidden

Hristo Terezov6deb0a638595
diff --git a/modules/UI/videolayout/VideoLayout.js b/modules/UI/videolayout/VideoLayout.js
index 143be3df78..6e75816dee 100644
--- a/modules/UI/videolayout/VideoLayout.js
+++ b/modules/UI/videolayout/VideoLayout.js
@@ -158,10 +158,11 @@ const VideoLayout = {
return;
}
+
+ const state = APP.store.getState();
const currentContainer = largeVideo.getCurrentContainer();
const currentContainerType = largeVideo.getCurrentContainerType();
const isOnLarge = this.isCurrentlyOnLarge(id);
- const state = APP.store.getState();
const participant = getParticipantById(state, id);
const videoTrack = getVideoTrackByParticipant(state, participant);
const videoStream = videoTrack?.jitsiTrack;
diff --git a/react/features/large-video/actions.any.ts b/react/features/large-video/actions.any.ts
index 0c0a2d04c2..9df86ad595 100644
--- a/react/features/large-video/actions.any.ts
+++ b/react/features/large-video/actions.any.ts
@@ -11,7 +11,6 @@ import {
getVirtualScreenshareParticipantByOwnerId
} from '../base/participants/functions';
import { toState } from '../base/redux/functions';
-import { isStageFilmstripAvailable } from '../filmstrip/functions';
import { getAutoPinSetting } from '../video-layout/functions';
import {
@@ -19,6 +18,7 @@ import {
SET_LARGE_VIDEO_DIMENSIONS,
UPDATE_KNOWN_LARGE_VIDEO_RESOLUTION
} from './actionTypes';
+import { shouldHideLargeVideo } from './functions';
/**
* Action to select the participant to be displayed in LargeVideo based on the
@@ -34,12 +34,8 @@ export function selectParticipantInLargeVideo(participant?: string) {
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const state = getState();
- if (isStageFilmstripAvailable(state, 2)) {
- return;
- }
-
- // Keep Etherpad open.
- if (state['features/etherpad'].editing) {
+ // Skip large video updates when the large video container is hidden.
+ if (shouldHideLargeVideo(state)) {
return;
}
diff --git a/react/features/large-video/functions.ts b/react/features/large-video/functions.ts
index e326585111..391bc961af 100644
--- a/react/features/large-video/functions.ts
+++ b/react/features/large-video/functions.ts
@@ -1,5 +1,7 @@
import { IReduxState } from '../app/types';
import { getParticipantById } from '../base/participants/functions';
+import { isStageFilmstripAvailable } from '../filmstrip/functions';
+import { shouldDisplayTileView } from '../video-layout/functions.any';
/**
* Selector for the participant currently displaying on the large video.
@@ -12,3 +14,17 @@ export function getLargeVideoParticipant(state: IReduxState) {
return getParticipantById(state, participantId ?? '');
}
+
+/**
+ * Determines whether the large video container should be hidden.
+ * Large video is hidden in tile view, stage filmstrip mode (with multiple participants),
+ * or when editing etherpad.
+ *
+ * @param {IReduxState} state - The Redux state.
+ * @returns {boolean} True if large video should be hidden, false otherwise.
+ */
+export function shouldHideLargeVideo(state: IReduxState): boolean {
+ return shouldDisplayTileView(state)
+ || isStageFilmstripAvailable(state, 2)
+ || Boolean(state['features/etherpad']?.editing);
+}
diff --git a/react/features/large-video/subscriber.any.ts b/react/features/large-video/subscriber.any.ts
new file mode 100644
index 0000000000..75145f527a
--- /dev/null
+++ b/react/features/large-video/subscriber.any.ts
@@ -0,0 +1,26 @@
+import StateListenerRegistry from '../base/redux/StateListenerRegistry';
+
+import { SELECT_LARGE_VIDEO_PARTICIPANT } from './actionTypes';
+import { selectParticipantInLargeVideo } from './actions.any';
+import { shouldHideLargeVideo } from './functions';
+
+/**
+ * Updates the large video when transitioning from a hidden state to visible state.
+ * This ensures the large video is properly updated when exiting tile view, stage filmstrip,
+ * whiteboard, or etherpad editing modes.
+ */
+StateListenerRegistry.register(
+ /* selector */ state => shouldHideLargeVideo(state),
+ /* listener */ (isHidden, { dispatch }) => {
+ // When transitioning from hidden to visible state, select participant (because currently it is undefined).
+ // Otherwise set it to undefined because we don't show the large video.
+ if (!isHidden) {
+ dispatch(selectParticipantInLargeVideo());
+ } else {
+ dispatch({
+ type: SELECT_LARGE_VIDEO_PARTICIPANT,
+ participantId: undefined
+ });
+ }
+ }
+);
diff --git a/react/features/large-video/subscriber.native.ts b/react/features/large-video/subscriber.native.ts
index e69de29bb2..42c4cc5107 100644
--- a/react/features/large-video/subscriber.native.ts
+++ b/react/features/large-video/subscriber.native.ts
@@ -0,0 +1 @@
+import './subscriber.any';
diff --git a/react/features/large-video/subscriber.web.ts b/react/features/large-video/subscriber.web.ts
index f165b7cbdd..9fdf1006fe 100644
--- a/react/features/large-video/subscriber.web.ts
+++ b/react/features/large-video/subscriber.web.ts
@@ -4,6 +4,7 @@ import StateListenerRegistry from '../base/redux/StateListenerRegistry';
import { getVideoTrackByParticipant } from '../base/tracks/functions.web';
import { getLargeVideoParticipant } from './functions';
+import './subscriber.any';
/**
* Updates the on stage participant video.
diff --git a/tests/pageobjects/Filmstrip.ts b/tests/pageobjects/Filmstrip.ts
index d11fb1c4ad..526add951a 100644
--- a/tests/pageobjects/Filmstrip.ts
+++ b/tests/pageobjects/Filmstrip.ts
@@ -136,6 +136,20 @@ export default class Filmstrip extends BasePageObject {
return await elem.isExisting() ? await elem.getAttribute('src') : null;
}
+ /**
+ * Returns true if the endpoint is dominant speaker and false otherwise.
+ * Uses the dominant-speaker class on the video thumbnail in order to check.
+ *
+ * @param {string} endpointId - The endpoint id of the participant we want to check.
+ * @returns {boolean} - True if the endpoint is dominant speaker and false otherwise.
+ */
+ async isDominantSpeaker(endpointId: string) {
+ const elem = this.participant.driver.$(
+ `//span[@id='participant_${endpointId}' and contains(@class,'dominant-speaker')]`);
+
+ return await elem.isExisting();
+ }
+
/**
* Grants moderator rights to a participant.
* @param participant
diff --git a/tests/specs/3way/activeSpeaker.spec.ts b/tests/specs/3way/activeSpeaker.spec.ts
index e5b6ed354b..57ef6c8950 100644
--- a/tests/specs/3way/activeSpeaker.spec.ts
+++ b/tests/specs/3way/activeSpeaker.spec.ts
@@ -61,10 +61,10 @@ async function testActiveSpeaker(
const otherParticipant1Driver = otherParticipant1.driver;
await otherParticipant1Driver.waitUntil(
- async () => await otherParticipant1.getLargeVideo().getResource() === speakerEndpoint,
+ async () => await otherParticipant1.getFilmstrip().isDominantSpeaker(speakerEndpoint),
{
timeout: 30_000, // 30 seconds
- timeoutMsg: 'Active speaker not displayed on large video.'
+ timeoutMsg: `${activeSpeaker.name} is not selected as active speaker.`
});
// just a debug print to go in logs
diff --git a/tests/specs/3way/codecSelection.spec.ts b/tests/specs/3way/codecSelection.spec.ts
index a585544efd..5cd1ff9d7e 100644
--- a/tests/specs/3way/codecSelection.spec.ts
+++ b/tests/specs/3way/codecSelection.spec.ts
@@ -42,6 +42,7 @@ describe('Codec selection', () => {
it('asymmetric codecs with AV1', async () => {
await ensureThreeParticipants({
configOverwrite: {
+ disableTileView: true,
videoQuality: {
codecPreferenceOrder: [ 'AV1', 'VP9', 'VP8' ]
}
@@ -95,6 +96,7 @@ describe('Codec selection', () => {
await ensureThreeParticipants({
configOverwrite: {
+ disableTileView: true,
videoQuality: {
codecPreferenceOrder: [ 'VP8' ]
}