Page MenuHomePhabricator

Only run live updates when tab is being viewed
Closed, ResolvedPublic3 Estimated Story Points

Description

Now, in terms of performance. The live update mode generates a lot of requests. Those requests keep happening even when the browser tab is in the background. This must be changed to requests only happening when the current page/tab is in focus. There's no point running those updates for a tab that the user doesn't see.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
DannyS712 triaged this task as Medium priority.Nov 19 2020, 6:31 PM
DannyS712 moved this task from Unsorted to Next on the User-DannyS712 board.
DannyS712 set the point value for this task to 3.

Refs / code to draw from / things to consider

Of the supported browsers, the desktop browsers allow using the pagevisibility api, but the mobile ones don't always

  • Safari (MW supports 5.1+, only available in 6.1+)
  • iOS (MW supports 6.1+, only available in 7+)
  • Android (MW supports 4.1+, only available in 81+ (though the numbering system changed in between))

T229239: Refresh target browser support for MW, dropping less-used browsers from Grade A to Grade C would solve the Safari and iOS support by dropping the versions that don't support the api
Not sure how to handle android

...that being said, this is geared towards desktops, not mobile views, and is not critical, so adding this handling when the page visibility api is available is better than nothing

Event handler should be attached in the "On ready initialization" for SpecialGlobalWatchlist.display.js, and in mounted for the vue version. If the visibility is hidden, and live updates is true, should set to paused, and if it is visible, and live updates is paused, should set it back to true.

Change 643157 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/GlobalWatchlist@master] Only run live updates while the tab is visible

https://gerrit.wikimedia.org/r/643157

Of the supported browsers, the desktop browsers allow using the pagevisibility api, but the mobile ones don't always

Have you considered using document.hasFocus() instead? It has better support for old mobile browsers, but might be a pain to use as the boolean value would need to be polled periodically (there's no event to listen to).

Of the supported browsers, the desktop browsers allow using the pagevisibility api, but the mobile ones don't always

Have you considered using document.hasFocus() instead? It has better support for old mobile browsers, but might be a pain to use as the boolean value would need to be polled periodically (there's no event to listen to).

I think the fact that there is no event rules it out for now, but I'll look into adding that in addition to using the pagevisibility api

Change 643157 merged by jenkins-bot:
[mediawiki/extensions/GlobalWatchlist@master] Only run live updates while the tab is visible

https://gerrit.wikimedia.org/r/643157

DannyS712 claimed this task.
DannyS712 moved this task from In progress to Done on the MediaWiki-extensions-GlobalWatchlist board.