Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (407)
games submitted by our members
Games in WIP (293)
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  
  No Stable Frame Rate - with Demo  (Read 2330 times)
0 Members and 1 Guest are viewing this topic.
Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Posted 2009-09-19 21:37:46 »

I'm still having trouble getting a really stable smooth framerate on Android devices and I wondered if anyone has got it right? I'm using Android 1.5 with OpenGLES. I use two threads - logic thread and render thread (part of GLSurfaceView). I render with RENDER_ON_DIRTY. Essentially logic loop is:

- calculateWhenTheFrameShouldEnd
- doLogic
- requestRender
- waitTilTheFrameShouldEnd

Render, doesn't do anything exciting, just splatting a few quads to the screen.

While this runs pretty smoothly it still glitches regularly. I've observed this behavior in any GL based animation game that I've tried (including the ones here). They run ok, but it doesn't feel really smooth. To illustrate I knocked a silly game together the last few nights:



Applet: http://www.cokeandcode.com/applets/defend/

Android: http://www.cokeandcode.com/applets/defend/defend-2.apk

While it's just about playable (from a game play point of view) the jitters are still fairly evident. The game creates zero garbage outside of the Android SDK and the logic going is really pretty simple.

Bit confused, not sure why it should be bad, has anyone got a simple example of something that runs really smoothly on the handset and uses GL?

Kev

Offline Ranger
« Reply #1 - Posted 2009-09-20 08:58:49 »

I don't use GLSurfaceView.  I manage the GL thread myself and use EGLContext.getEGL().  Then in the GL thread I use a wait and the game loop calls notify (this is mostly likely how RENDER_ON_DIRTY works).

So I have 3 threads:
- Game loop
- GL thread
- EDT

The game loop thread will spend a lot of time sleeping (as I only target 30fps).  I think this allows other processes to run in the background and gives a more stable frame rate.

I read somewhere that the next version of Android will stop widgets and other background processes from hogging the CPU.
Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #2 - Posted 2009-09-20 10:52:49 »

Yeah, it's the same thing. I get the same behaviour in Craig's Race too.. most of the time it's smooth then jitter.

Kev

Games published by our own members! Check 'em out!
Play the free demo of Revenge of the Titans!
Offline Nate

JGO Wizard


Medals: 81
Projects: 3


Esoteric Software


« Reply #3 - Posted 2009-09-20 11:11:14 »

The 1.5 Android SDK generates garbage. This is ridiculous IMO, but true. There is a thread on their newsgroup somewhere about it. Connect up DDMS using the batch file, not Eclipse, and you can watch the memory allocations in both your code, if any, and the SDK. The SDK causes garbage collection about every 20 seconds on my G1, probably depending on how much OpenGL stuff you are doing. Maybe they'll fix it at some point!? Haven't tried 1.6.

FWIW, I use a modified (ie completely gutted) version of GLSurfaceView. There are two threads, the Android UI thread (where events come in) and the GL thread. I run my event listeners (onTouch, etc) on the GL thread to keep things sane. I don't use the request render stuff, I just try to render at 60fps. Hopefully soon I'll post my code.

Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #4 - Posted 2009-09-20 11:24:38 »

Yeah, I took a look at GLSurfaceView after you mentioned it before. I'm using a hacked down version (simplifing and running events nicely). Still no luck.

FWIW, in SingSong when it's scrolling along the music/lyrics I see the same thing.. just slight jitters that make draw your attention.

On another note, the demo above also shows how the touch screen isn't quite responsive enough for action games.

Interesting the SDK causes a lot of garbage... bit of a pain in the bum that. I've tried frame smoothing also and still no real luck. It almost feels like the timing isn't quite right.

Kev

Offline Nate

JGO Wizard


Medals: 81
Projects: 3


Esoteric Software


« Reply #5 - Posted 2009-09-21 07:05:10 »

Re-reading my post I realize I wasn't as explicit as I meant to be. It is the OpenGL stuff in the SDK that generates garbage, so there is nothing we can do if we want to use OpenGL. I haven't tried frame smoothing, I just considered it good enough as I had a lot of other things that needed attention.

Offline endolf
« League of Dukes »

JGO Coder


Medals: 4
Projects: 1


Current project release date: sometime in 3003


« Reply #6 - Posted 2009-09-21 10:30:09 »

I don't have any issues with Craig's Race, could it be other processes on the device?, have you tried a scene with no widgets?, tried killing other processes?. Just a thought. Might be totally the wrong path, but it's a thought Smiley.

Endolf

Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #7 - Posted 2009-09-21 10:33:31 »

I've tried lots of things Smiley It's more likely that if you're just focused on playing the game you don't notice the slight hiccups - but if you just want it scrolling you'll see slight blips - not enough to worry about probably but enough to make it not look quite perfect Wink

Kev

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (92 views)
2013-05-17 21:29:12

alaslipknot (100 views)
2013-05-16 21:24:48

gouessej (130 views)
2013-05-16 00:53:38

gouessej (125 views)
2013-05-16 00:17:58

theagentd (136 views)
2013-05-15 15:01:13

theagentd (124 views)
2013-05-15 15:00:54

StreetDoggy (165 views)
2013-05-14 15:56:26

kutucuk (187 views)
2013-05-12 17:10:36

kutucuk (190 views)
2013-05-12 15:36:09

UnluckyDevil (197 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.234 seconds with 22 queries.