Battery.

Hi, 

Before posting this, ive made many test. 

I have f6sapphire, so far no hr, no oxy activated

Ive noticed That after few days (3) battery consumption is increased a lot, with the same use (from 0.3%/hr to 1.0)

Im wondering if someone jad the same. Thing and if solution was found.

It could be var issue ? Only few setting storage used,

For weather for exemple, do I have to set it to Bull before puting something Else inside ?

Can it be a Glance issue ?

I have a widget which en able sensor on glance and put it to Bull on hide, 

It turns to GPS on on initializ (main view) and turn it of onhide.

Or a device issue ?

I hope my explanation arr clear. 

Have a great day 

  • Hi, Travis, 

    Many thanks for That, I have 4 wf with bg, may be it is That which drain batt if the 4 bg run. 

    So I have to use 

    deleteTemporalEvent

    Is it better to put it onStop in app ? 

  • I am *almost* certain that this is incorrect

    I recall asking Brian about this when backgrounding was first introduced, and at least at that point, it was only the active one.  When you go to switch WFs, you can see a WF's BG run when you preview an inactive one.  It won't have data when you first preview it, but gets it after a few seconds.(I ignore data more than 6hrs old in Storage)

    The reason I'd asked Brian was specifically about the battery impact of having more than one WF with a background process installed.  This would have been around the time backgrounding was introduced at the 1st Summit.

  • here is my report, since Travis post, I added to all my WF 

    function onStop(state) {
        	if( Toybox.System has :ServiceDelegate ) {
            	Bg.deleteTemporalEvent();
            }
        
        }

    perhaps it is a coincidence but since I've done this, Battery consumption return to normal.

    May be it is just Fenix 6 "issue" because I did have this with the F5.

    so it seems all wf background process run and it was why I had odd battery behaviour.

    I'll let you know if something change, I ve been testing this only for few hours.

  • Ok, I ran a test with one of my test WFs that logs things and clone a copy so both would be on the watch (a 245m).  The first one became active after the sideload, and from this log, you can see it ran for a couple minutes, and then I switched to the other (I added some notes in the logs)

    ===>(this one was active, to get temporal event registered)
    App initialize 3:29
    Counter in App initialize: 0
    onStart
    getInitialView
    From OS: data=none 0 at 3:29
    App initialize 3:29
    Counter in App initialize: 0
    onStart
    getServiceDelegate: 3:29
    bg exit: 3:29
    onStop
    onBackgroundData=3:29 1 at 3:29
    onStop counter=1 3:31
    App initialize 3:31
    Counter in App initialize: 1
    onStart
    getInitialView
    From OS: data=none 1 at 3:31
    onStop counter=1 3:31
    =====>(make other WF active for 30 minutes, then back to this one)
    App initialize 4:00
    Counter in App initialize: 1
    onStart
    getInitialView
    From OS: data=none 1 at 4:00
    App initialize 4:00
    Counter in App initialize: 1
    onStart
    getServiceDelegate: 4:00
    bg exit: 4:00
    onStop
    onBackgroundData=4:00 2 at 4:00
    onStop counter=2 4:00
    App initialize 4:00
    Counter in App initialize: 2
    onStart
    getInitialView
    From OS: data=none 2 at 4:00
    App initialize 4:05
    Counter in App initialize: 2
    onStart
    getServiceDelegate: 4:05
    bg exit: 4:05
    onStop
    onBackgroundData=4:05 3 at 4:05
    App initialize 4:10
    Counter in App initialize: 2
    onStart
    getServiceDelegate: 4:10
    bg exit: 4:10
    onStop
    onBackgroundData=4:10 4 at 4:10
    App initialize 4:15
    Counter in App initialize: 2
    onStart
    getServiceDelegate: 4:15
    bg exit: 4:15
    onStop
    onBackgroundData=4:15 5 at 4:15
    App initialize 4:20
    Counter in App initialize: 2
    onStart
    getServiceDelegate: 4:20
    bg exit: 4:20
    onStop
    onBackgroundData=4:20 6 at 4:20
    App initialize 4:25
    Counter in App initialize: 2
    onStart
    getServiceDelegate: 4:25
    bg exit: 4:25
    onStop
    onBackgroundData=4:25 7 at 4:25
    onStop counter=7 4:30
    =====>> at this time I started the native run app for 30 minutes.  This background still runs, but the WF itself isn't running)
    App initialize 4:30
    Counter in App initialize: 7
    onStart
    getServiceDelegate: 4:30
    bg exit: 4:30
    onStop
    App initialize 4:35
    Counter in App initialize: 7
    onStart
    getServiceDelegate: 4:35
    bg exit: 4:35
    onStop
    App initialize 4:40
    Counter in App initialize: 7
    onStart
    getServiceDelegate: 4:40
    bg exit: 4:40
    onStop
    App initialize 4:45
    Counter in App initialize: 7
    onStart
    getServiceDelegate: 4:45
    bg exit: 4:45
    onStop
    App initialize 4:50
    Counter in App initialize: 7
    onStart
    getServiceDelegate: 4:50
    bg exit: 4:50
    onStop
    App initialize 4:55
    Counter in App initialize: 7
    onStart
    getServiceDelegate: 4:55
    bg exit: 4:55
    onStop
    ====> stop native run activity and return to WF
    App initialize 5:00
    Counter in App initialize: 7
    onStart
    onBackgroundData=4:55 8 at 5:00
    getInitialView
    From OS: data=4:55 8 at 5:00
    App initialize 5:00
    Counter in App initialize: 7
    onStart
    getServiceDelegate: 5:00
    bg exit: 5:00
    onStop
    onBackgroundData=5:00 9 at 5:00
    App initialize 5:05
    Counter in App initialize: 7
    onStart
    getServiceDelegate: 5:05
    bg exit: 5:05
    onStop
    onBackgroundData=5:05 10 at 5:05
    onStop counter=10 5:06
    App initialize 5:06
    Counter in App initialize: 10
    onStart
    getInitialView
    From OS: data=none 10 at 5:06
    onStop counter=10 5:06
    =====>done

    From the other log you can see both background processes don't run at the same time,, but you'll see while switching, there could be a minor overlap. 

    App initialize 3:29
    Counter in App initialize: 0
    onStart
    getServiceDelegate: 3:29
    onAppInstall
    onStop
    App initialize 3:31
    Counter in App initialize: 0
    onStart
    getInitialView
    From OS: data=none 0 at 3:31
    App initialize 3:31
    Counter in App initialize: 0
    onStart
    getServiceDelegate: 3:31
    bg exit: 3:31
    onStop
    onBackgroundData=3:31 1 at 3:31
    onStop counter=1 3:31
    App initialize 3:31
    Counter in App initialize: 1
    onStart
    getInitialView
    From OS: data=none 1 at 3:31
    App initialize 3:36
    Counter in App initialize: 1
    onStart
    getServiceDelegate: 3:36
    bg exit: 3:36
    onStop
    onBackgroundData=3:36 2 at 3:36
    App initialize 3:41
    Counter in App initialize: 1
    onStart
    getServiceDelegate: 3:41
    bg exit: 3:41
    onStop
    onBackgroundData=3:41 3 at 3:41
    App initialize 3:46
    Counter in App initialize: 1
    onStart
    getServiceDelegate: 3:46
    bg exit: 3:46
    onStop
    onBackgroundData=3:46 4 at 3:46
    App initialize 3:51
    Counter in App initialize: 1
    onStart
    getServiceDelegate: 3:51
    bg exit: 3:51
    onStop
    onBackgroundData=3:51 5 at 3:51
    App initialize 3:56
    Counter in App initialize: 1
    onStart
    getServiceDelegate: 3:56
    bg exit: 3:56
    onStop
    onBackgroundData=3:56 6 at 3:56
    onStop counter=6 4:00
    App initialize 4:00
    Counter in App initialize: 6
    onStart
    getInitialView
    From OS: data=none 6 at 4:00
    onStop counter=6 4:00
    ====(one hr gap here when other WF was the active one)
    App initialize 5:06
    Counter in App initialize: 6
    onStart
    getInitialView
    From OS: data=none 6 at 5:06
    onStop counter=6 5:06
    App initialize 5:06
    Counter in App initialize: 6
    onStart
    getInitialView
    From OS: data=none 6 at 5:06
    App initialize 5:06
    Counter in App initialize: 6
    onStart
    getServiceDelegate: 5:06
    bg exit: 5:06
    onStop
    onBackgroundData=5:06 7 at 5:06
    App initialize 5:11
    Counter in App initialize: 6
    onStart
    getServiceDelegate: 5:11
    bg exit: 5:11
    onStop
    onBackgroundData=5:11 8 at 5:11
    App initialize 5:16
    Counter in App initialize: 6
    onStart
    getServiceDelegate: 5:16
    bg exit: 5:16
    onStop
    onBackgroundData=5:16 9 at 5:16
    App initialize 5:21
    Counter in App initialize: 6
    onStart
    getServiceDelegate: 5:21
    bg exit: 5:21
    onStop
    onBackgroundData=5:21 10 at 5:21
    App initialize 5:26
    Counter in App initialize: 6
    onStart
    getServiceDelegate: 5:26
    bg exit: 5:26
    onStop
    onBackgroundData=5:26 11 at 5:26
    onStop counter=11 5:27
    App initialize 5:27
    Counter in App initialize: 11
    onStart
    getInitialView
    From OS: data=none 11 at 5:27
    onStop counter=11 5:27

    So, only the background for the active WF runs.  You'll see in the first log, I start the native run app, and the background for only that WF runs during that time too.

  • Actually, what you're doing there means the background runs only a single time, as onStop() is called when the background terminates.  So, you're removing the background process from the picture.

    In the logs I posted, you can see that onStop() is called when the background process ends, Specifically in the first log between 4:30 and 5:00  OnStart(),getServiceDelegate(),bg exit,onStop()

    onStart
    getServiceDelegate: 4:45
    bg exit: 4:45
    onStop

  • hum, very odd because I use bg for weather and with this it is still updating...

  • You'll re-register the temporal event each time the WF starts, so if you move to a widget or an app, it will run when you return to the WF.

    Put in some println calls for things and you can see what's happening and when.

  • Oh OK, so it is why the battery consumption decrease. 

    If I believe Travis, how can I do to stop the bg when I set an other wf ?

    Put this in onHide maybe ? 

  • If you look at the two log files I posted, only the background for the active WF runs.  As I said that's been my understanding since backgrounding was introduced, and the logs show it.

    There could be a bug on the f6 in relation to this but I don't have one to test this on.

  • I found this post where you answered

    https://forums.garmin.com/developer/connect-iq/f/discussion/6107/how-to-stop-a-duration-based-backgroundservice/40716#40716

    Since the global are not shared, where I am supposed to put the Var isbackground = False. 

    Im pretty sure it is a f6 bug because I didnt have this on my F5. 

    And your log are clear on how it works !