I made game for android but have problem with stuttering. It occurs once in 10 seconds, sometimes 30 or 60 seconds. It is not caused by garbage collector in my game. From reading of LogCat I found out that it is caused by background system processes like KeyGuardMonitor, Watchdog, LockScreen, BatteryService, KeyInputQueue, ... Those processes grab to much CPU processing power in short time(ussualy aroound 100 ms) and give almost nothing to foreground game. It results to very short but still visible lag. I played other games and all of them have the problem in Android 1.6. I really wonder why such simple thing such as touching the screen take almost 100 ms of CPU power. Five consequent touches can cause 500 ms lag and FPS drops to 10. Is the stuttering also in 2.1, 2.2 Android? Is it possible somehow to make real time apps without stuttering?
Here is app which can show the stuttering. public class StutteringActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().setFormat(PixelFormat.RGBA_8888); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER); setContentView(new StutteringView(this)); } } public class StutteringView extends View { private class StutteringRunnable implements Runnable { @Override public void run() { float s = 3.0f; for (int i = 1; i < 1000; i++) { s += s / i; } cycleCount++; long currentTime = System.currentTimeMillis(); long elapsedTime = currentTime - oldTime; oldTime = currentTime; if (elapsedTime > 1) { Log.d("We like stuttering in google.", "currentTime: " + currentTime + " lostTime: " + elapsedTime + " cycles: " + cycleCount); cycleCount = 0; } StutteringView.this.post(stutteringRunnable); } } private long oldTime; private long cycleCount; private StutteringRunnable stutteringRunnable = new StutteringRunnable(); public StutteringView(Context context) { super(context); post(stutteringRunnable); } } Results from app. Normal behaviour. 212 cycles - per 101 ms Slowdown. (KeyGuardMonitor, Watchdog, LockScreen, BatteryService, KeyInputQueue, ...) 52 cycles - per 101 ms (25%) (Game received only 25% of CPU processing power in 101 ms. Stuttering occurres.) -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en