Sketch seems laggy on primary display but not on secondary one

This is something I’ve noticed recently while working on a game with Processing. I plug in my second monitor (1440p) and run my sketch at full screen and it’s smooth, no problem.

I try to run the same program on my primary laptop display and I start to see noticeable lag, like the framerate drops. Same thing when no other display is plugged in.

I looked into this more and made a simple program to be sure, and sure enough there is an issue. Even in windowed mode with a very basic sketch (see below), on my second monitor the circle glides across the screen smoothly, and once I drag the window to my laptop screen I can see lag…

The framerate from my second monitor is about 59 I believe, and on the first one it’s 60.02. I tried using frameRate() and set it to 60, 50, 59… to no avail. This is really strange and might only be an issue with my computer but thought I would reach out here.

Thanks for your help in advance.

int x = 0;

void setup() {
  size(500, 300);
  //frameRate(60);
}


void draw() {
  background(0);
  fill(255);
  ellipse(x, height / 2, 50, 50);
  x += 5;
  if(x > width) x = 0;
}

What OS and graphics card are you using?

Some laptops will use integrated graphics by default for their display, but might revert to an external GPU to drive the monitor. You might need to tell the OS or the video driver to always use your GPU with your application, i.e., with Processing. Check your video driver settings, in any case. Does it have vsync enabled for both display? If vsync is enabled (probably is), try disabling it to compare the two.

Are you running the sketch full screen on the laptop screen or is it trying to share video memory with a web browser with half a dozen youtube videos in the background like my son does?

Have your sketch print out the frameRate every so often so you have some more concrete data to compare them. Add

if( (frameCount % 300) == 0 ) println( frameRate );

at the end of draw(). Does it change if you drag the app (in windowed, not fullscreen) between the screens?

1 Like

Hello @nicolaskellum,

This topic may be of interest:

:)

1 Like

Thanks for the replies, I will check these things when I have some time :slight_smile:

One display could have slower Digital Signal Processing hardware than the other, or render a few frames behind the other.
Maybe the thermionic tubes need to heat up. Lol.

I recently had a similar project and encountered some difficulties. Some of my friends suggested that I change a monitor. Maybe you can also try TFT LCD. I’ve used it before. It’s really an excellent monitor
www.stoneitech.com

Kind of late to update this, but it looks like forcing the OS to use the right graphics card for the screen / application made things better. Thanks!