sojamo / controlp5

A gui library for processing.org
GNU Lesser General Public License v2.1
490 stars 142 forks source link

Android Slowdown #130

Open philspitlerSF opened 6 years ago

philspitlerSF commented 6 years ago

I have a weird issue where my sketch gets slower and slower the more Control P5 buttons I have. This behavior only shows up in Processing / Android mode, it seems fine when running in Processing / Java on OSX.

If you look at my code you will see I draw a UI with a bunch of buttons… If I comment out that code my sketch returns a value of 10 seconds which is correct for 24fps. If I leave all the buttons in my sketch the time goes up to 22 seconds… If I leave half the buttons in it is somewhere in the middle… I only create the buttons in setup so it seems odd that I am getting such a drastic slow down…

Any ideas?

Thanks, Phil


import controlP5.*;

Button myButton1;
Button myButton2;
Button myButton3;
Button myButton4;
Button myButton5;
Button myButton6;
Button myButton7;
Button myButton8;
Button myButton9;
Button myButton10;
Button myButton11;

ControlP5 cp5;
int buttonYpos = 0;
int currentFrame = 0;
int Yoffset = -55; 

void setup() {
  frameRate(24);

  size(1200, 1920);

  stroke(255);

  cp5 = new ControlP5(this); // 
  cp5.setFont(new ControlFont(createFont("Arial", 32), 32));
  cp5.setAutoDraw(false);

  // build UI
  myButton1 = cp5.addButton("alloff")

    .setCaptionLabel("All Off")
    .setValue(0)
    .setPosition(100, 250+Yoffset)
    .setSize(500, 60)

    ;

  myButton2 = cp5.addButton("grad")

    .setCaptionLabel("Color Grad")
    .setValue(0)
    .setPosition(100, 350+Yoffset)
    .setSize(500, 60)

    ;

  myButton3 = cp5.addButton("buddah")

    .setCaptionLabel("Pink Buddah")
    .setValue(0)
    .setPosition(100, 450+Yoffset)
    .setSize(500, 60)

    ;

  myButton4 = cp5.addButton("colorwipe")
    .setCaptionLabel("Color Wipe")
    .setValue(0)
    .setPosition(100, 550+Yoffset)
    .setSize(500, 60)

    ;

  myButton5 = cp5.addButton("orange")
    .setCaptionLabel("Orange Blossom")
    .setValue(0)
    .setPosition(100, 650+Yoffset)
    .setSize(500, 60)

    ;

  myButton6 = cp5.addButton("rustySwirl")
    .setCaptionLabel("Embers")
    .setValue(0)
    .setPosition(100, 750+Yoffset)
    .setSize(500, 60)

    ;

  myButton7 = cp5.addButton("psych")
    .setCaptionLabel("psychedelic blue")
    .setValue(0)
    .setPosition(100, 850+Yoffset)
    .setSize(500, 60)

    ;

  myButton8 = cp5.addButton("petals")
    .setCaptionLabel("rainbow petals")
    .setValue(0)
    .setPosition(100, 950+Yoffset)
    .setSize(500, 60)

    ;

  myButton9 = cp5.addButton("sunrise")
    .setCaptionLabel("Sunrise")
    .setValue(0)
    .setPosition(100, 1050+Yoffset)
    .setSize(500, 60)

    ;

  myButton10 = cp5.addButton("smoke")
    .setCaptionLabel("Ice Drops")
    .setValue(0)
    .setPosition(100, 1150+Yoffset)
    .setSize(500, 60)

    ;

  myButton11 = cp5.addButton("allSeq")
    .setCaptionLabel("All Sequences")
    .setValue(0)
    .setPosition(100, 1250+Yoffset)
    .setSize(500, 60)

    ;
} 

void draw() {

  cp5.draw();
  currentFrame = (currentFrame+1);

  if (currentFrame >= 240) { // 10 seconds @ 24fps
    println (millis()/1000); // how many seconds did it actually take?
    stop();
  };
}
sojamo commented 6 years ago

sorry not sure how to help here.