0

For the past few months I have been having a issue with apps I have created for android. It appears that after a relatively low time of being open (roughly 10-20 minutes), my phone starts to get extremely hot. On top of that, the app will occasionally start lagging a ton (dropping roughly 30-40 frames). Ive been trying to track down the issue for a while but have had no luck. I have a few ideas as to what could be causing the problem but have not been able to confirm.

Heres a bit of information about my setup that may be the cause of the issue:

  1. The app uses roughly 50-80MB, if sounds or high quality images are loaded sometimes can go as high as 140MB.

  2. Everything is directly drawn onto Javas canvas. (Is it alright to try to produce a high quality app by using Javas canvas to draw?)

  3. I am not using androids "activity" system. Instead I have my own system which creates and removes objects through passing strings when certain events are triggered. (So technically the entire program is run in the main activity at all time, and the objects are handled through my system).

  4. I am not using any of androids UI elements, instead I have created everything on my own. There is nothing super complicated about them, I am just not sure if using androids UI elements has any benefits that im unaware of.

  5. The main object update function is run in a thread, while the paint method calls invalidate on its own. My objects are updated through the following code

    while (roomRunning)
            {
                if (!isPaused)
                    update();
    
                try { synchronized (this) { wait(5); } } catch       (InterruptedException e)
                {
                    e.printStackTrace();
                }
            }
    

.005 seconds is the code update rate. This update rate is very close to 60 frames, and feels very smooth, however I am still concerned it may be to fast (especially since the app occasionally may have to process hundreds of objects per code update.

I have monitored the memory usage of my app and compared it to other games running on my phone. The memory usage appears to be up there with many other apps, however those do not cause a overheat. Also, when running my app on my friends phone I have not noticed any overheating or lag issues.

Could this issue be caused by a faulty phone, or is there something serious I need to fix in my app?

If there is any more information which is needed to solve this problem, please let me know.

Sam A
  • 3
  • 4
  • Interesting question. I'd say that if it's not causing the issue on any other phones, then it's your phone that is the issue. If you find you can reproduce the problem on another phone... then you'll have a case for looking at your code again. If you were going to look at it, I'd say memory use is not the thing to look at but CPU use... but I don't know enough about apps to be certain. – Taryn East Sep 08 '15 at 01:48
  • update should triggered by event(manage dirty screen rectangle to send the update event). or overheat. – Jiang YD Sep 08 '15 at 01:53
  • @Taryn East When the app is running, it appears that the average CPU percentage is 10%. I am not sure what the average usage is but I would assume that is not alot. Occasionally it spikes up to 20% but thats only for a brief second. – Sam A Sep 08 '15 at 03:33
  • @Jiang YD I am a bit confused by this response. Is there someplace I can go to learn more about this update method? – Sam A Sep 08 '15 at 03:37
  • Yeah that doesn't sound like sufficient to be causing the problem. Your first step will be to reproduce it in other phones, though... otherwise this isn't really a problem with your code at all... – Taryn East Sep 08 '15 at 04:27
  • http://stackoverflow.com/questions/76651/dirty-rectangles – Raju-san Sep 08 '15 at 05:46
  • @SamA what GUI component system you use? a GUI system would have provide such 'dirty rectangle' events. you need block your main event dispatch loop until such event come. – Jiang YD Sep 08 '15 at 05:50
  • @Jiang YD My UI is all custom objects which are drawn on the screen and handled by my 'main object', so I am not using anything which was included within Java for Android (Mainly for customization purposes). The only UI element which I had to use from java was EditText, because I could not receive accurate text input any other way (otherwise I would likely have my own system for that, too). – Sam A Sep 08 '15 at 23:58
  • I mean, could you need to know when to redraw the UI components. – Jiang YD Sep 09 '15 at 00:42

0 Answers0