FAQ
Cover
\
Build
\
Source
\
Bugs
\
Reference
\
Libraries
\
Tools
The bugs database has moved
here
.
Bug 766 : Frame skipping with processor intensive applets using 1.6 JVM
Last modified: 2008-08-15 08:54
P
roject:
processing
trash
Version:
unspecified
Co
m
ponent:
android
book
core
libraries
pde
reference
tools
web
Status:
ASSIGNED
Resolution:
-
Pr
i
ority:
P2
Severity:
normal
Platform
All
O
S:
All
Windows
Mac OS
Linux
Other
Reporter:
ewjordan
Assigned To:
fry
Attachment
Type
Created
Size
Actions
Description
: Opened: 2008-05-04 16:49
Rev 0135
OS: Mac OS X 10.5.2, Windows XP SP2, Vista (not checked on Linux)
Java version 1.6
Using either Java2d or P3D with Java 1.6, sketches that do a lot of
computation per frame (enough to cause significant frame rate reduction)
are not only causing frame rate reduction, but actual skipping of frame draws.
An applet that usually causes this using Java2d is up at
http://www.jbox2d.org/demos/dominotower.html
- the boxes flying at the
tower should be moving smoothly, which they do using a 1.5 VM, but with 1.6
installed, they skip several frames (unless your computer is really
fast...) between each one drawn.
I will see if I can put together a lightweight Processing sketch to test
this directly.
-ewjordan
Additional Comment
#1 From ewjordan 2008-05-04 17:09
Okay, here's a simple sketch that illustrates the problem, set up to waste
a lot of time in the draw method but keep the JVM from optimizing the loop
away:
void setup() {
size(640,480);//,P3D);
frameRate(60);
}
float x=0;
float y=0;
long wasteTime = 10000000;
void draw() {
background(255);
stroke(0);
rect(x,y,10,10);
x += 10;
y += 10;
if (x>width) x = 0;
if (y>width) y = 0;
float x1 = width/2.0;
float y1 = height/2.0;
for (long i=0; i<wasteTime; ++i) {
x1 += .0001*random(-1.0,1.0);
y1 += .0001*random(-1.0,1.0);
}
ellipse(x1,y1,2,2);
}
You might have to tune the wasteTime variable for your computer. On mine
(Vista with Java 1.6 installed, using the included JVM when in the PDE) it
draws every frame when run from the PDE (the square should move exactly its
own size each frame), but skips substantially when exported and loaded in a
browser or run as an application. Switching to P3D the same problem
exists; OpenGL seems fine.
Additional Comment
#2 From fry 2008-05-05 16:29
k, thanks for tracking this down.
to be clear, are you using the version of processing that includes java--so
when run from the environment it's using 1.4, and then when you export/use
a browser it's using 1.6? or is it something in how the sketch is running
in the environment that is causing problems?
we're making a move to drop 1.4 support, which means that we can rely on
*far* better timing for threads and loops, so hopefully we'll be able to
clear up some of this mess.
Additional Comment
#3 From ewjordan 2008-05-05 23:22
(In reply to
comment #2
)
> to be clear, are you using the version of processing that includes java--so
> when run from the environment it's using 1.4, and then when you export/use
> a browser it's using 1.6? or is it something in how the sketch is running
> in the environment that is causing problems?
That's right, I've got 1.4 running within the PDE, and everything runs
fine, but when I export as application and run with my default VM set to
1.6, massive frame skipping results. Switching my default JVM to 1.5 or
1.4.2 fixes the skipping (though I do have to say, and this surprised me,
overall speed is far better in 1.6, at least for this simple example and on
OS X). Currently I can't test 1.6 within the browser on my Mac, but I've
verified on XP and Vista that 1.6 skips a lot both within and outside of
the browser, whereas 1.4.2 and 1.5 seem fine.
I wouldn't worry too much about this, it's just a good test case to keep in
mind when threading is revisited.
Additional Comment
#4 From fry 2008-05-06 20:51
got it.. well, hopefully the shift to 1.5 will help since i can clean some
things up.. sometime mid-summer when java 6u10 is released we may even
start using that as the default included jre because of its size, speed,
and startup advantages.. will have to see.
Additional Comment
#5 From fry 2008-08-15 08:54
hopefully this is fixed in release 0145, which is now online. if you get a
chance, please test and let me know.
This bug is now being tracked
here
.