(Bug?) Touches Array sometimes doesn't remove objects if touch has ended

With this code example:

void setup() {
  fullScreen();
}

void draw() {
  background(0);
  fill(255);
  for (TouchEvent.Pointer p : touches) {
    circle(p.x, p.y, 400);
  }
}

If I touch with one finger, a circle is displayed (at it’s position)
If I touch with a second finger, a second circle is displayed
If I pull up the second finger without changing the position of the first one, the second circle still is being displayed
Only if I move or let go of the first finger, the second circle also disappeares.

Interestingly, the touchEnded() function is still correctly executed when letting go of the second finger.

It’s easiest to test this by holding one finger steadily and then tapping with a second.

Tested on the following devices:

moto g5 (LineageOS 19.1 / Android 11)     : Bug occured
Xiaomi 12 Lite (Android 12)               : Bug occured
Samsung Galaxy A5 2016 (Android 7)        : Bug occured
Honor 9X Lite (Android 9)                 : Bug DIDN'T occur

Video Links:
Xiaomi 12 Lite (Android 12)
Galaxy A5 2016 (Android 7)
Motorola moto g5 (LineageOS 19.1 / Android 11)
I don’t have a Video of the Honor 9X Lite unfortunately

Hi @JoLi,

Interesting…

I’ve now tested it 5mins on my S22(Android 13) and have to say that I can’t reproduce it. :thinking:
I’ve also looked at the processing code and the touches gets updated directly before triggering the touchStarted / touchEnded events, which means that both should have the same issue you described above…
Maybe you can check if the framerate drops or draw is called at all…

void setup() {
  fullScreen();
  textSize(50);
}

void draw() {
  background(0);
  fill(255);
  String msg = String.format("f: %d, t:",int(frameRate));
  for (TouchEvent.Pointer p : touches) {
    msg += " " + p.id;
    circle(p.x, p.y, 400);
  }
  text(msg ,50,50);
}

Cheers
— mnse

1 Like

ezgif-3-02bdfae67b
doesn’t seem like it drops the fps significantly…
I don’t really get what you mean by “or draw is called at all”, because obviously stuff is being displayed, so draw has to be called, or am I wrong?

This should show grey at the beginning,
then red if the last action was touchStarted()
and green if the last one was touchEnded()

color c;

void setup() {
  fullScreen();
  textSize(76);
  textAlign(CENTER);
  fill(255);
  c = color(100);
}

void draw() {
  background(c);
  for (TouchEvent.Pointer p : touches) {
    text(p.id, width*0.5, height*0.5+p.id*76);
    push();
    fill(255);
    circle(p.x, p.y, 400);
    pop();
  }
}

void touchStarted() {
  c = color(100, 0, 0);
}

void touchEnded() {
  c = color(0, 100, 0);
}

Link to video of that code running on my Xiaomi 12 Lite
(Unfortunately I couldn’t convert this video to webp and post it directly here, sorry for the inconvenience…)

1 Like

Hi @JoLi,

Meant maybe graphics is persistent by the devices graphicbuffer. Would be still displayed but without getting updates from draw.
But as far as I spot it correct in your vid the frameRate text is flickering 59/60. So it definitely gets updated …
Nevertheless, I tried it once more to reproduce it on my mobile (+ on my old S9 Android 10) but still no luck. All fine on my device. :person_shrugging:

Cheers
— mnse

I just “achieved” this by tapping shortly with 4 Fingers?
Console doesn’t show any Errors, and the last Event apparently was touchStarted() as the background is red.
I can easily reproduce this about every fourth attempt.
This screen stays until I tap (or hold) again.


also works when using your code example that shows the fps and touches at the top, and the fps doesn’t drop and continues to flicker between 59 and 60. t: shows 0 1 2 3 as it does in my code, too.

1 Like

That’s on my mobile…
ezgif.com-gif-maker

it only “works” if the first finger isn’t moved.
On my mom’s Galaxy A5 2016 it was a bit difficult as even if I didn’t move my finger, it sometimes moved the detected touch of that first finger.