Possible interaction: direct2d + Nvidia frame-rate limit -> bad slowdowns? (deep dive)

Hi all. I may have discovered the root cause of some host issues I was seeing. I’m not sure if it is just my setup though. Looking for help to validate.

TLDR

Nvidia’s “Max Frame Rate” and Nvidia “Background Application Max Frame Rate” settings may freeze/slow some hosts (even when set above screen refresh). These settings are commonly changed on gaming machines. I don’t think it is the host’s fault. I see this on my AMD, Nvidia 4070, Win 10 computer running reaper.exe. I would like to know if others can repro this.

Background

I noticed my plugins would lock up my host (Reaper) if I had lots of instances on-screen at once. I solved this by switching my code to attach to opengl but I wanted to get d2d working.

@matt was working really hard to try and diagnose my issues and made a ton of changes but the core issue remained: too many d2d plugins (sometimes needed to be different plugins) open at once locked up the host.

He couldn’t repro the issue though, which was curious. And then I couldn’t repro on another machine with Intel graphics. So I started digging.

Repro case

  • Pick any modern JUCE d2d plugin that updates at 60fps (I can supply minimal test source code if you need one). Use JUCE ver 8.0.6 (others may also work, dunno). Load a track in Reaper, and pick a slider, and use Reaper’s “parameter automation” to randomly wiggle it. It needs to update at 60fps.
  • Double click the plugin name to pop it out of the FX chain to its own window.
  • Duplicate that track 4-10 times so there are multiple editors visible. For plugins that update every frame, host may lock up (for me, anyway).
  • Sometimes you need to save the project and re-open it 2-3 times to trigger the lockup.

Data point 1: My lockups stopped with Nvidia “Max Frame Rate” and “Background Application Max Frame Rate” set “Off”

  • I was not able to repro the issue when I set my driver settings to default.
  • I started adding settings back and “Background Application Max Frame Rate” triggered the issue, up to a limit of about 150fps.
  • “Max Frame Rate” set to 60fps also triggered the issue.

Thought: It can’t just be Reaper, can it?

Data point 2: other apps have big issues with that setting:

Chrome is fine, but some chrome-derived browsers choke when that setting is on:

Global ‘Background Application Frame Rate’ is set to ‘60’. Setting it to unlimited fixes the problems.

Hmm. That’s weird.

Data point 3: Reaper DOES NOT display the issue if you rename it to chrome.exe (!!!)

  • I was trying to figure out why Chrome was OK but Chrome-derived browsers weren’t. I had a look through the Chrome repository and couldn’t find anything.
  • Then I remembered some GPU makers got caught out doing weird stuff years ago with optimization when called from specifically-named binaries, so I renamed reaper.exe to chrome.exe.
  • When I did that, the problem went away.

Repeating that: with that frame rate limit on, for my test setup on my machine,

  • reaper.exe locks up
  • identical binary renamed to chrome.exe works fine

???

Anyway here’s a video of it:

:thinking:

My nvidia driver is set to default for chrome.exe so any override is maybe (?) happening lower down:

Data point 4: these might be common issues?

Other folks are seeing issues in Reaper:

“yep. some cause the ui to freeze completely, and it’s even hard to close the plugin sometimes”

I couldn’t repro in Ableton Live. Haven’t checked other hosts.

Last bit of info: it’s basically impossible to detect if that setting is enabled in any nice way. The setting is buried in an encrypted nvidia data file, and the nvidia API provided to access it refuses to allow it to be read without getting deep into the weeds. More info here: Background Application Max Frame Rate · Issue #79 · Orbmu2k/nvidiaProfileInspector · GitHub

If this isn’t meaningfully fixable, I intend to work around it by putting a screen into my installer saying “please don’t do this”. It might be possible to detect lockups happening at runtime at the JUCE level though?

My theory is: I suspect every separate plugin window’s “present” call (per-frame) is adding towards the “frames per second” counter, and any window that is partly obscured is classed as “background”.

Also thanks again to @matt who worked really hard to figure out what was going on in my system.

Can anyone else shed light on this, or repro - is this just my system? Thanks.

2 Likes

Impressive work, @remaincalm

Matt

1 Like

(…no-one else able to confirm this behaviour? it can’t just be this system, surely?)

anyway so i’m just going to add this to my installer and be done with it:

First off, a huge thank you for this post because I wouldn’t have made the connection otherwise. I’ve spent ages trying to figure out why I couldn’t have more than one of my plugin GUIs open without locking up the host (also Reaper in my case). I realized it was also happening to plugins from other developers which were JUCE-based, one GUI of my plugin + another GUI from a different plugin would also cause lockups. I also tested in Tracktion Waveform and it had the same problem.

A small addition: it’s not just the NVIDIA control panel frame limiter that causes the issue, it’s any frame limiter. In my case, I was using Riva Tune Statistic Server (RTSS) which is a very common frame limiter amongst gamers. Adding an exclusion for Reaper immediately eliminated the lockups, and my plugin UI is also running much smoother with fewer stutters. CPU and GPU usage for Reaper also dropped significantly.

1 Like

Oh, thanks! It’s really great to hear that someone else was able to get a confirmed repro of that behaviour - I was starting to think it might have just been my system.

I wasn’t able to get a better solution than just popping up a warning in the installer. If anyone has better ideas on detecting that condition (maybe checking if successive calls to vsync update callback are really spaced out or something…) that’d be useful to know.

Cheers!

We use JUCE 8.0.10. A user with an NVIDIA card reported that our plug-in graphics slow down and finally freeze after a few seconds (TAL Software), even with only one plug-in window open. This happened in Ableton Live. The same plugin worked in Reaper without issues.

We use a timer that calls repaint every 20 ms. No VBlank or other special things.

The user reported that setting MaxFrameRate OFF and Background Application Max Frame Rate OFF as suggested above improved the situation, but he still had short freezes, and the UI still had some lag.

Only disabling the GPU for Ableton Live fixed the problem.

I found this troubleshooting guide by Ableton that also recommends trying this:
https://help.ableton.com/hc/en-us/articles/209071269-Reducing-the-CPU-load-on-Windows#h_01FDF1TF065R756HGWVCXQWSZ4

1 Like