nextcloud / notifications

🔔 Notifications app for Nextcloud
GNU Affero General Public License v3.0
116 stars 56 forks source link

No notifications from open chat when Chrome is in background #1946

Open RTechSn opened 4 months ago

RTechSn commented 4 months ago

How to use GitHub


Steps to reproduce

  1. Have a chat with another account open.
  2. Have no notifications from other apps
  3. Minimize or obstruct your browser window
  4. Send a message from another account

Expected behaviour

Notifications should appear

Actual behaviour

Notifications appear after unminimizing the window, or not appear at all

Talk app

Talk app version: 19.0.0

Custom Signaling server configured: yes/no and version (see Talk administration settings: /index.php/index.php/settings/admin/talk#signaling_server)

Custom TURN server configured: Yes

Custom STUN server configured: Yes

Browser

Microphone available: yes

Camera available: no

Operating system: Windows

Browser name: Chrome

Browser version: 123

nickvergessen commented 3 months ago

Actually we improved exactly these scenarios in the Talk 18 version. At least when switching to another tab that is. When overlapping the browser with another window that is not detectable from within the website as far as I recall, but @Antreesy might know more

ratmix commented 3 months ago

i also really need notifications to work when the browser tab is not active

9joshua commented 3 months ago

Likewise. For me on Desktop the notification is suspended until the Spreed tab is focused - defeating the purpose of the notification.

RTechSn commented 3 months ago
2024-06-10 103325

As you can see, message is received by the client, but the notification is somehow suppressed, until you unminimize the window.

Antreesy commented 3 months ago

See https://github.com/nextcloud/spreed/pull/10544 : Conversation session is considered active (and you won't receive notiication for this exact conversation only) when:

Then you should see a request like nextcloud.local/ocs/v2.php/apps/spreed/api/v4/room/{token}/participants/state to server with payload 0: image

Same request is sent when you:

Though in that case, you shouldn't receive any notifications from server (304 response status). Apart from it, we are not blocking any native pop-ups by code.

RTechSn commented 3 months ago

2024-06-11 100806 @Antreesy I've checked again, here you can see that the session is marked as inactive and the notification has been received by the browser. But there is no pop-up notification, until you focus the window. This bug occurs only if you have no other notifications and only on Chromium browsers.

Antreesy commented 3 months ago

I've checked again, here you can see that the session is marked as inactive and the notification has been received by the browser. But there is no pop-up notification, until you focus the window. This bug occurs only if you have no other notifications and only on Chromium browsers.

Thanks for the confirmation, will try to reproduce it

Antreesy commented 3 months ago

Yep, reproducible for me. As I understood it, issue seems to be on Notifications app side (frontend):

```vue // in NotificationsApp watch:{ notifications(value) { console.log('watch notifications', value) if (value[0]?.shouldNotify && this.showBrowserNotifications && this.webNotificationsThresholdId < value[0]?.notificationId) { const n = new window.Notification(value[0]?.subject, { title: value[0]?.subject, lang: OC.getLocale(), body: value[0]?.message, icon: value[0]?.icon, tag: value[0]?.notificationId, }) } }, }, ```

Transferring this issue to nextcloud/notifications repo

ShGKme commented 3 months ago

We are checking only active/inactive state. We can also check for frozen/ discarded states for suspended tabs.

I'd say that a proper solution is to move notifications completely out from any DOM rendering, best to a worker to not be a part of the page that can be frozen.

nickvergessen commented 3 months ago

While yes, let's first do the quick fix of moving it to the root component

ShGKme commented 3 months ago

For the reference:


In a frozen state, DOM is not updated, but background tasks are still running.

In a discarded state, no new task from the task queue will be executed.

So, to support discarded state or true push notifications, we would need to use workers what most of our libraries do not support.

RTechSn commented 3 months ago

This particular issue seems to be fixed in the last update (29.0.3). Should this issue be closed, or should it remain open, until the proper solution with the support of discarded state be implemented?

Antreesy commented 3 months ago

should it remain open, until the proper solution with the support of discarded state be implemented?

Yes, we wanted to keep track it and look into web workers usage in the future for handling notifications. You may unsubscribe from receiving a notifications from this issue to not suddenly be bothered one day. Thanks again for the help with investigation!

MohammedNoureldin commented 3 months ago

Hi

I have issues generally in Nextcloud notifications. In both Desktop PWA and in browser. The notifications do not arrive and are not shown when the Windows is minimized (PWA and NC webpage). As soon as I open the Window, the notifications are shown (not always quickly, but at least they arrive).

The notifications are in general too slow.

Is it related to this issue and planned for 29.0.4, or is it not related?

I am using 29.0.0

nickvergessen commented 3 months ago

I am using 29.0.0

Then update please. Mostlikely it's fixed in 29.0.2 via https://github.com/nextcloud/notifications/pull/1948

MohammedNoureldin commented 3 months ago

Thanks a lot @nickvergessen! I confirm that it works now with 29.0.3.

Nevertheless, the notification on the desktop (Web or PWA) is slow, it takes always about 20-30 seconds for the notification to arrive and get shown in Windows. Is there anything we can do for it?

nickvergessen commented 3 months ago

Is there anything we can do for it?

Yeah we do 30 second polling. So can be between 0 and 29 seconds. You can install this additional tool that will create a websocket connection with the clients and browser so that notifications can be pushed live: https://github.com/nextcloud/notify_push