Skip to content

Commit

Permalink
Update JitsiStreamPresenterEffect.js (jitsi#7362)
Browse files Browse the repository at this point in the history
* Update JitsiStreamPresenterEffect.js
Create/terminate the Web Worker on effect start/stop so that we don't leak them.
  • Loading branch information
miticc06 committed Jul 21, 2020
1 parent eaa7158 commit eb1ef0f
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ export default class JitsiStreamPresenterEffect {

// Bind event handler so it is only bound once for every instance.
this._onVideoFrameTimer = this._onVideoFrameTimer.bind(this);
this._videoFrameTimerWorker = new Worker(timerWorkerScript, { name: 'Presenter effect worker' });
this._videoFrameTimerWorker.onmessage = this._onVideoFrameTimer;
}

/**
Expand Down Expand Up @@ -136,6 +134,8 @@ export default class JitsiStreamPresenterEffect {
this._desktopElement.srcObject = desktopStream;
this._canvas.width = parseInt(width, 10);
this._canvas.height = parseInt(height, 10);
this._videoFrameTimerWorker = new Worker(timerWorkerScript, { name: 'Presenter effect worker' });
this._videoFrameTimerWorker.onmessage = this._onVideoFrameTimer;
this._videoFrameTimerWorker.postMessage({
id: SET_INTERVAL,
timeMs: 1000 / this._frameRate
Expand All @@ -153,6 +153,7 @@ export default class JitsiStreamPresenterEffect {
this._videoFrameTimerWorker.postMessage({
id: CLEAR_INTERVAL
});
this._videoFrameTimerWorker.terminate();
}

}

0 comments on commit eb1ef0f

Please sign in to comment.