User idle not working if browser tab focus is changed to another tab/window

127 views Asked by At

I am using angular-user-idle plugin for my application to track whether the user is idle or not. Plugin: https://github.com/rednez/angular-user-idle

The plugin "onTimerStart" method is able to return counter/count value if the user is on the application or the application is in focus. But if the user changes it's focus by opening a new tab or a new window then the application lags and doesn't provide proper values and sometimes it get's stuck as well till the time the user is headed back to the application. Which resulting in inconsistent idle activity. And due to which user idle calculation/screening is not accurate. I searched around and found out that it might be due to latest browser throttling down the application if the app is not in focus or the tab is switched to some other application. So, I am not getting how do I overcome this issue. As I need to update user by updating the document title that X seconds are left before timeout/logout.

Scenario: Let's say idle time is 60 secs meaning if no activity is detected for 60 secs. Application will mark the user as idle. And timeout is set to 120 secs. Meaning a counter/count down will start and will go till 120 secs before marking the user logout.

So, now let's say if a user is idle for 40 secs and he opens a new tab in the browser. So, I want my application to show the title after 20 secs (40 + 20 = 60secs). That "You will be logged out in 120 secs" and so on.... till "You will be logged out in 1 secs" in the document title.

But due to application losing focus the "onTimerStart" method of the plugin does not return any values and hence I am unable to show this to user in document title.

0

There are 0 answers