Closed Bug 1020000 Opened 10 years ago Closed 9 years ago

Flame: Battery drains over night

Categories

(Firefox OS Graveyard :: Performance, defect, P1)

ARM
Gonk (Firefox OS)
defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: gwagner, Unassigned)

References

Details

(Keywords: foxfood, perf, power, Whiteboard: [c=power p= s= u=flame])

My flame running 1.3 or master doesn't survive the night without having it plugged in.
We need to fix this or nobody will use it as dogfood phone.
I've turned on one of mine right now (9:15 pm), and its currently at 90% battery. I'll see where it is tomorrow morning.
Probably a vendor problem.

I'm also adding qawanted to see if this happens on Open C as a point of comparison.
Keywords: dogfood, perf, power, qawanted
So my flame has been sitting, powered on, with the screen off, for 10 hours. It started at 90% last night, and right now its at 89%.

I do not have any sim cards in this phone, and I don't have wifi turned on. Gregor, what is the state of your phone with respect to apps running, and radios?
Flags: needinfo?(anygregor)
Check background 3rd apps, FaceBook, Twitter, ConnectA2.. These apps may use alarms to wakeup themselves quite often, and some of them acquire wakelocks but forget to release them.
Did you have browser up and running ?  If so maybe it may have to do with bug 1003912?
My setup is: 2 sim cards, wifi, data enabled, bunch of certified apps are running (email, calendar, dialer, camera, clock...). I usually set my alarm but the phone is dead if I don't leave it plugged in over night. Doesn't matter if the battery is full before I go to sleep.

I also have connectA2, twitter installed. Especially connectA2 starts right away when I kill it.
Flags: needinfo?(anygregor)
OS: Mac OS X → Gonk (Firefox OS)
Priority: -- → P1
Hardware: x86 → ARM
Whiteboard: [c=power p= s= u=]
My battery consumption is also quite good. My flame has been unplugged from my computer for a couple of days and it's sitting at 81%.

I haven't been using it all, It is connected to Wifi, but doesn't have a SIM.

I'm running the 10G2 base image:
https://intranet.mozilla.org/QA/B2G_Tips_and_Tricks#Flashing_Base_Build_Image_.28US.29
I also have terrible battery life. There's a thread on dev-b2g about this:
https://groups.google.com/forum/#!topic/mozilla.dev.b2g/24ZtvAljpro

One example: my battery went from 71% to 35% in 9 hours overnight. This was with zero use, wireless off, bluetooth off, one SIM card installed, good reception (4 out of 5 bars), and an alarm set.

|adb shell top -m 5| indicates that ksmd (kernel samepage merging daemon) is constantly running and consuming 3--8% of CPU.

And Thinker said that his phone never actually goes to sleep.
ConnectA2 uses alarms(every 30 seconds?) to restart itself, requires cpu wakelock and never release it, which prevents the phone to go sleep.

