Why is frameRate limited when Processing runs in a window?

I’m working on a project in P3D, and I noticed something about performance when the window isn’t focused: the framerate immediately jumps up. I’m working on a relatively beefy PC, so I don’t consider myself limited by performance. When loading and running this simple sketch:

void setup() {
  size(1600, 900, P2D);
  frameRate(999);
  textSize(69);
  textAlign(LEFT, TOP);
}
void draw() {
  background(0);
  fill(255);
  text("FPS:" + frameRate, 0, 11);
}

I get 75 fps (the refresh rate of my monitor) when I am focused on the window. But, when I open another window on top of the processing sketch, the framerate jumps into the 900s. I’ve narrowed the cause of this to the P2D/P3D renderer itself because using the default renderer doesn’t have this limitation. Additionally, this limitation causes frame drops every once in a while, so I’m inclined to disable it. I don’t know the cause of this, or if it can be disabled, but if anyone has some insight I’d be happy to know.

[EDIT]
Insight gathered: when running rocket league in fullscreen, the framerate is unlimited. When running rocket league windowed, the framerate caps at 75 fps. So, by that observation, the window itself is limiting the framerate. So, replacing size() with fullScreen() should make the framerate unlimited, and lo and behold, it does. In the context of making a game, it is another thing to put into an options menu.

2 Likes