I'm on developing on a Motorola Droid with Android 2.0.1.  I was
trying to track down frame rate issues with my VBO program, so I
created a program to check the baseline times spent when calling
onDrawFrame().  So I created an empty onDrawFrame and pulled time
statistics on it.

I can't even get nears 60 FPS *and I'm not even drawing anything*.
The big problem is that the delay between calls into onDrawFrame() is
insanely variable.  It's not the GC--it doesn't run during the test.
It's not fill rate--I'm not drawing anything.  So, I can only imagine
that its the scheduler.  Here is the histogram of delays entering
onDrawFrame() as tracked by SystemClock.uptimeMillis() over a period
of 60 seconds.  Note that there is the expected hump near 16ms, but
there is a non-trivial second hump near 29ms with not a few stragglers
almost to 50ms.  This is running full tilt on the render thread not
doing *anything*.

Why is this so unpredictable and slow?  It's running in the
foreground.  I'm not touching anything or generating events.  It's not
drawing.  It's not even collecting garbage.

This is death for any program that requires any level of response
timing.  Am I doing something wrong?  Should I simply move to the NDK
for anything that touches OpenGL?  WIll that actually help?

03-30 02:35:52.284: VERBOSE/FuncnDelta:(1450):   6: 1
03-30 02:36:52.300: VERBOSE/*****(1450): Run ended ... dumping...
03-30 02:36:52.308: VERBOSE/EntryDelta:(1450):   1: 2
03-30 02:36:52.323: VERBOSE/EntryDelta:(1450):   2: 1
03-30 02:36:52.331: VERBOSE/EntryDelta:(1450):   4: 1
03-30 02:36:52.339: VERBOSE/EntryDelta:(1450):  12: 1
03-30 02:36:52.355: VERBOSE/EntryDelta:(1450):  13: 2
03-30 02:36:52.362: VERBOSE/EntryDelta:(1450):  14: 2
03-30 02:36:52.370: VERBOSE/EntryDelta:(1450):  15: 29
03-30 02:36:52.370: VERBOSE/EntryDelta:(1450):  16: 1185
03-30 02:36:52.378: VERBOSE/EntryDelta:(1450):  17: 1560
03-30 02:36:52.378: VERBOSE/EntryDelta:(1450):  18: 343
03-30 02:36:52.386: VERBOSE/EntryDelta:(1450):  19: 15
03-30 02:36:52.386: VERBOSE/EntryDelta:(1450):  20: 13
03-30 02:36:52.394: VERBOSE/EntryDelta:(1450):  21: 4
03-30 02:36:52.394: VERBOSE/EntryDelta:(1450):  22: 6
03-30 02:36:52.401: VERBOSE/EntryDelta:(1450):  23: 1
03-30 02:36:52.409: VERBOSE/EntryDelta:(1450):  24: 9
03-30 02:36:52.409: VERBOSE/EntryDelta:(1450):  25: 3
03-30 02:36:52.417: VERBOSE/EntryDelta:(1450):  26: 7
03-30 02:36:52.417: VERBOSE/EntryDelta:(1450):  27: 10
03-30 02:36:52.425: VERBOSE/EntryDelta:(1450):  28: 60
03-30 02:36:52.425: VERBOSE/EntryDelta:(1450):  29: 105
03-30 02:36:52.433: VERBOSE/EntryDelta:(1450):  30: 16
03-30 02:36:52.433: VERBOSE/EntryDelta:(1450):  31: 4
03-30 02:36:52.487: VERBOSE/EntryDelta:(1450):  32: 10
03-30 02:36:52.495: VERBOSE/EntryDelta:(1450):  33: 6
03-30 02:36:52.495: VERBOSE/EntryDelta:(1450):  34: 5
03-30 02:36:52.503: VERBOSE/EntryDelta:(1450):  35: 3
03-30 02:36:52.503: VERBOSE/EntryDelta:(1450):  36: 2
03-30 02:36:52.511: VERBOSE/EntryDelta:(1450):  37: 1
03-30 02:36:52.511: VERBOSE/EntryDelta:(1450):  38: 1
03-30 02:36:52.519: VERBOSE/EntryDelta:(1450):  46: 1

<code>
package org.allcaps.vbo1;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;

import android.content.res.Resources;
import android.opengl.GLSurfaceView.Renderer;
import android.os.SystemClock;
import android.util.Log;

// Basic VBO example
// Why does writing Java always make me want to punch somebody?

public class LessonVBO implements Renderer {
        private long previousMillis = -1;
        private long currentMillis = SystemClock.uptimeMillis();
        private long entryMillis = SystemClock.uptimeMillis();
        private long exitMillis = SystemClock.uptimeMillis();
        private long startMillis = SystemClock.uptimeMillis();

        long entryDeltaMillis[] = new long[1000];
        long funcDeltaMillis[] = new long[1000];
        public LessonVBO(Resources resources) {
        }

        public void onSurfaceCreated(GL10 gl10, EGLConfig config) {
                GL11 gl = (GL11)gl10;

                if (!(gl10 instanceof GL11)) {
                        Log.v("VBO", "gl cast failed");
                }
        }

        public void onSurfaceChanged(GL10 gl10, int width, int height) {
                GL11 gl = (GL11)gl10;

                if (!(gl10 instanceof GL11)) {
                        Log.v("VBO-onSurfaceChanged", "gl cast failed");
                }
        }

        public void onDrawFrame(GL10 gl10) {
                if (previousMillis == -1) {
                        // First time through
                        currentMillis = SystemClock.uptimeMillis();
                        previousMillis = currentMillis;
                        startMillis = currentMillis;
                        return;
                }

                currentMillis = SystemClock.uptimeMillis();
                entryMillis = currentMillis;

                entryDeltaMillis[(int)(currentMillis-previousMillis)] += 1;

                previousMillis = currentMillis;
                exitMillis = SystemClock.uptimeMillis();

                funcDeltaMillis[(int)(exitMillis-entryMillis)] += 1;

                if (currentMillis >= startMillis + 60000) {
                        dumpAndEraseTables();
                        previousMillis = -1;
                }


        }

        public void dumpAndEraseTables() {
                Log.v("*****", "Run ended ... dumping...");
                for(int ii=0; ii<1000; ++ii) {
                        if (entryDeltaMillis[ii] != 0) {
                                Log.v("EntryDelta:", String.format("%3d: %d", 
ii,
entryDeltaMillis[ii]));
                                entryDeltaMillis[ii] = 0;
                        }
                }

                for(int ii=0; ii<1000; ++ii) {
                        if (funcDeltaMillis[ii] != 0) {
                                Log.v("FuncnDelta:", String.format("%3d: %d", 
ii,
funcDeltaMillis[ii]));
                                funcDeltaMillis[ii] = 0;
                        }
                }
        }
}
</code>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to