Issue Details (XML | Word | Printable)

Key: TRIDENT-2
Type: Improvement Improvement
Status: Open Open
Priority: Minor Minor
Assignee: Unassigned
Reporter: Boomah
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
trident

Animations under linux are jerky

Created: 25/Jun/09 09:42 AM   Updated: 07/Jul/09 05:54 PM
Component/s: core
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Environment:

Ubuntu 8.04, Sun Java6 update 14


Tags:


 Description  « Hide

Hi Kirill.

On part 7 of your examples (http://www.pushing-pixels.org/?p=1303&cpage=1#comment-9837), the webstart application looks great on windows but awful on Linux. It jerks about and almost flashes. I don't think this is your fault though as I ran into this problem when using the timingframework.

Someone came up with a solution here:

http://forums.java.net/jive/thread.jspa?threadID=38821&tstart=0

and sure enough, when I move my mouse about it smooths everything out and looks great. I don't want to have to constantly move my mouse though and unfortunately I never got the second solution (Toolkit.getDefaultToolkit().sync()) to work.

Do you have any suggestions on how to solve this issue?

Thanks, Nick.



kirillg added a comment - 04/Jul/09 12:57 AM

Finally got around to installing the latest Ubuntu and OpenJDK. Running this WebStart link on my machine, i don't see any jerkiness - i'm not moving the mouse or using Toolkit.sync().

Can you provide a little bit more information about your system? OS, OpenJDK version + CPU specifications?

Also, since you've mentioned TimingFramewor has the same problem, perhaps this has nothing to do with Trident. At the very basic level, Trident has a thread that wakes up every 40ms and handles all timelines. Can you create a Trident-less application that has a Thread running in an infinite loop and calling repaint() on some JPanel every 40ms. Then, print tracing statements in the JPanel.paintComponent() to see what are the time intervals between successive invocations of this method - since JComponent.repaint() is effectively an asynchronous call that can coalesce multiple painting events - and this is what might be happening based on your description.

Thanks
Kirill


kirillg added a comment - 04/Jul/09 12:59 AM

Apologies - just saw that you're using Ubuntu 8.04 and Sun JDK 6u14. Can you run this on the latest Ubuntu distribution so that we have the same latest versions to compare against? I've ran this demo with Sun JDK - my previous comment was incorrect since there are problems with OpenJDK WebStart for Trident [1].

Thanks
Kirill

[1] http://kenai.com/jira/browse/TRIDENT-1


kirillg added a comment - 04/Jul/09 01:12 AM

This is a sample application that test threading / repainting as done in Trident:

package test;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.*;

public class Tracing extends JFrame {
public Tracing() {
final JPanel mainPanel = new JPanel() {
long lastPainted = -1;

@Override
protected void paintComponent(Graphics g) {
long curr = System.currentTimeMillis();
long diff = (curr - lastPainted);
if (lastPainted > 0) { System.out.println("Painting interval is " + diff); }
lastPainted = curr;
super.paintComponent(g);
g.setColor(Color.black);
g.drawString("" + lastPainted, 10, 20);
}
};

this.add(mainPanel);
this.setSize(300, 200);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

new Thread() {
long lastLoop = -1;

@Override
public void run() {
while (true) {
try { Thread.sleep(40); } catch (InterruptedException e) { e.printStackTrace(); }
long curr = System.currentTimeMillis();
long diff = (curr - lastLoop);
if (lastLoop > 0) { System.out.println("Sleeping interval is " + diff); }
lastLoop = curr;
mainPanel.repaint();
}
}
}.start();
}

public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { new Tracing().setVisible(true); }
});
}

}

Can you run this on your machine and attach a few lines of the output? On my Windows box it prints this:

Sleeping interval is 40
Painting interval is 46
Sleeping interval is 40
Painting interval is 16
Sleeping interval is 41
Painting interval is 40
Sleeping interval is 41
Painting interval is 41
Sleeping interval is 40

For every timing pulse, there's a matching repaint. Perhaps on your Ubuntu box there will be many more sleeps than paints? In this case i would guess you'll need to call paintImmediately instead of using SwingRepaintTimeline that just calls repaint().

Thanks
Kirill


Boomah added a comment - 06/Jul/09 07:46 AM

Hi Kirill. I've not got the latest Ubuntu installed. I'll be able to update my home pc, but not for a couple of days. However, when I had the problem with the TimingFramework a while ago, it wasn't a hardware problem as I was dual booting. It looked fine on windows, but bad on linux. I've ran the sample program you have supplied and this is the output:

Painting interval is 40
Sleeping interval is 40
Painting interval is 40
Sleeping interval is 40
Painting interval is 41
Sleeping interval is 40
Painting interval is 40
Sleeping interval is 41
Painting interval is 40
Sleeping interval is 40
Painting interval is 40
Sleeping interval is 40
Painting interval is 40
Sleeping interval is 40
Painting interval is 40
Sleeping interval is 40
Painting interval is 41
Sleeping interval is 41
Painting interval is 40
Sleeping interval is 40
Painting interval is 42
Sleeping interval is 40
Painting interval is 38

I don't think it is trident's fault as I've had this problem before, I was just hoping you could get round the problem somehow.

Thanks, Nick.


kirillg added a comment - 07/Jul/09 05:53 PM

As Windows is my only development environment, and i don't see the jerky animations on my Ubuntu installation, i don't think that i can help much in analyzing this problem.

At the present moment this will be left for the interested members of community.

Thanks
Kirill