Android onTouch slow
Monkey Forums/Monkey Programming/Android onTouch slow
| ||
Sorry to raise this one again, but I've been looking at the Libgdx framework and the Replica Island source code and I feel that this issue can be fixed to some degree. http://code.google.com/p/libgdx/ http://code.google.com/p/replicaisland/ Basically I think the "fix" is to use threading, both of these projects I think use threading to fix the issue. When playing Replica Island using the onscreen keys I dont see much slow down. Also when I've created tests with Libgdx again I dont see the slow down I get with the Monkey code. Could you please have another look at this issue. Thanks! |
| ||
Just a couple of tests: Using the "latest" mojo.android.java I get 50FPS and when I press the screen it drops to 30FPS - so a 20FPS drop. Using Libgdx I get 60FPS and when I press the screen it drops to 50FPS, so a 10FPS drop. The on-screen controls in Replica Island requires you to press and hold one finger to move left or right and another to perform an action - there is no noticeable slow down while doing this. |
| ||
I've added this to mojo.android.java:final long time = System.currentTimeMillis(); if (event.getAction() == MotionEvent.ACTION_MOVE && time - mLastTouchTime < 32) { // Sleep so that the main thread doesn't get flooded with UI events. try { Thread.sleep(32); } catch (InterruptedException e) { // No big deal if this sleep is interrupted. } app.waitDrawingComplete(); } mLastTouchTime = time; It doesnt help my issue, but it is meant to help users who are on less than Android 2.0... Still researching... |
| ||
I've just hacked the Replica Island code and added a FPS counter (the one which is in the game shows a 3 figure value!?!). In the GameThread.java file, in the run() method I added the following between the if (timeDelta > 12) statement: if ((SystemClock.uptimeMillis() - startTime) >= 1000) { totalFPS = fpsCount; fpsCount = 0; startTime = SystemClock.uptimeMillis(); } else { fpsCount += 1; } mGameRoot.sSystemRegistry.hudSystem.setFPS(totalFPS); The game runs at 60FPS, but when I touch the screen it does drop to 50FPS - 10FPS drop, so the same as LibGdx. |