Another problem is about WebAudio API. Some games(FlappyBird for example) using Phaser (http://phaser.io/) enginee may raise bottem current even when my flame goes to sleep. 
After called Phaser.SoundManager.boot(), which creates an AudioContext, the bottom current would never go down until you kill the app. 

(In reply to Gregor Wagner [:gwagner] from comment #6)
> My setup is: 2 sim cards, wifi, data enabled, bunch of certified apps are
> running (email, calendar, dialer, camera, clock...). I usually set my alarm
> but the phone is dead if I don't leave it plugged in over night. Doesn't
> matter if the battery is full before I go to sleep.
> 
> I also have connectA2, twitter installed. Especially connectA2 starts right
> away when I kill it.
(In reply to Jin Zhang from comment #9)
> ConnectA2 uses alarms(every 30 seconds?) to restart itself, requires cpu
> wakelock and never release it, which prevents the phone to go sleep.
> 
> Another problem is about WebAudio API. Some games(FlappyBird for example)
> using Phaser (http://phaser.io/) enginee may raise bottem current even when
> my flame goes to sleep. 
> After called Phaser.SoundManager.boot(), which creates an AudioContext, the
> bottom current would never go down until you kill the app. 
> 
> (In reply to Gregor Wagner [:gwagner] from comment #6)
> > My setup is: 2 sim cards, wifi, data enabled, bunch of certified apps are
> > running (email, calendar, dialer, camera, clock...). I usually set my alarm
> > but the phone is dead if I don't leave it plugged in over night. Doesn't
> > matter if the battery is full before I go to sleep.
> > 
> > I also have connectA2, twitter installed. Especially connectA2 starts right
> > away when I kill it.

Correct me if I'm wrong Paul, but I think you fixed the WebAudio API behavior described by Jin, right?
Flags: needinfo?(paul)
Flags: needinfo?(jz.zhangjin)
I installed the kernel with ksmd disabled that Alexandre provided. It works, and things are looking better. In the six hours since I flashed my phone, my battery went from 93% to 82%, which is about 2% points per hour. Previously I was losing about 4% points per hour.

So that'll give me about two days per charge, which is better, though still seems on the low side.

Can anybody else confirm if their Flame is or is not running ksmd, using |adb shell top -m 5|? How do we go about updating users' kernels -- is that something that can be done via automatic updates?
(In reply to Nicholas Nethercote [:njn] from comment #11)
> I installed the kernel with ksmd disabled that Alexandre provided. It works,
> and things are looking better. In the six hours since I flashed my phone, my
> battery went from 93% to 82%, which is about 2% points per hour. Previously
> I was losing about 4% points per hour.
> 
> So that'll give me about two days per charge, which is better, though still
> seems on the low side.
> 
> Can anybody else confirm if their Flame is or is not running ksmd, using
> |adb shell top -m 5|? How do we go about updating users' kernels -- is that
> something that can be done via automatic updates?

Updating boot partition can be done by OEM for sure, and it can be done with our update process also, but it will require some changes to the production of FOTA.
(In reply to Alexandre LISSY :gerard-majax from comment #10)
> Correct me if I'm wrong Paul, but I think you fixed the WebAudio API
> behavior described by Jin, right?

If the author does the proper thing, then we can do an optimization. That's what Gaia apps are doing.

We are working in the working groupe to add a way to suspend an audio context, at the moment. The spec effort is lead by Google, but we are actively participating in the discussion.
Flags: needinfo?(paul)
Depends on: 1021400
I have run the following command on my flame:

  while sleep 3; do echo 1 > /data/test.log; done &

Then, disconnect the USB cable and turn off the screen.  The device is supposed to go to sleep, but it doesn't.  /data/test.log continues growing up.  I don't run any game or connectA2, and /sys/power/wake_lock is empty.  If the device go to sleep properly, ksm should not cause such much of battery dropping.
Your test above doesn't demonstrate whether the phone will goto sleep or not.

On phones I've worked on in the past, it would sleep for 2.9x secnds, wakeup (due to a pending timeout on the sleep command) do some processing, and go back to sleep, and wakeup again 2.9x seconds later due to a pending timeout.
Whiteboard: [c=power p= s= u=] → [c=power p= s= u=flame]
(In reply to Nicholas Nethercote [:njn] from comment #11)
> I installed the kernel with ksmd disabled that Alexandre provided. It works,
> and things are looking better. In the six hours since I flashed my phone, my
> battery went from 93% to 82%, which is about 2% points per hour. Previously
> I was losing about 4% points per hour.
> 
> So that'll give me about two days per charge, which is better, though still
> seems on the low side.
> 
> Can anybody else confirm if their Flame is or is not running ksmd, using
> |adb shell top -m 5|? How do we go about updating users' kernels -- is that
> something that can be done via automatic updates?

Where can I find the Alexander's kernel ? I can see that ksmd running on mine
> Where can I find the Alexander's kernel ? I can see that ksmd running on mine

See bug 1021400 comment 10.
With the modified kernel i also noticed a strange screen flickering.
I reflashed The original boot and now the screen still flickers when on auto brightness andò now Wi-Fi is not working anymore
Hurrà!  Catching old enemies?
For tracking purposes -
This issue has also been reported by a user in the SUMO forums: https://support.mozilla.org/en-US/questions/1011284

VERBATIM:
My battery was 68% when retiring to bed. In the morning it was in the twenties. This seems excessive for nothing more than being idle.
I disabled ksm per 

adb shell echo 0 > /sys/kernel/mm/ksm/run

and after 17hours I have still 45% battery with hdspa constantly on (email check every 30min)

so it seems to have an impact on the flame.
(In reply to gabriele.vidali from comment #18)
> With the modified kernel i also noticed a strange screen flickering.
> I reflashed The original boot and now the screen still flickers when on auto
> brightness andò now Wi-Fi is not working anymore
> Hurrà!  Catching old enemies?

So as I replied by email, this is not "screen flickering", but a bogus behavior of the automatic brightness. I've always seen it on Flame, I have no idea whether it's a bug from the driver or Gaia brightness changes.

(In reply to ralf tauscher from comment #20)
> I disabled ksm per 
> 
> adb shell echo 0 > /sys/kernel/mm/ksm/run
> 
> and after 17hours I have still 45% battery with hdspa constantly on (email
> check every 30min)
> 
> so it seems to have an impact on the flame.

Ralf, what base image are you using ? Flame bought on the web ?
Flags: needinfo?(mozilla)
hi, i'm using the boot.img from base image 123. on top of a self built v2.0 (gabriele made a contact to thundersoft because of screen flickering, but thats a seperate bug.) and yes, it's a flame bought on the web. i was just checking my keon with geeksphones 2.0 from today and it has /sys/kernel/mm/ksm/run with 0. i understood that the reason for turning ksm on is to save memory. that would be the case with the flame in the reduced memory configuration. but with the full meg its the bigger benefit to save power. I will test the flame in flight mode one time with ksm enabled and one without. maybe we have a better feeling how much ksm needs.

for screen flickering it seems normal like on the keon now. so my guess is, it was boot.img related and now its up to gaia.
Flags: needinfo?(mozilla)
bug 1022486 is related for [dolphin]
Not sure what you mean by base image 123, as the last one is 122 and they are not publicly accessible. Where did you get this image from?
I made a test over the last 2 nights.

one time ksm disabled in flight mode 7h. battery went down from 100% to 96%

one time ksm enabled in flight mode 7h. battery went down from 100% to 95%

no significant difference so far.

I will try the same but with hsdpa enabled in the next two nights. or any other ideas?
QA Contact: mclemmons
On the latest 2.1 Open_C build, with Power on, screen off, no SIM within device, and no WiFi, device started at 78% battery percentage at 4 p.m. unplugged.

After 17 hours with no changes to device, battery percentage reported at 71%.

Unable to reproduce Comment 1 and Comment 3 ten (10) hour time frame due to work schedule. 

Environmental Variables:
Device: Open_C 2.1
BuildID: 20140811040202
Gaia: 19ed3c9e78eaf234cc08484bde6998ae21552ba5
Gecko: a9b43778f0c2
Version: 34.0a1 (2.1) 
Firmware Version: P821A10V1.0.0B06_LOG_DL
User Agent: Mozilla/5.0 (Mobile; rv:34.0) Gecko/34.0 Firefox/34.0
QA Whiteboard: [QAnalyst-Triage?
Flags: needinfo?(jmitchell)
QA Whiteboard: [QAnalyst-Triage? → [QAnalyst-Triage?]
QA Whiteboard: [QAnalyst-Triage?] → [QAnalyst-Triage+]
Flags: needinfo?(jmitchell)
QA Whiteboard: [QAnalyst-Triage+] → [QAnalyst-Triage+][lead-review+]
As documented in https://bugzilla.mozilla.org/show_bug.cgi?id=1051083#c40 I noticed some error with lastUpdateTime variable. So far my finding indicates that this may trigger too much update checking. For instance, the timer "user-agent-updates-timer" gets triggered every two minutes, while, as far as I can tell, the pref general.useragent.updates.interval is set to one week. It may have a role to play with the draining documented.
Depends on: 1056034
(In reply to Ralph Daub [:rdaub] from comment #19)
> For tracking purposes -
> This issue has also been reported by a user in the SUMO forums:
> https://support.mozilla.org/en-US/questions/1011284
> 
> VERBATIM:
> My battery was 68% when retiring to bed. In the morning it was in the
> twenties. This seems excessive for nothing more than being idle.

Ralph, given the user report on SUMO and my comment 27, it's possible bug 1056034 has a play there. According to the user description on SUMO, data was enabled on the device.
My phone is on KK. It drains battery over night again today. I think we need to log the battery power consumption and compare it with something on the phone that logs application activity, and do it every night :/
See Also: → 1097083
I spent the weekend in (downtown) Chicago on a TMo SIM running:

Gaia-Rev        f8d3bf44029e0afc0124600a4bb34dba8fc1ad21
Gecko-Rev       https://hg.mozilla.org/releases/mozilla-b2g34_v2_1/rev/f70a67a7f846
Build-ID        20141120001207
Version         34.0
Device-Name     flame
FW-Release      4.4.2
FW-Incremental  40
FW-Date         Tue Oct 21 15:59:42 CST 2014
Bootloader      L1TC10011880

My battery life, with minimal usage, was consistently only 5 to 6 hours.
This might be related to the following bug:

https://bugzilla.mozilla.org/show_bug.cgi?id=1095846

It seems that the problem is in the radio, which is constantly trying to update the connection after an error. Probably it only happens with some operators.

Please have a look and upvote the bug.
The battery drains overnight.
Flame with 2.0.0.0-pre
I am not using the radio. 3G is off.
Are running: phone, messages, clock, parameters.
The battery drains overnight.
Flame with 2.0.0.0-pre
I am not using the radio. 3G is off.
Are running: phone, messages, clock, parameters.
No heat-up.
I seem to hit a bug with Flame 2.0 OTA and Internet Sharing – once I disable it, the battery keeps draining at a fast rate until I reboot. Still investigating this, but if you were using Internet Sharing at one point and then saw this happening, please chime in.
(In reply to Florian Bender from comment #34)
> I seem to hit a bug with Flame 2.0 OTA and Internet Sharing – once I disable
> it, the battery keeps draining at a fast rate until I reboot. Still
> investigating this, but if you were using Internet Sharing at one point and
> then saw this happening, please chime in.

I seem to have saw this. Yesterday my battery was drained up over night and I indeed were using wifi hotspot before that.
(In reply to Florian Bender from comment #34)
> I seem to hit a bug with Flame 2.0 OTA and Internet Sharing – once I disable
> it, the battery keeps draining at a fast rate until I reboot. Still
> investigating this, but if you were using Internet Sharing at one point and
> then saw this happening, please chime in.
Same here, just noticed this today.

In addition, I have no battery issue when I used old build on 2014/08/19 (http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/2014/08/2014-08-19-16-02-08-mozilla-central-flame-eng/) with image base v123.
Flags: needinfo?(jz.zhangjin)
Closed per no further data coming since 6months ago.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.