Only redraw when something has changed / High CPU usage
TouchRAM has a high CPU usage even if nothing is done, i.e., even if it runs in the background. On a recent rMBP it has a constant CPU usage of 40-45%!
When profiling the CPU with JProfiler it shows that drawing is something that takes a lot. Therefore, it could mean that MT4j constantly redraws everything on the screen, even if that is not necessary, because nothing has changed.
Comments (7)
-
reporter -
reporter Processing contains support for redrawing. I am surprised MT4j doesn't use this.
That means,
draw()
gets executed in a loop, but can be stopped withnoLoop()
.redraw()
allows to draw once orloop()
to continue looping again. It seems that has to be implemented manually. -
reporter - changed milestone to AOSD 2014 Demo
Would be nice to have :)
-
reporter Issue
#29was marked as a duplicate of this issue. -
reporter - changed title to Only redraw when something has changed / High CPU usage
-
reporter - changed milestone to MODELS 2014 Demo
-
reporter I tried to stop the loop using
noLoop()
. However, in the loop,runApplication
ofAbstractMTApplication
is called. In that method, the first task is to process incoming events. This means that, stopping the loop stops processing of events. For some reason, drawing and event processing are intertwined in MT4j. - Log in to comment
AbstractMTApplication.draw()
(line 271) gets called constantly (i.e., every loop), which invokes the private methodrunApplication
. From there, thedrawAndUpdate
method of the current scene is called, which leads to the scene being cleared and redrawn. Eventually this will lead to every child of the scenes canvas being redrawn.