cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
StraighterSwing
Level: Powered On

Timer stops counting down when browser tab focus changes

I have a timer on my PowerApp.  If I have 2 or 3 other tabs open, if the timer is running and I change tabs, the timer stops. It won't continue so I can do other things in other tabs while it's running.

However, if I have the PowerApp in its' own browser window, it will run just fine if I'm working in another browser session.

 

How can I make the timer always continue to run regardless of if I'm working in another tab?

 

I tried to include a video of the problem but I cannot upload mp4 files.

7 REPLIES 7
SKH19
Level 10

Re: Timer stops counting down when browser tab focus changes

Hi @StraighterSwing 

This is a browser issue. I know Chrome throttles background timers in order to conserve resources and save battery life. 

You can try other browsers to see if they have different resource allocation for background tabs, but I think it is quickly becoming industry standard.

Unfortunately, there is nothing that can be done to affect this in Power Apps.

 

---
Please hit the "Accept as Solution" button if my post answered your question! If my post was helpful please consider giving it a "Thumbs Up."

Microsoft v-siky-msft
Microsoft

Re: Timer stops counting down when browser tab focus changes

Hi @StraighterSwing ,

 

The problem also occurs on the ios client when you switch to another app and PowerApps client is running in the background, the timer stops counting down. I'm not sure if this is a design flaw, but you can feedback this to PowerApps, just submit an idea to PowerApps Ideas Forum.

As an alternative workaround, please modify your Timer control as below:

1. Set Duration: 1000

2. Set OnSelect: 

 

Set(StartTime, Now());
Set(Now, Now())

 

3. Set OnTimerStart: 

 

Set(Now, Now())

 

4. Set Text: 

 

 Text(Time(0, 0, DateDiff(StartTime,Now,Seconds)), "[$-en-US]hh:mm:ss")

 

 Then it will be like this:

StoG_18.gif

Sik

Highlighted
StraighterSwing
Level: Powered On

Re: Timer stops counting down when browser tab focus changes

Thank you for the suggestion but I don't think that'd work for a countDOWN timer.  My timer counts down so I don't think using Now() will work in this case.

Microsoft v-siky-msft
Microsoft

Re: Timer stops counting down when browser tab focus changes

Do you mean countdown?

You can try this, take 10 seconds as an example:

Set OnSelect property: 

 

Set(StartTime, DateAdd(Now(),10,Seconds));
Set(Now, Now())

 

Set OnTimerStart : 

 

Set(Now, Now())

 

Set repeat: 

 

If(Timer1.Text="00:00:00",false,true)

 

Set Duration: 1000

Set Text: 

 

 Text(Time(0, 0, DateDiff(Now,StartTime,Seconds)), "[$-en-US]hh:mm:ss")

 

Then the timer will countdown from 10s - 0s.

If this doesn't make sense, please submit an idea to PowerApps Ideas Forum.

Sik

dynamicsedge
Level 8

Re: Timer stops counting down when browser tab focus changes

@v-siky-msft 

 

We never encounter this but in case for future, we are also interested to keep this in mind in case.

 

So you claim that Timer does not work in background?

Actually we presumed this. We thought the PowerApps Timer may not work in background when app is not active.

 

However, we may be interested in your workaround to force timer to work in the background, including in cases where the underlying framework may put the Timer to sleep.

 

So for timer to work in Background, you are making the time duration shorter (1 second), auto repeating timer, and setting variable each time?

 

Why does it work to do this??

 

Is your setting of the variable all the time causing the app to remain awake in the background by force?

 

Why does your workaround cause the Timer to work in background effectively whereas supposedly if you do not do this, the Timer doesn't work in the background without this workaround?

Microsoft v-siky-msft
Microsoft

Re: Timer stops counting down when browser tab focus changes

The timer background shutdown is the result of our testing. I am here to provide an alternative solution. 

In my solution, the Timer text is calculated in two times (StartTime - Now), Time can not be affected by background dormancy. The StartTime is set and the current time(Now) is updated every second, then the Timer Text shows the calculated result, Time countdown.

Sik

 

 

dynamicsedge
Level 8

Re: Timer stops counting down when browser tab focus changes

@v-siky-msft 

 

Ah, thank you for clarifying.

 

So actually the trick is, the Timer is retrieving value of time passed, now it makes sense. 

 

In your GIF now we understood why the old amount of time still showed for split second.

Because it was not a workaround to dormancy, it was a workaround to still keep track of amount of time being passed even after it was made dormant, and to update right away when made awake again.

 

So if suppose something had to actually happen when countdown ended exactly and while still dormant, this would not work.

 

However, it could still work, if it was OK for the countdown action to be performed immediately when the app is made awake again, even if it means it could be later than the literal countdown time (i.e. not until app was made awake again at the minimum).

 

This is great alternative solution @v-siky-msft considering the limitation.

 

This would be similar to something we might do under these conditions

Aside from your idea, we would be unsure how to do it while the app was dormant and countdown timer literally enforced even if it was dormant. Your alternative is very great though considering the limits.

 

Helpful resources

Announcements
thirdimage

Power Platform 24

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (5,296)