As grambers is scala based project I first suspected that the problem is related to java-scala version incompatibility. I pretty quickly ruled it out by measuring where the extra time was spent: in Java's graphics2D.drawImage. I then tested the Java2D official example DukeAnim by just adding a measurement around the paint.drawImage call and got the following results on my MacBook Pro:
reynders$ java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04-415-11M3635)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01-415, mixed mode)
reynders$ java DukeAnim
50 draws took 19ms
50 draws took 23ms
50 draws took 24ms
50 draws took 29ms
reynders$ java -version
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode)
reynders$ java DukeAnim
50 draws took 226ms
50 draws took 219ms
50 draws took 222ms
50 draws took 217ms
10x reduction in speed! I ran the same tests on a ages old Lenovo T60p using Java 1.7.0_04:
java -version
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot(TM) Server VM (build 23.0-b21, mixed mode)
java DukeAnim
50 draws took 23ms
50 draws took 33ms
50 draws took 25ms
50 draws took 27ms
So the problem seems to be in the Java 1.7 OSX implementation. As of writing oracle does not accept OSX bug reports in their java bugzilla and the macports site is down I decided to create this blog post as a way to help people with the same problem. I will report a bug to Oracle when possible - if the problem does not go a way before that :)
A dragonfly on a rock in Khao Sok Rainforest, Thailand
I experience the exact same problem. When I measure not the framerate but only the drawimage the performance is slower by 100-150 times.
VastaaPoistaDo you have some new info's?
frank@bgblitz.com