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(largeVideo-bg):render canvas only when visible

Hristo Terezov809ac42e4c60
diff --git a/modules/UI/videolayout/VideoContainer.js b/modules/UI/videolayout/VideoContainer.js
index 7b2fa87272..0b9ddf7a2c 100644
--- a/modules/UI/videolayout/VideoContainer.js
+++ b/modules/UI/videolayout/VideoContainer.js
@@ -206,6 +206,8 @@ export class VideoContainer extends LargeContainer {
*/
this._hideBackground = true;
+ this._isHidden = false;
+
/**
* Flag indicates whether or not the avatar is currently displayed.
* @type {boolean}
@@ -561,6 +563,8 @@ export class VideoContainer extends LargeContainer {
FADE_DURATION_MS,
1,
() => {
+ this._isHidden = false;
+ this._updateBackground();
resolve();
}
);
@@ -578,6 +582,8 @@ export class VideoContainer extends LargeContainer {
return new Promise(resolve => {
this.$wrapperParent.fadeTo(FADE_DURATION_MS, 0, () => {
this.$wrapperParent.css('visibility', 'hidden');
+ this._isHidden = true;
+ this._updateBackground();
resolve();
});
});
@@ -635,7 +641,7 @@ export class VideoContainer extends LargeContainer {
ReactDOM.render(
<LargeVideoBackground
- hidden = { this._hideBackground }
+ hidden = { this._hideBackground || this._isHidden }
mirror = {
this.stream
&& this.stream.isLocal()
diff --git a/react/features/large-video/components/LargeVideoBackground.web.js b/react/features/large-video/components/LargeVideoBackground.web.js
index 4cfe510dc3..59a9cfc97d 100644
--- a/react/features/large-video/components/LargeVideoBackground.web.js
+++ b/react/features/large-video/components/LargeVideoBackground.web.js
@@ -2,6 +2,9 @@
import React, { Component } from 'react';
+import { connect } from '../../base/redux';
+import { shouldDisplayTileView } from '../../video-layout';
+
/**
* Constants to describe the dimensions of the video. Landscape videos
* are wider than they are taller and portrait videos are taller than they
@@ -21,6 +24,14 @@ export const ORIENTATION = {
*/
type Props = {
+ /**
+ * Whether or not the layout should change to support tile view mode.
+ *
+ * @protected
+ * @type {boolean}
+ */
+ _shouldDisplayTileView: boolean,
+
/**
* Additional CSS class names to add to the root of the component.
*/
@@ -83,7 +94,9 @@ export class LargeVideoBackground extends Component<Props> {
* @returns {void}
*/
componentDidMount() {
- if (this.props.videoElement && !this.props.hidden) {
+ const { _shouldDisplayTileView, hidden, videoElement } = this.props;
+
+ if (videoElement && !hidden && !_shouldDisplayTileView) {
this._updateCanvas();
this._setUpdateCanvasInterval();
}
@@ -95,15 +108,18 @@ export class LargeVideoBackground extends Component<Props> {
* @inheritdoc
*/
componentDidUpdate(prevProps: Props) {
- if (prevProps.hidden && !this.props.hidden) {
- this._clearCanvas();
- this._setUpdateCanvasInterval();
- }
-
- if ((!prevProps.hidden && this.props.hidden)
- || !this.props.videoElement) {
- this._clearCanvas();
- this._clearUpdateCanvasInterval();
+ const wasCanvasUpdating = !prevProps.hidden && !prevProps._shouldDisplayTileView && prevProps.videoElement;
+ const shouldCanvasUpdating
+ = !this.props.hidden && !this.props._shouldDisplayTileView && this.props.videoElement;
+
+ if (wasCanvasUpdating !== shouldCanvasUpdating) {
+ if (shouldCanvasUpdating) {
+ this._clearCanvas();
+ this._setUpdateCanvasInterval();
+ } else {
+ this._clearCanvas();
+ this._clearUpdateCanvasInterval();
+ }
}
}
@@ -216,3 +232,22 @@ export class LargeVideoBackground extends Component<Props> {
}
}
}
+
+/**
+ * Maps (parts of) the Redux state to the associated LargeVideoBackground props.
+ *
+ * @param {Object} state - The Redux state.
+ * @private
+ * @returns {{
+ * _shouldDisplayTileView: boolean
+ * }}
+ */
+function _mapStateToProps(state) {
+ return {
+ _shouldDisplayTileView: shouldDisplayTileView(state)
+ };
+}
+
+
+export default connect(_mapStateToProps)(LargeVideoBackground);
+