proginosko / LeechBlockNG

LeechBlock NG (Next Generation) for Firefox is a simple productivity tool designed to block those time-wasting sites that can suck the life out of your working day. All you need to do is specify which sites to block and when to block them.
https://www.proginosko.com/leechblock/
Mozilla Public License 2.0
723 stars 66 forks source link

Countdown timer keeps going even when the screen is off #418

Open bluekeyboards opened 8 months ago

bluekeyboards commented 8 months ago

Using Firefox Android 123.1.0 and LeechBlock NG 1.6.3. When I'm viewing a tab with an active countdown timer, if my phone's screen turns off, the timer will continue running as if the tab was focused. This happens both when I manually turn my screen off (by pressing the physical button) and when it turns off automatically after a period of inactivity. The same thing happens when I go back to my home screen or switch to other apps while I'm on that tab.

The option "Treat browser window as always active" has always been off, toggling "Count time spent on these sites only when browser tab is active" on/off doesn't seem to make a difference, neither does "Process only active tabs". I have never used the override mode.

The timer does stop properly when I switch tabs or when I close Firefox (from the Recent Apps view) and restart it. I found a relatively similar issue #122 and used the website you linked, https://www.proginosko.com/test/WindowFocusEvents.html, and my browser correctly triggers BLUR events when the screen is turned off and when I switch tabs/apps.

EDIT: Just to cover all my bases, I tried Firefox Beta. No difference.

proginosko commented 8 months ago

Thanks for the report.

Yes, this is a known issue. The main problem is that Firefox for Android doesn't implement any part of the windows API for browser extensions (despite requests from some extension developers). One workaround I've experimented with is to use a content script to track the blur/focus events for a document's window object (as in the test page linked above, which works on Android). But the problem with that solution is that currently Firefox for Android doesn't correctly implement content scripts (see here). So unfortunately I'm kinda stuck with the problem for now. 🙁