# Sketch seems laggy on primary display but not on secondary one

**URL:** <https://discourse.processing.org/t/sketch-seems-laggy-on-primary-display-but-not-on-secondary-one/35623>\
**Category:** Processing\
**Created:** [March 8, 2022, 9:11pm UTC](https://discourse.processing.org/t/sketch-seems-laggy-on-primary-display-but-not-on-secondary-one/35623 "2022-03-08T21:11:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicolaskellum](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/nicolaskellum/32/15860_2.png) [@nicolaskellum](https://discourse.processing.org/u/nicolaskellum)\
**Post date:** [March 8, 2022, 9:11pm UTC](https://discourse.processing.org/t/sketch-seems-laggy-on-primary-display-but-not-on-secondary-one/35623/1 "2022-03-08T21:11:25Z")

</div>

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.

```auto
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;
}

```

---

<div class="post-metadata">

**Author:** ![scudly](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/scudly/32/5597_2.png) [@scudly](https://discourse.processing.org/u/scudly)\
**Post date:** [March 8, 2022, 9:41pm UTC](https://discourse.processing.org/t/sketch-seems-laggy-on-primary-display-but-not-on-secondary-one/35623/2 "2022-03-08T21:41:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [March 10, 2022, 1:09pm UTC](https://discourse.processing.org/t/sketch-seems-laggy-on-primary-display-but-not-on-secondary-one/35623/3 "2022-03-10T13:09:03Z")

</div>

Hello @nicolaskellum,

This topic may be of interest:

> [@FrameRate hiccups](https://discourse.processing.org/t/framerate-hiccups/11947/15):
>
> I had some fun visualizing the data available to me. I displayed frameRate data (which averages) to framerate calculated from time between frames. [https://processing.org/reference/frameRate.html](https://processing.org/reference/frameRate.html) Code (you will have to select use “true” or “false” to see different modes of output): PrintWriter output; Table table; int time = 16\*60+40; //16s\*60f/s = 960f hiccups end after this time boolean dispMode = true; // "true" stores to file and plots after "time", "false" plots in real time lo…

`:)`

---

<div class="post-metadata">

**Author:** ![nicolaskellum](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/nicolaskellum/32/15860_2.png) [@nicolaskellum](https://discourse.processing.org/u/nicolaskellum)\
**Post date:** [March 10, 2022, 1:30pm UTC](https://discourse.processing.org/t/sketch-seems-laggy-on-primary-display-but-not-on-secondary-one/35623/4 "2022-03-10T13:30:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![seanc4s](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@seanc4s](https://discourse.processing.org/u/seanc4s)\
**Post date:** [March 12, 2022, 12:27am UTC](https://discourse.processing.org/t/sketch-seems-laggy-on-primary-display-but-not-on-secondary-one/35623/5 "2022-03-12T00:27:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![SantosCuccia](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@SantosCuccia](https://discourse.processing.org/u/SantosCuccia)\
**Post date:** [March 30, 2022, 5:51am UTC](https://discourse.processing.org/t/sketch-seems-laggy-on-primary-display-but-not-on-secondary-one/35623/6 "2022-03-30T05:51:36Z")

</div>

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](https://www.stoneitech.com)

---

<div class="post-metadata">

**Author:** ![nicolaskellum](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/nicolaskellum/32/15860_2.png) [@nicolaskellum](https://discourse.processing.org/u/nicolaskellum)\
**Post date:** [April 12, 2022, 8:54pm UTC](https://discourse.processing.org/t/sketch-seems-laggy-on-primary-display-but-not-on-secondary-one/35623/7 "2022-04-12T20:54:50Z")

</div>

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!
