Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Rendering Loop Stuttering On Random App Instances  (Read 1082 times)
0 Members and 1 Guest are viewing this topic.
Offline ghostsoldier23

Junior Member


Medals: 1



« Posted 2013-01-06 06:58:21 »

I'm using a fixed timestep in my rendering loop to interpolate the render positions and maintain a steady framerate of 60fps and update interval of 30tps.

I have a test animation that moves a single image across the screen in a linear path, checking for a minimum timestep on each update.

The odd thing is, the animation is smooth on a majority of the times I launch the program, but sometimes it begins to stutter (i.e. the image "shakes" while moving or jumps ahead/behind in its position a little bit).

What I don't understand, is that the frame-rate monitor has the frame rate and update rate staying steady even while the image is stuttering during the animation.

What could be causing this?  And why is it so inconsistent between application instances?

If you need any code snippets, let me know.

Thanks in advance for your input!
Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #1 - Posted 2013-01-06 07:50:58 »

You can't have a "fixed variable" timestep. It's one or the other. Pointing

Of course we need code snippets. We can't read your mind. persecutioncomplex

Offline jonjava
« Reply #2 - Posted 2013-01-06 10:49:28 »

How much does it jump/stutter? Could be a rounding error (or lack thereof) when drawing or faulty interpolation.

That or it could just be Swing, if you're using that.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ghostsoldier23

Junior Member


Medals: 1



« Reply #3 - Posted 2013-01-06 18:32:48 »

You can't have a "fixed variable" timestep. It's one or the other. Pointing

Of course we need code snippets. We can't read your mind. persecutioncomplex

My mistake.  That was a stupid miswording.  It's a fixed timestep (I'll fix that in the question).

There's a lot of different code snippets, so I figured we should start with speculation and theory and then I can get you any specific sections of code you need (i.e. rendering logic, timestep loop, etc.)

How much does it jump/stutter? Could be a rounding error (or lack thereof) when drawing or faulty interpolation.

That or it could just be Swing, if you're using that.

I'm using Math.round when applying the interpolation to rendering positions.  That should work fine right?

I am using Swing.  The goal of the engine was to use pure Java2D.  Surely it can work....
Offline jonjava
« Reply #4 - Posted 2013-01-06 23:10:07 »

Could be Swing, the code, system clock or a number of things.

A notorious cause can be the inaccurate windows clock which you can force to use a more accurate one by making an infinite daemon loop. The "windows daemon fix" which some call it.

Game loops have been discussed extensively and the slight stutter you mention isn't unheard of:

Game loops:
http://www.java-gaming.org/topics/game-loops/24220/view.html

Stutter discussion:
http://www.java-gaming.org/topics/slight-jerkiness/24311/view.html

Offline ghostsoldier23

Junior Member


Medals: 1



« Reply #5 - Posted 2013-01-07 21:14:12 »

Could be Swing, the code, system clock or a number of things.

A notorious cause can be the inaccurate windows clock which you can force to use a more accurate one by making an infinite daemon loop. The "windows daemon fix" which some call it.


I am actually already using that infinite daemon timer fix.  It does seem to work quite nicely for the Windows timer.

After switching the buffer and display BufferedImages to native image type (Graphics.createNativeImage I think is the method), and adding the -Dsun.java2d.opengl=true VM argument, the stuttering seems to be mostly gone on Windows.  It does still occur on Linux, however.  That actually surprises me quite a bit.... I would've expected Linux to perform better.

That may have something to do with my Graphics driver on Linux.  Not sure.  Are there any known issues with Java2D on Linux?
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #6 - Posted 2013-01-08 01:27:44 »

Unfortunately Java2D just can't be relied upon. Your issues sound like they may be unique to your system or drivers, but that's just the problem – you're always going to have machines that have issues. This is complete guesswork, but in my experience around 10% of people have problems of one kind or anything playing games I have made in Java2D. It's also worth mentioning that Applets are for the most part broken now because of all the security scares (Apple no longer has Java enabled without fiddling, for example), so there is little advantage to using Java2D. You might as well touch the hardware if you have a downloaded app.

See my work:
OTC Software
Offline ghostsoldier23

Junior Member


Medals: 1



« Reply #7 - Posted 2013-01-10 05:05:48 »

I was able to bring the stuttering down to a reasonable minimum on Linux, and nearly eliminate it on Windows.

I find that playing with various things such as BufferStrategy buffer count, render ops, and max-updates in the fixed timestep can make a difference depending on the platform.  That seems reasonable.  It isn't uncommon that you have to adjust video settings in a game to get optimal results.

Setting the JVM flag -Dsun.java2d.opengl=true REALLY helps.  I highly recommend that to anyone having slow rendering/stuttering problems in Java2D.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (12 views)
2014-07-29 18:09:19

Riven (9 views)
2014-07-29 18:08:52

Dwinin (9 views)
2014-07-29 10:59:34

E.R. Fleming (26 views)
2014-07-29 03:07:13

E.R. Fleming (10 views)
2014-07-29 03:06:25

pw (40 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (27 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!