Page MenuHomePhabricator

Update Echo Notifications in real time without page reloads
Open, HighPublic

Description

Classic 'new message' notifications about your talk page or LQT only show up when refreshing a page.

Polling the web API every couple minutes could be nice, especially if things like RecentChanges turn into more interactive pages that will be long-running.


Alternatively, a non-polling implementation (real-time) could use something like Server-Sent Events (browser support), WebSockets (browser support) with COMET fallback, T113125: Investigate using service workers to provide real-time Echo notifications in the browser (push notifications), or another option. There are libraries that handle some of the browser compatibility issues with these.

Details

Reference
bz32284

Related Objects

StatusAssignedTask
ResolvedNone
OpenNone
InvalidWikinaut
OpenNone
OpenNone
Resolveddemon
DuplicateNone
ResolvedGalorefitz
ResolvedNone
DeclinedQuiddity
DeclinedNone
OpenNone
OpenNone
OpenNone
StalledNone
OpenNone
ResolvedNone
OpenNone

Event Timeline

bzimport raised the priority of this task from to High.
bzimport set Reference to bz32284.
bzimport added a subscriber: Unknown Object (MLST).
brion created this task.Nov 8 2011, 9:09 PM

Brion: Is this ticket Echo territory nowadays? Should this be moved, or can this be considered closed?

brion added a comment.Feb 16 2014, 5:38 PM

Sounds like Echo territory for implementation -- has this been implemented in Echo, or is it still something that needs doing?

Not sure if that's implemented already, but if it was it would be Echo territory. Hence moving there. Might require fixing bug 32283 first...

See also bug 59879 (probably a duplicate?), particularly comment1 by legoktm

This is inconsistent with other sites where notification are shown in real-time, or at least while the user is on the page rather than leaving or explicitly reloading the page.

  • Bug 59879 has been marked as a duplicate of this bug. ***

I put together a POC at I8f7bc77d05762fd12927437f6450ae3f97eb84af.

It simply polls the API every 60 seconds to check for new notifications (it kinda but not really works).

That said, I don't think polling is a good idea. We should instead have some kind of websockets service pushing notifications to the user/browser. This might line up well with [[mw:Requests for comment/Publishing the RecentChanges feed]].

Kunal, sounds like a reasonable stopgap measure fix, as you said there are better ways to do it, How would you feel about increasing the polling frequency but tying it to an activity timer, associated with page scrolling or mouse movement, e.g. we poll at a higher frequency while we know the user is interacting with the page, and stop polling or poll much more infrequently when no activity is detected. Quora uses a similar approach.

Another metric of, is the user looking at the page could be a mixture of Page Visibility API https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API#Use_cases and window focus and blur for older browsers compatibility. http://stackoverflow.com/questions/14309596/detecting-when-browser-window-tab-is-not-in-the-foreground

For T75209, we need a more frequent update than "every 2 minutes".

Polling the API (whether every 2 minutes or every 1 minute or every second) is not truly real-time, IMHO (and also not performant).

Any objection to changing this task to be about true real-time (i.e. Server-Sent Events, WebSockets, COMET fallback and such)?

Sounds good unless it permanently blocks this task ;)

sent while mobile

He7d3r added a subscriber: He7d3r.Nov 26 2014, 10:55 AM

Polling is not really real-time, as I said earlier. However, I think polling at a reasonable interval (not too much load on the server) is an appropriate interim solution for this. Detecting whether the user is really looking at the page (with page visibility API and such) as suggested by @Jaredzimmerman-WMF) could help with this.

I do think some kind of server push is better medium-term.

@Mattflaschen whats the highest polling frequency you'd be comfortable with, Ideally we'd be be talking about something in the single digit seconds when the window is in focus, and 30-90 when its out of focus?

@Mattflaschen whats the highest polling frequency you'd be comfortable with, Ideally we'd be be talking about something in the single digit seconds when the window is in focus, and 30-90 when its out of focus?

I'm not really sure. But my gut tells me that if you want to measure it in seconds (especially single-digit seconds, which I think would be a problem especially on higher-latency connections, and likely for the server), we're better off implementing server push.

If PHP is not suitable, it could perhaps be implemented as a service (similar to Parsoid, Citoid, Mathoid, Offline content generator).

Mattflaschen-WMF set Security to None.
Restricted Application added a project: Growth-Team. · View Herald TranscriptJul 26 2018, 12:25 PM
JTannerWMF added a subscriber: JTannerWMF.

This is a powerful long-standing feature idea, but the team will not have time to work on it in the near future.