# Basic interactive sketches don't run smoothly

**URL:** <https://discourse.processing.org/t/basic-interactive-sketches-dont-run-smoothly/28751>\
**Category:** Processing\
**Created:** [March 23, 2021, 9:58am UTC](https://discourse.processing.org/t/basic-interactive-sketches-dont-run-smoothly/28751 "2021-03-23T09:58:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![cern](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/cern/32/19208_2.png) [@cern](https://discourse.processing.org/u/cern)\
**Post date:** [March 23, 2021, 9:58am UTC](https://discourse.processing.org/t/basic-interactive-sketches-dont-run-smoothly/28751/1 "2021-03-23T09:58:43Z")

</div>

Hi all,

I’m having the weirdest issue here. I’ve switched to p5js and its been almost a year that I didn’t use Processing on my Macbook (13-inch 2017, running macOS 10.13.6). Now I’m running the Hello World of interactivity and trying to move an ellipse using mouse coordinates. It doesn’t run smoothly as expected. It seems like the frameRate is very low, but I’ve printed it to console, it is pretty normal… around 60 fps. What is wrong? I’ve tried it with Processing 3.5.4 and the alpha version of Processing 4, same result.

Can anyone help me?

Thx,

---

<div class="post-metadata">

**Author:** ![WeinSim](https://avatars.discourse-cdn.com/v4/letter/w/db5fbb/32.png) [@WeinSim](https://discourse.processing.org/u/WeinSim)\
**Post date:** [April 13, 2021, 3:19pm UTC](https://discourse.processing.org/t/basic-interactive-sketches-dont-run-smoothly/28751/2 "2021-04-13T15:19:42Z")

</div>

Maybe the refresh rate of your screen is just really low, or you have some problem with your graphis driver. Simple programs like

```auto
void setup() {
  size(1280, 720);
}

void draw() {
  background(255);
  stroke(0);
  strokeWeight(3);
  fill(255, 180, 0);
  ellipse(mouseX, mouseY, 50, 50);
}

```

should run at 60 fps (or whatever the default maximum is for your machine, but I think in most cases it is 60)

---

<div class="post-metadata">

**Author:** ![cern](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/cern/32/19208_2.png) [@cern](https://discourse.processing.org/u/cern)\
**Post date:** [April 13, 2021, 4:07pm UTC](https://discourse.processing.org/t/basic-interactive-sketches-dont-run-smoothly/28751/3 "2021-04-13T16:07:25Z")

</div>

Thx for the reply!

Yes the frameRate is around 60 fps for this very simple program, but the ellipse is not following the cursor smoothly… And now I’ve observed one more thing, the ellipse doesn’t move while I’m moving the mouse, it jumps to the point of the cursor after I stop moving. It looks like mouse movement is blocking the draw loop but below are the frameRate and frameCount values printed on console, so it seems nothing is wrong? But visually it is very wrong … any ideas?

```auto
59.92041 1
52.982334 2
53.152084 3
53.267273 4
53.658943 5
53.77972 6
54.46967 7
54.439957 8
54.77287 9
54.936268 10
55.223812 11
55.55422 12
55.887882 13
55.88683 14
56.00667 15
56.092365 16
56.363525 17
56.550713 18
56.884026 19
56.872078 20
57.3123 21
57.290966 22
57.44062 23
57.607468 24
57.678425 25
57.498352 26
57.886944 27
57.77772 28
57.771477 29
58.14217 30

```

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [April 13, 2021, 11:07pm UTC](https://discourse.processing.org/t/basic-interactive-sketches-dont-run-smoothly/28751/4 "2021-04-13T23:07:28Z")

</div>

Can you share the code? Also what happens without mouse, for example moving an ellipse with `map(sin(millis()*0.01),-1,1,0,width)` ?

---

<div class="post-metadata">

**Author:** ![cern](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/cern/32/19208_2.png) [@cern](https://discourse.processing.org/u/cern)\
**Post date:** [April 14, 2021, 12:33pm UTC](https://discourse.processing.org/t/basic-interactive-sketches-dont-run-smoothly/28751/5 "2021-04-14T12:33:32Z")

</div>

Thx for the reply @micuat ! I’m using the same code that WeinSim posted…  
There is no problem with animations as you’ve suggested, they are pretty smooth. I’ve tried the code below. But if I move the mouse during this animation, ellipse movement stops, draw continues to loop and prints the frameRate and frameCount 🤯 Any more ideas on what is going wrong?

```auto
void setup() {
  size(1280, 720);
}

void draw() {
  background(255);
  stroke(0);
  strokeWeight(3);
  fill(255, 180, 0);
  
  circle(map(sin(millis()*0.01),-1,1,0,width), height/2, 50);
  
  println(frameRate, frameCount);
  
}

```

This is how the console looks like:

```auto
60.222404 1
52.22927 2
52.530968 3
52.4702 4
53.0685 5
53.471985 6
53.83725 7
53.815617 8
54.29866 9
54.681328 10
54.887657 11
55.160927 12
55.35825 13
55.565506 14
55.550766 15
56.008003 16
55.692516 17
56.208244 18
56.279285 19
56.55302 20
56.83483 21
56.693428 22
56.87931 23
57.259018 24
57.183098 25
57.284416 26
57.57314 27

```

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [April 14, 2021, 12:37pm UTC](https://discourse.processing.org/t/basic-interactive-sketches-dont-run-smoothly/28751/6 "2021-04-14T12:37:30Z")

</div>

Hi @cern,

From what you posted, the framerate is fine and it should run well.

It might be your operating system or your graphic card / drivers…

Also did you try to run Processing alone with no other applications running in the background or windows around?

---

<div class="post-metadata">

**Author:** ![WeinSim](https://avatars.discourse-cdn.com/v4/letter/w/db5fbb/32.png) [@WeinSim](https://discourse.processing.org/u/WeinSim)\
**Post date:** [April 14, 2021, 6:26pm UTC](https://discourse.processing.org/t/basic-interactive-sketches-dont-run-smoothly/28751/7 "2021-04-14T18:26:58Z")

</div>

So if I am understanding this right, the `draw()` method stops being executed as soon as you start moving your mouse, and once you stop moving, `draw()` continues? That seems very odd  
To quantify this, could you maybe add this to your code?

```auto
println(frameCount, frameRate, millis()); //instead of just println(frameRate)

```

---

<div class="post-metadata">

**Author:** ![cern](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/cern/32/19208_2.png) [@cern](https://discourse.processing.org/u/cern)\
**Post date:** [April 14, 2021, 8:07pm UTC](https://discourse.processing.org/t/basic-interactive-sketches-dont-run-smoothly/28751/8 "2021-04-14T20:07:57Z")

</div>

Hi @josephh, I also tried to run Processing alone, no luck…

@WeinSim `draw()` doesn’t stop, it continues to print to console smoothly but the circle stops moving as soon as I start moving the mouse and once I stop moving the mouse the circle continues moving… I’ve also tried to press random keys. I’m trying to understand if any mouse/keyboard input is blocking the canvas update, but pressing keys doesn’t interrupt the animation. Here is the updated console output according to your suggestion:

```auto
57.249493 1 807
47.20708 2 820
47.49295 3 837
48.180977 4 853
48.581757 5 870
49.06544 6 887
49.369396 7 903
49.922966 8 920
50.37355 9 936
50.88027 10 953
51.14275 11 971
51.64865 12 986
51.658867 13 1004
52.260025 14 1020
52.784363 15 1035
53.00308 16 1052
53.223545 17 1069
53.295784 18 1088
53.981346 19 1102
54.115166 20 1120

```

---

<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:** [April 15, 2021, 12:38am UTC](https://discourse.processing.org/t/basic-interactive-sketches-dont-run-smoothly/28751/9 "2021-04-15T00:38:35Z")

</div>

Hello,

It works fine on W10.

Try another renderer and report back.  
_[Environment (IDE) \ Processing.org](https://processing.org/reference/environment/#Renderers)_

size(1280, 720, P2D);  
size(1280, 720, P3D);  
size(1280, 720, FX2D);

`:)`

---

<div class="post-metadata">

**Author:** ![cern](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/cern/32/19208_2.png) [@cern](https://discourse.processing.org/u/cern)\
**Post date:** [April 15, 2021, 7:51am UTC](https://discourse.processing.org/t/basic-interactive-sketches-dont-run-smoothly/28751/10 "2021-04-15T07:51:51Z")

</div>

@glv thank youuu! now it is displaying the animation smoothly 🌟  
It seems I have to use the P2D or FX2D (it also works fine with P3D, but no need in my case since I work with 2D canvas only) I still don’t know why it doesn’t work with the default renderer, but it is solved!
