CasparCG / server

CasparCG Server is a Windows and Linux software used to play out professional graphics, audio and video to multiple outputs. It has been in 24/7 broadcast production since 2006. Ready-to-use downloads are available under the Releases tab https://casparcg.com.
GNU General Public License v3.0
901 stars 269 forks source link

requestAnimationFrame leaks #375

Closed ronag closed 7 years ago

ronag commented 8 years ago

requestAnimationFrame leaks in Caspar a few kb every minute.

Example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>

<head>
    <meta charset="UTF-8">
    <title>Test</title>
    <script language="javascript">
        function init() {
            window.requestAnimationFrame(init);
            return;
        }

        function play() {
        }

        function stop() {
        }

        function pause() {
        }

        function resume() {
        }

        function next() {
        }

        function update(str) {
        }

    </script>
</head>

<body onload="init()">HELLO
</body>

</html>

I'm looking into it but haven't had time to quite figure it out. I think the general solution for requestAnimationFrame in CasparCG is a bit hacky. There has to be a better way. We should probably ask the CEF guys.

HellGore commented 8 years ago

Can you see which process is leaking? There probably is another way, yes. Just not a way I am aware of.

hreinnbeck commented 8 years ago

Is this 2.1 Robert?

Running your example on 2.0.7 has a leak (looks like the CEF process). Also in latest Chrome Dev, same leak.

However I'm running constantly updating tickers using requestAnimationFrame on 2.0.7 without any differences in memory usage, it's +-1MB through the day (total usage is always about 39-40MB) - and these tickers run for weeks!

Also your template runs at 2% CPU here, while my ticker is at zero (doing a whole lot more stuff per frame).

ronag commented 8 years ago

It's on 2.0.7.

ronag commented 8 years ago

I solved this by completely removing the custom requestAnimation thing that CasparCG does. As far as I see it makes no difference since CEF will run on it's own clock anyway. There is a bug though where the framerate is set to 25 fps instead of 50 fps in e.g. 1080i5000 which causes animation to be unsmooth.

HellGore commented 8 years ago

Without the custom requestAnimation thing I have never gotten smooth animations with the html producer, not even in 5994 modes. Under what circumstances are you able to get smooth playback without it?