clock-app is rather a busy app (analogue clock display)

Bug #1363968 reported by Colin Ian King
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Clock App
Fix Released
High
Kill Animals

Bug Description

The clock app is using ~35% of the CPU, this is rather busy and will suck power quite badly.

Attached is the output of running health-check on the clock app process:

Major points to consider:

* qmlscene is seeing ~6800+ context switches a second
* clock_gettime() is called more than 100 times a second
* gettimeofday() is called more than 70 times a second
* stat64() is stat'ing /etc/localtime 734 times a second

I know we want an accurate clock, but this is a bit of overkill isn't it?

Heap seems to be growing at around 1.57K/sec, which doesn't look promising

Related branches

Revision history for this message
Colin Ian King (colin-king) wrote :
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

hmm this happens because in the analog clock mode, we need to update the UI every 10 ms to show a super smooth seconds hand movement. In the old clock app (purple background) we circumvented this issue by disabling the seconds hand by default. I am a bit unsure how to proceed. But this is an issue which needs to be tackled.

Changed in ubuntu-clock-app:
status: New → Confirmed
importance: Undecided → High
milestone: none → rtm
Revision history for this message
Colin Ian King (colin-king) wrote :

Idle phone, display on, draws ~201 mA, running the clock app (analogue display) draws ~426mA.

Revision history for this message
Colin Ian King (colin-king) wrote :

And here is the digital clock analysis (see attached)

I can't measure the current being drawn, it's too small a difference really.

description: updated
Changed in ubuntu-clock-app:
assignee: nobody → Akiva (akiva)
Revision history for this message
Kill Animals (kill-animals) wrote :

Changing the property to:
        rotation: visible ? 360 * analogTime.getSeconds() / 60 : 0

reduces the cpu at least on my laptop well... from a 3/4 to a 0/1

Only thing is, that it is not a smooth movement.

Changed in ubuntu-clock-app:
status: Confirmed → In Progress
Revision history for this message
Kill Animals (kill-animals) wrote :

Added two branches; Both use less CPU

one branch tries to go for simplicity, just updating the position every second, but without any smooth animation that cpus love to eat
The other branch goes with a small linear animation every second, that is slightly more appealing to the eye. one caveat to this however is once it reaches 359, it loops back. This may be actually a neat feature for someone to have, because it lets the user know when a minute has keeled over.

Revision history for this message
Sam Bull (dreamsorcerer) wrote :

"we need to update the UI every 10 ms"

I would image that the screen runs at 60 Hz, so if you use vsync, it will run every 16.7 ms and look 100% identical. That should drop the CPU usage by about 40%, which is a start.

I'm not sure why you would need such a large amount of CPU usage just for an animation though. Is there processing in there which could be split out and updated only once every few seconds, separate from the animation? I would assume that an animation would not need any of the calls mentioned in the description.

Revision history for this message
Kill Animals (kill-animals) wrote :

@Sam Bull

There is no qml animation in the current branch. What it does rather is just update the rotation property every millisecond, so it appears to be a smooth linear animation.

 lp:~akiva/ubuntu-clock-app/1363968-linear-animation-every-second
However has an animation if you would like to see the difference.

I think the hertz idea is very interesting. I would not know how to pipe that signal though.

Revision history for this message
Sam Bull (dreamsorcerer) wrote :

I would expect some kind of support in the SDK for vsync, if not you should probably register a bug. It's a moderately important feature for 3D games and other visual applications, in order to stop screen tearing.

Every millisecond is definitely overkill. That means you're updating the animation about 16 times between each screen update.

Revision history for this message
Kill Animals (kill-animals) wrote :

@Sam Bull

Every millisecond is overkill, thus the bug. My two branches that I linked significantly reduce this though.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

Fix committed into lp:ubuntu-clock-app at revision None, scheduled for release in ubuntu-clock-app, milestone rtm

Changed in ubuntu-clock-app:
status: In Progress → Fix Committed
Changed in ubuntu-clock-app:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.