I am testing jmonkeyengine in Nexus S, and notice that jmonkeyengine consume a lots of battery. I think the battery got drained so much (at least partly) because the updateLoop is running constantly (I am assuming that the GL rendering thread only runs when there is a change in the scene - have not check the code yet, so forgive me if i’m wrong). This behavior makes sense for interactive games where AI elements has to constantly calculate their move. However, for apps with a lot of idle time, such as turn based games, a constant loop like this seems to be wasteful (particularly, of battery resource).
Is there a way to config the app so that the loop will not run constantly? I went through the source code last night (starting from SimpleApplication, to Application, to some JmeContext classes) and it looks like there might be a way to slow down the loop (by setting up a mode so that there is some sleeping time in each iteration basically). But that might not be enough for me. Ideally, I would like to run the update pass only when there is an update. Could you guys let me know if there is a way I can control the update routine? Or generally, is there a way to avoid draining battery?
Bellows are how I measure the battery consumption. I use the tutorial number 3 as the test app and measure the battery consumption in my Nexus S. Here are the results:
- In 1 hour the app (tutorial #3 https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_asset) drained 25% of the battery.
- I modified the app a bit using the simpleUpdate method to make the teapot and the ninja rotate constantly and the app drained about the same amount of battery.
- I measured the battery level using a separate app that listens to ACTION_BATTERY_CHANGED broadcast. Basically I read the battery level before launching the test app, ran the test app for 1 hour (without letting the screen to shut off) and read the battery level again.
- For a reference, I wrote a simple app using openGL to display about 20 geometries (each with about a few hundred vertexes), without animation. If I let the rendering loops to run constantly, the app drains about 20% of battery after 1 hour. if I set GLSurfaceView.setRenderingMode(RENDERMODE_WHEN_DIRTY) then the app drain only 10% of the battery in 1 hour.
- For further reference, I also tested the stock android 2.3.3 contact app (no interaction, just displaying the list of contacts). The app drained 10% of the battery in 1 hour.