Hard stutter on certain HTML animations

You can start Caspar under Windows with parameters, but the first parameter given must be the name of the config-fiel to be used. So for instance:

casparcg.exe casparcg.config --disable-web-security

works very well. I never tried --ignore-gpu-blacklist but I guess, that will work too.

Didikunz is right. I started with config-file but didn’t know that the proces fails otherwise. So it should be something like that:

casparcg.exe casparcg.config --ignore-gpu-blacklist --enable-gpu-rasterization --disable-software-rasterizer

The graphics settings in detail:

Setting Recommended Option Explanation
Image Scaling Off Prevents GPU from scaling resolutions, ensuring CasparCG works with fixed resolutions (e.g., 720p, 1080p).
Anisotropic Filtering Off CasparCG doesn’t require this, and disabling it reduces GPU load.
Antialiasing – FXAA Off Prevents conflicts with OpenGL-based anti-aliasing in CasparCG.
Antialiasing – Setting Application-controlled Lets CasparCG control anti-aliasing as needed.
Antialiasing – Gamma Correction Off Disables unnecessary gamma correction as CasparCG handles this internally.
Antialiasing – Mode Application-controlled Ensures CasparCG has full control over anti-aliasing.
Antialiasing – Transparency Off Disabling this prevents conflicts with CasparCG’s transparency layers.
CUDA – GPUs Select all NVIDIA GPUs Ensures the dedicated NVIDIA GPU is used for CUDA acceleration.
CUDA System Memory Fallback Policy Prefer device memory Prioritizes GPU memory usage for optimal performance.
Triple Buffering On Helps improve OpenGL performance by preloading frames.
Power Management Mode Prefer maximum performance Prevents the GPU from entering power-saving mode, ensuring consistent performance.
Background Application Max Frame Rate Off (0) Ensures the frame rate is not limited when CasparCG is running in the background.
Max Frame Rate Off (0) Allows CasparCG to run at its natural frame rate without restrictions.
Low Latency Mode Off Helps avoid potential conflicts with OpenGL.
Multi-Frame Sampled AA (MFAA) Off Disabling MFAA avoids rendering issues and improves compatibility.
OpenGL GDI Compatibility On Ensures that GDI-based applications (like CasparCG) work correctly with OpenGL.
OpenGL Rendering GPU Select NVIDIA GPU Forces the use of the dedicated GPU instead of integrated graphics.
Texture Filtering – Anisotropic Sample Optimization On Improves GPU efficiency with minimal impact on visual quality.
Texture Filtering – Negative LOD Bias Clamp Prevents unnecessary texture flickering or aliasing effects.
Texture Filtering – Quality High performance Prioritizes performance over quality, which is suitable for CasparCG.
Texture Filtering – Trilinear Optimization On Optimizes GPU load while maintaining acceptable texture quality.
Threaded Optimization Auto Allows the NVIDIA driver to decide if multi-threading is beneficial.
Vertical Sync (V-Sync) Off CasparCG handles its own frame synchronization, so V-Sync can interfere.
Pre-Rendered Virtual Reality Frames 1 Minimizes latency when rendering frames (not critical for CasparCG, but it helps).
Vulkan/OpenGL Present Method Auto or OpenGL Ensures proper OpenGL functionality, as CasparCG relies on OpenGL.

Now that the server is running with parameters as Didikunz suggested, GPU rasterization is working. However, I’m still facing a stuttering issue with the simple text animation in HTML template. The animations only run smoothly when I open the FPS meter in Developer Tools.

Here’s the HTML code. Would you mind testing it?

<!DOCTYPE html>
<html>

<head>
	<title>test</title>
	<style type="text/css">
		body {
			width: 1024px;
			height: 576px;
			margin: 0px auto;
			padding: 0;
			background: transparent;
			overflow: hidden;
			text-rendering: optimizeLegibility;
			-webkit-font-smoothing: antialiased;
		}

		#news {
			position: absolute;
			top: 14px;
			left: 52px;
			width: 885px;
			height: 57px;
			color: wheat;
			font-size: 50px;
			text-align: center;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		#inner {
			position: absolute;
			white-space: nowrap;
			transform: scale(0);
			will-change: transform;
			/* animation: scale 4s linear infinite; */
		}

		#bg {
			position: absolute;
			top: 11px;
			left: 35px;
			width: 925px;
			height: 62px;
			object-fit: fill;
		}

		@keyframes scale {
			0% {
				transform: scale(0);
			}
			40% {
				transform: scale(1);
			}
			80% {
				transform: scale(1);
			}
			100% {
				transform: scale(0);
			}
		}
	</style>
</head>

<body>
	<video src="https://files.catbox.moe/a9v502.webm" width="100%" height="100%" id="bg" autoplay loop muted></video>
	<div id="main">
		<div id="news">
			<span id="inner">MEDIATEK'S MOST POWERFUL FLAGSHIP ANDROID CHIP OFFICIALLY ANNOUNCED</span>
		</div>
	</div>
	</div>

	<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/gsap.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function () {
			var tl = gsap.timeline({ repeat: -1 });
			tl.to('#inner', { scale: 0.96, opacity: 1, duration: 0.5 }, 'label4')
				.to('#inner', { scale: 1, duration: 8})
				.to('#inner', { scale: 0, opacity: 0, duration: 0.6 })
				.to('#inner', { scale: 0,duration: 2 });
		});

		function play() { }

		function stop() { }

		function update(str) { }
	</script>
