cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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.

10 REPLIES 10
Highlighted
Impactful Individual
Impactful Individual

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."

Highlighted
Community Support
Community Support

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
Frequent Visitor

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.

Highlighted
Community Support
Community Support

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

Highlighted
Power Participant
Power Participant

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?

Highlighted
Community Support
Community Support

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

 

 

Highlighted
Power Participant
Power Participant

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.

 

Highlighted
Frequent Visitor

Re: Timer stops counting down when browser tab focus changes

Is it possible to do this automatically?

 

I have tried doing these steps but there is an error when I do it on Autostart.

Highlighted
Regular Visitor

Re: Timer stops counting down when browser tab focus changes

How do you make the label return to 00:00:00?

 

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (3,486)