I am new to the android world (new to any mobile platform to be specific). I have a problem with SurfaceView. I have a thread set up as my game loop which locks the canvas, prints out a black screen and the current fps, and prints out a red screen in case the fps goes below 25. The thread then unlocks and posts this.
Using java Syntax Highlighting
- public void run() {
- //UPDATE
- while (mRun) {
- Canvas c = null;
- try {
- c = mHolder.lockCanvas(null);
- synchronized (mHolder) {
- mPanel.doDraw(mElapsed, c);
- }
- } finally {
- if (c != null) {
- mHolder.unlockCanvasAndPost(c);
- }
- mElapsed = System.currentTimeMillis() - mStartTime;
- mStartTime = System.currentTimeMillis();
- }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
I have a sony x10 and just outputing a "black screen" gives me an fps of 33 solid. The issue is why is the canvas SO slow because all it does is output a black screen?
My second question (which is a more serious one), the fps "jumps" down to 15 every 3-5 seconds on my x10 with just that code. This is a very bad performance issue because as I work on my app, there will be constant quirks of lag later. When I ran this code on motorola atrix, the fps was solid 60 and the fps only jumped below 25 fps every 20 seconds. That phone is obviouslly a faster phone, but I don't get it. Why is the FPS jumping like that? My ultimate goal is to make a 2-d game.

. Is this error message a very bad one?