</body>

</html>

Your file works smooth on my machine. But I tried to optimize gpu rendering in your code although. It’s using the Web Animations API:

test.html (1.8 KB)

First of all, thank you @knoepsche for your time and testing this HTML.

I tried to use Web Animations API, as you suggested, but noticed that if you slow down the animation speed, then this library is also stucking while scaling.

So, the main issue is something at the rendering side because when we enable the FPS meter or other options in the rendering tab in the developer tools or when we open the same file in the browser then animation is smooth and fine with any library.

Can we know what changes happen when we enable options in the Rendering tab?

I was testing this animation issue and found that OBS v30.2.3 plays the animation very smoothly, the same as in the Chrome browser. So after checking the chrome://gpu/ status, I noticed the difference between OBS and CasparCG is that in OBS, WebGPU is disabled.

Maybe WebGPU does indeed have performance issues compared to WebGL or WebGL2? However, I don’t know how to disable WebGPU for testing animation in CasparCG. Does anyone here know how to do it?

CasparCG shows WebGPU enabled in chrome://gpu/

and according to https://webgpureport.org/ webgpu adapter not found or failed.

But the report from https://webgpureport.org/ for the Chrome browser on the same machine has different results.

I hope that helps. Maybe this isn’t related to the animation issue, but I’m sharing it here for information purposes.

Using the --disable-frame-rate-limit flag makes animation smooth but requires additional hardware resources, so I think the frame rate limit should be capped.

is it safe to use this flag with CasparCG ?

I don’t see, how this flag should help, as video always has a fixed framerate and so it cannot show more frames.

The CEF --disable-frame-rate-limit flag generally won’t increase the output frame rate of CasparCG. This attempts to remove any artificial limits on the frame rate at which CEF renders in html template. this allows CEF to render as fast as the hardware allows.

In this case, it is helping to render the animation smoothly, regardless of why the animation is stuttering, but this isn’t a good approach because disabling the frame rate limit is leading to higher CPU and GPU usage.

Hello!
Has anyone found a final solution to this problem?

I also tried it on my machine, but under CasparCG 2.3.0 and it runs smooth. Don’t understand the problem.

No, as far as I’m aware there has not been a solution yet. The problem still exists on 2.4.3.

I had troubles with HTML animations (crawls and rolls) in 2.3.0. too. But there were randomly drops one max two frames somtetimes. This problem disappeared with version 2.4, but a new one appeared, described above by gfurg - 250-500 ms freezing when gpu is enabled. The problem occurs repeatedly, always at exactly in the same point in the animation. For example, in the case of a crawl (roll), every time the last character (row) appears on the screen.

I have tested this simple example:
Roll01.html (2.1 KB)
in both 2.3.0 and 2.4.2 now.

There is an irregular, occasional tiny twitch in the 2.3.0 while in 2.4.2 goes everything and everytime very smoothly BUT there is ONE BIG jump everytime, after the last row appears on the screen.

I have enable-gpu=true in both versions.

Here are two simple examples where the described problem always occurs for me on version 2.4.2

Translate01.html (1.1 KB)

Webm01.html (1.3 KB)

Could someone please try them on their device with version 2.4. (enable-gpu=true) and tell me whether the big stutter when the video stops (Webm01) or when the right edge of the red rectangle appears (Translate01) also appears or not? (notes on settings are marked with exclamation marks in the comments).

Thanks!

Hi everyone,

It looks like the HTML stuttering issue in CasparCG is getting some much-needed attention! There’s an open bug report on the CasparCG GitHub (#1583) that directly addresses this problem, specifically when the GPU is enabled. We’re hopeful that Julusian’s work on this will lead to a fix in an upcoming release. It’s very likely that the issues many of you are experiencing are related to this.

Interestingly, OBS faced a similar HTML stuttering problem in OBS v31.0. that was resolved in their latest version, v31.0.3. They used this Singular.live page for testing and identifying the stutter. This provides us with a great way to independently verify if your issue is the same.

To help diagnose if your particular stuttering is related to the GitHub issue, I recommend the following test:

  1. Test your HTML sample file (or the Singular.live page linked above) in OBS v31.0. Note if you see the stuttering.
  2. Then, test the same file or content in the latest OBS v31.0.3.

If your issue is present in OBS v31.0 but not in v31.0.3, then it’s a strong indicator that what you’re experiencing is indeed the same core problem being tracked in the CasparCG GitHub issue. This will help us confirm and prioritize the fix within CasparCG.

I can confirm that if I play the linked remote page on Singular.live on my CasparCG 2.4.2 with enable-gpu=true, the described problem occurs. With enable-gpu=false not.

Julusian wrote “Many people have been using 2.4 with its CEF117 with varying complexity of templates without issue” on the GitHub, but I think it could be a very complex template where the problem won’t appear simply because specific conditions aren’t met there and conversely, one sufficiently long div with css transformation will reliably invoke it - see my example Translate01.html above.

I’m not skilled enough to imagine how difficult an edit similar to that in OBS would be in casparcg at least for testing.