소스 검색

fix(electron7):memory leak when the page is hidden

It happens when you are drawing into hidden canvas.
j8
Hristo Terezov 5 년 전
부모
커밋
eea87be801
1개의 변경된 파일13개의 추가작업 그리고 0개의 파일을 삭제
  1. 13
    0
      react/features/large-video/components/LargeVideoBackground.web.js

+ 13
- 0
react/features/large-video/components/LargeVideoBackground.web.js 파일 보기

@@ -211,6 +211,19 @@ export class LargeVideoBackground extends Component<Props> {
211 211
      * @returns {void}
212 212
      */
213 213
     _updateCanvas() {
214
+        // On Electron 7 there is a memory leak if we try to draw into a hidden canvas that is part of the DOM tree.
215
+        // See: https://github.com/electron/electron/issues/22417
216
+        // Trying to detect all the cases when the page will be hidden because of something not in our control
217
+        // (for example when the page is loaded in an iframe which is hidden due to the host page styles) to solve
218
+        // the memory leak. Currently we are not handling the use case when the page is hidden with visibility:hidden
219
+        // because we don't have a good way to do it.
220
+        // All other cases when the canvas is not visible are handled trough the component props
221
+        // (hidden, _shouldDisplayTileView).
222
+        if (!this._canvasEl || this._canvasEl.offsetParent === null
223
+                || window.innerHeight === 0 || window.innerWidth === 0) {
224
+            return;
225
+        }
226
+
214 227
         const { videoElement } = this.props;
215 228
         const { videoWidth, videoHeight } = videoElement;
216 229
         const {

Loading…
취소
저장