Second-long freezes with WebGL in Firefox (maybe PRIME-related?)

I’ve got intermittent freezes on my laptop when Firefox displays WebGL content in Firefox (for example, any of the WebGL samples you’ll find with a quick googling). A definite trigger for these freezes are moving the browser window while the WebGL content is displayed. The whole system (or at least, the display side of it) freezes for a few seconds, then continues normally afterwards, until it freezes again after some time. The Xorg.log shows “(WW) NVIDIA: Wait for channel idle timed out.” for each freeze.

This happens only in Firefox, not in Chrome, and also not with, for example, glxgears. So this might be a Firefox issue or a nvidia issue Firefox triggers. It’s not a Firefox profile issue, because it also happens in a fresh Firefox profile. I think I’ll also open up a bug report with Firefox.

It also only happens on my laptop and not on my desktop system. The laptop is a Thinkpad E570 with an NVIDIA Corporation GM107M [GeForce GTX 950M], and from what I understand, the display is hooked up the on-CPU Intel GPU, so it might be a PRIME issue.

The nvidia-drivers version is 470.63.01, Xorg 1.20.13, Linux kernel 5.14.2, all running on a Gentoo distribution. The desktop system, where the problem is not occuring, is identical.

Is there any debug output I can enable that would help getting to the bottom of this?

(Full system specs: Heimbs system specs · GitHub)