Bug 189 : save() and saveFrame() can be slow or throttle cpu with JAVA2D on Mac OS X
Last modified: 2006-03-31 05:51




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P3
Severity:
normal

 

Reporter:
fry
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2005-10-29 17:26
boolean clicked= false;

void setup() {
size(800, 600, JAVA2D); //trouble. first 16%. then after clicked save 78%!
//size(800, 600, P3D); //ok. stays put at 34%
framerate(15);
}

void draw() {
line(10, 10, random(width), random(height));
if(mousePressed&&clicked==false) {
save("asdf.tif");
//saveFrame("asdf.tga"); //same with saveFrame and tga
clicked= true;
println("saved");
}
}
Additional Comment #1 From fry 2005-10-29 17:27
Additional Comment #2 From fry 2006-03-28 05:09
seems to be the same issue, for some reason it often takes a long time to save images using
saveFrame() on OS X. haven't yet been able to reproduce the problem, but getting several
reports. if anyone has a sketch that reliably reproduces the bug, please post, along with details
of their setup.
Additional Comment #3 From backspaces 2006-03-30 10:00
I've taken my initial model that exhibited the problem and simplified it.
To run the test, simply choose between one of the two wintypes at the top of the program.

String wintype = JAVA2D; // Creates one image then hangs
//String wintype = P3D; // Works fine.

int numCars = 1000;
boolean makeMovie = true;

Car[] cars = new Car[numCars];

void setup() {
size(500, 500, wintype);
println("wintype="+wintype+" numCars="+numCars+" makeMovie="+makeMovie);
for (int i=0; i<numCars; i++)
cars[i] = new Car(color(255,0,0), random(width),random(height));
}

void draw() {
background(0);

for (int i=0; i<numCars; i++)
cars[i].move(random(-2,2),random(-2,2));

if (makeMovie)
saveFrame();
println("framerate="+framerate+" frameCount="+frameCount);
}

class Car {
float xpos, ypos;
color c;

Car(color c, float x, float y) {
xpos = x;
ypos = y;
this.c = c;
}
void move(float dx, float dy) {
xpos = max(min(xpos+dx,width), 0);
ypos = max(min(ypos+dy,height),0);
fill(c);
noStroke();
rect(xpos,ypos,2,2);
}
}
Additional Comment #4 From backspaces 2006-03-30 10:02
Well, as usuall the BBs mangle the text. Here's the original:
http://backspaces.net/files/testSaveFrame.pde
Let me know if you need more help.
Additional Comment #5 From fry 2006-03-31 05:51
woohoo! found it. the issue is described here:
http://www.jhlabs.com/ip/managed_images.html

the upshot is a huge performance increase for JAVA2D any time that images
or loadPixels() (things like get/set/etc).

thanks for posting the example.
Additional Comment #6 From fry 2006-03-31 05:51
fixed for revision 0112/