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 (406)
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  
  better FPS... sometimes!?  (Read 3597 times)
0 Members and 1 Guest are viewing this topic.
Offline Nate

JGO Wizard


Medals: 81
Projects: 3


Esoteric Software


« Posted 2009-08-18 07:02:53 »

I'm working on optimizing my Android OpenGL game. It started at ~18 FPS and I now have it at ~25 FPS. However, I think I may be losing my damned mind. Sometimes when I run the game on the device, as I have done a thousand times, it will run between 48 and 55 FPS, instead of the usual 25! Everything in the game is working, and the game is silky smooth! If I shutdown the game and run it again without making ANY changes, I see it runs at ~25 FPS. Does this make any sense at all!? It has happened 4 times in the past couple days. Any ideas how to figure out what kicks it into amazing FPS mode?

Offline Ranger
« Reply #1 - Posted 2009-08-18 09:47:50 »

Well, when my phone upgraded to Android 1.5, I had the opposite, went from 30fps down to 10-15fps, but sometimes it would run fine at 30fps.  After many a debugging session, I worked out it was the main screen orientation.

My game runs in landscape mode.  If the main screen (the screen that kicks off the game) is also in landscape orientation, it runs at 10-15fps, however, if it is in portrait orientation, the game runs fine at 30fps.  I didn't believe this was actually happening, so I ran it over and over again, every time, without fail, it happened.

The fix was simple.  Before starting the game, force the main screen into portrait layout.  When the game ends, let the screen do whatever orientation it wants.  Now I always get 30fps.

I tried to replicate this in a test case, but couldn't.  Funny thing is, I actually have 2 games, and it happens in both of them (although there is a lot of code reuse between my games, so I'm not ruling out it is something silly I'm doing).
Offline Nate

JGO Wizard


Medals: 81
Projects: 3


Esoteric Software


« Reply #2 - Posted 2009-08-18 10:47:26 »

Interesting. My game is also in landscape mode. I'll take note of the screen orientation if I see it happening again. Can you tell what code you used to force the orientation?

I've been working all day on optimizations and now have it running at 40 to 50 FPS. This is great, though it means I may not notice the strange problem I was having.

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

JGO Coder


Medals: 2


falling into the abyss of reality


« Reply #3 - Posted 2009-08-18 10:55:43 »

Battery level low, or charger plugged in?

Many J2ME phones throttle the cpu to conserve power when the battery is getting low; wouldn't be surprised if Android handsets did the same.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here!
Offline Ranger
« Reply #4 - Posted 2009-08-18 10:57:35 »

Can you tell what code you used to force the orientation?

Force portrait before game start:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

Restore default when game ends:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #5 - Posted 2009-08-18 11:17:51 »

You can force it in the manifest also.

One gotcha I had was handling lifecycle correctly. It's easy to get yourself multiple threads running if you don't start/stop things in the right places. I thought I only had 12 FPS at one point only to find it was just a duplicate thread Smiley

Kev

Offline Ranger
« Reply #6 - Posted 2009-08-18 12:24:15 »

Also surfaceDestroyed and surfaceCreated can be called at any point (although usually only if another window pops up over your game), so you need make sure you handle that properly too.
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 (77 views)
2013-05-17 21:29:12

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

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

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

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

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

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

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

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

UnluckyDevil (186 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.092 seconds with 21 queries.