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(ui): guard createRoot/isVisible against missing DOM containers

Jaya Allamsetty11cb9be644c3
diff --git a/modules/UI/util/UIUtil.js b/modules/UI/util/UIUtil.js
index 1ed4b6e23e..c44ceea53f 100644
--- a/modules/UI/util/UIUtil.js
+++ b/modules/UI/util/UIUtil.js
@@ -52,7 +52,7 @@ const UIUtil = {
* @param {el} The DOM element we'd like to check for visibility
*/
isVisible(el) {
- return el.offsetParent !== null;
+ return Boolean(el) && el.offsetParent !== null;
}
};
diff --git a/modules/UI/videolayout/LargeVideoManager.js b/modules/UI/videolayout/LargeVideoManager.js
index 9b8436c5e3..8e4894be85 100644
--- a/modules/UI/videolayout/LargeVideoManager.js
+++ b/modules/UI/videolayout/LargeVideoManager.js
@@ -152,9 +152,6 @@ export default class LargeVideoManager {
= this._onVideoResolutionUpdate.bind(this);
this.videoContainer.addResizeListener(this._onVideoResolutionUpdate);
-
- this._dominantSpeakerAvatarContainer
- = document.getElementById('dominantSpeakerAvatarContainer');
}
/**
@@ -533,8 +530,17 @@ export default class LargeVideoManager {
* Updates the src of the dominant speaker avatar
*/
updateAvatar() {
+ // Re-fetch the container each call rather than caching it in the constructor:
+ // LargeVideo's React subtree can unmount/remount and a cached reference becomes
+ // a detached node. Bail out if the container is not currently in the DOM.
+ const container = document.getElementById('dominantSpeakerAvatarContainer');
+
+ if (!container) {
+ return;
+ }
+
if (!this._avatarRoot) {
- this._avatarRoot = createRoot(this._dominantSpeakerAvatarContainer);
+ this._avatarRoot = createRoot(container);
}
this._avatarRoot.render(
<Provider store = { APP.store }>
diff --git a/modules/UI/videolayout/VideoContainer.js b/modules/UI/videolayout/VideoContainer.js
index 9a11623861..796771f577 100644
--- a/modules/UI/videolayout/VideoContainer.js
+++ b/modules/UI/videolayout/VideoContainer.js
@@ -666,8 +666,17 @@ export class VideoContainer extends LargeContainer {
return;
}
+ const container = document.getElementById('largeVideoBackgroundContainer');
+
+ // LargeVideo's React subtree may not be mounted (e.g. between fade-out and
+ // fade-in, or during reduced-UI transitions). createRoot(null) would throw
+ // React error #200; bail out instead.
+ if (!container) {
+ return;
+ }
+
if (!this._backgroundRoot) {
- this._backgroundRoot = createRoot(document.getElementById('largeVideoBackgroundContainer'));
+ this._backgroundRoot = createRoot(container);
}
this._backgroundRoot.render(
<LargeVideoBackground