Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (711)
Games in Android Showcase (213)
games submitted by our members
Games in WIP (785)
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 4858 times)
0 Members and 1 Guest are viewing this topic.
Offline Nate

« JGO Bitwise Duke »

Medals: 167
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: 167
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 Ninja

Medals: 57

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.
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:

Restore default when game ends:
Offline kevglass

« JGO Spiffy Duke »

Medals: 319
Projects: 25
Exp: 22 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


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.

numerical (361 views)
2017-02-21 07:32:16

numerical (362 views)
2017-02-21 07:31:46

theagentd (473 views)
2017-02-18 13:42:33

theagentd (471 views)
2017-02-18 13:35:16

h.pernpeintner (1638 views)
2017-01-24 22:39:11

h.pernpeintner (1625 views)
2017-01-24 22:38:32

Galdo (2194 views)
2017-01-12 13:44:09

Archive (2153 views)
2017-01-02 05:31:41

0AndrewShepherd0 (2693 views)
2016-12-16 03:58:39

0AndrewShepherd0 (2355 views)
2016-12-15 21:50:57
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 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‑
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!