Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (601)
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 4088 times)
0 Members and 1 Guest are viewing this topic.
Offline Nate

« JGO Bitwise Duke »


Medals: 158
Projects: 4
Exp: 14 years


Esoteric Software


« Posted 2009-08-18 05: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 07: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 Bitwise Duke »


Medals: 158
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #2 - Posted 2009-08-18 08: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 Knight


Medals: 14


falling into the abyss of reality


« Reply #3 - Posted 2009-08-18 08: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! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Ranger
« Reply #4 - Posted 2009-08-18 08: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

« JGO Spiffy Duke »


Medals: 212
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #5 - Posted 2009-08-18 09: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 10: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.

 

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

The first screenshot will be displayed as a thumbnail.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (51 views)
2014-12-03 16:27:13

CopyableCougar4 (48 views)
2014-11-29 21:32:03

toopeicgaming1999 (115 views)
2014-11-26 15:22:04

toopeicgaming1999 (103 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!