# VideoRecorder class causes FPS drop, fails to dispose properly

**URL:** <https://forum.babylonjs.com/t/videorecorder-class-causes-fps-drop-fails-to-dispose-properly/22611>\
**Category:** Bugs\
**Created:** [July 26, 2021, 2:29pm UTC](https://forum.babylonjs.com/t/videorecorder-class-causes-fps-drop-fails-to-dispose-properly/22611 "2021-07-26T14:29:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrlooi](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mrlooi/32/18406_2.png) [@mrlooi](https://forum.babylonjs.com/u/mrlooi)\
**Post date:** [July 26, 2021, 2:29pm UTC](https://forum.babylonjs.com/t/videorecorder-class-causes-fps-drop-fails-to-dispose-properly/22611/1 "2021-07-26T14:29:56Z")

</div>

Creating the VideoRecorder class creates a noticeable FPS drop

var recorder = new VideoRecorder(engine, { fps: 30, recordChunckSize: 3000, mimeType: “video/webm;codecs=h264” });

Then `recorder.dispose()` does not clear properly, and the FPS drop remains.

In fact, recorder.dispose() then creating another recorder stacks the FPS drops i.e. causing the FPS to drop more and more on each new recorder instantiation

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 26, 2021, 2:34pm UTC](https://forum.babylonjs.com/t/videorecorder-class-causes-fps-drop-fails-to-dispose-properly/22611/2 "2021-07-26T14:34:43Z")

</div>

I am not able to experience this locally at all, I suspect you could go in sofware mode for video envoding or you have another issue 🙂

Could you create a repro in the playground ?

Could you try this mime type ? video/webm;codecs=vp8

---

<div class="post-metadata">

**Author:** ![mrlooi](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mrlooi/32/18406_2.png) [@mrlooi](https://forum.babylonjs.com/u/mrlooi)\
**Post date:** [July 26, 2021, 3:13pm UTC](https://forum.babylonjs.com/t/videorecorder-class-causes-fps-drop-fails-to-dispose-properly/22611/3 "2021-07-26T15:13:32Z")

</div>

vp8 has really bad compression, which creates a ton of artifacts in the rendered output video. h264 is much better

---

<div class="post-metadata">

**Author:** ![mrlooi](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mrlooi/32/18406_2.png) [@mrlooi](https://forum.babylonjs.com/u/mrlooi)\
**Post date:** [July 26, 2021, 3:17pm UTC](https://forum.babylonjs.com/t/videorecorder-class-causes-fps-drop-fails-to-dispose-properly/22611/4 "2021-07-26T15:17:24Z")

</div>

Here’s a super simple PG

[https://playground.babylonjs.com/#2TNRDB](https://playground.babylonjs.com/#2TNRDB)

The FPS tanks to 25 on my system and never recovers. If you don’t notice it because your system is more performance, could try changing i \< 100 or something, maybe that’ll be quite evident

EDIT: WEIRD, if I open or resize the console debugger tools (F12), it goes back to 60 FPS?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 26, 2021, 4:01pm UTC](https://forum.babylonjs.com/t/videorecorder-class-causes-fps-drop-fails-to-dispose-properly/22611/5 "2021-07-26T16:01:25Z")

</div>

The thing is here you are not even recording so you are only creating some pretty heavy Garbage collect from creating and disposing MediaRecorder.

You could do the same by instantiating big Arrays. At a first glance it is not a babylon issue.
