element-x-android icon indicating copy to clipboard operation
element-x-android copied to clipboard

Intermittent push notifications

Open kieranlane opened this issue 8 months ago • 5 comments

Steps to reproduce

Receive / expect to receive a push notification.

Outcome

What did you expect?

Push notifications should reliably function, including:

  1. When the device is locked
  2. When the Element X app is no longer in the foreground
  3. Inbound DM Element Call push notifications should correctly render as full screen inbound calls

What happened instead?

  1. Intermittently see a notification in the notification bar but do not hear the audio notification while the phone is locked. When you unlock the phone, the notifications are sitting in the bar and on the EX app icon/badge

  2. We don't see/hear notifications at all. We see the new messages when we bring EX back to the foreground

  3. EC inbound calls in a DM room - We've only seen the "full screen inbound call" behavior twice out of several calls. Other times we'll see a push just stating there's an inbound call (similar to what I think we'd expect in a group room).

Notes / Context

  • Homeserver is not configured with Sygnal nor Unified Push/ntfy gateway for these servers. We're just using the default push notification proxy that I think is run at matrix.org.

  • The notification tests in EX all pass when run.

  • Push notifications from a test homeserver whose traffic to the matrix push proxy is sourced from AWS appears to be affected, whereas a test homeserver deployed locally does not. However, this could also be due to specific device(s), the AWS test server has been tested with Samsung A35 5Gs - the local with an S25.

  • All issues occurred whilst testing connected to commercial VPNs.

Your phone model

Samsung A35 5G

Operating system version

Android 15

Application version and app store

25.03.4 from Google Play Store.

Homeserver

ESS LTS 24.10.11 1.116.0+lts.4

Will you send logs?

Yes

Are you willing to provide a PR?

Yes

kieranlane avatar Apr 07 '25 16:04 kieranlane

Pending debug logs to be attached. Possible related https://github.com/element-hq/element-x-android/issues/4390 & https://github.com/element-hq/element-x-android/issues/4456

kieranlane avatar Apr 07 '25 16:04 kieranlane

Just testing the 3 points below using EXA, 2 matrix.org account in a DM and using Firebase (FCM):

  1. When the device is locked
  2. When the Element X app is no longer in the foreground
  3. Inbound DM Element Call push notifications should correctly render as full screen inbound calls

and did not see any particular issue today.

It's worth noting that if Firebase notification is not working anymore, we will get quick feedback from users.

Waiting for some logs to investigate more. If possible, please include a screenshot of the notification troubleshoot screen after running the tests.

bmarty avatar Apr 08 '25 08:04 bmarty

I experience the same. It works for a while after reinstall, then suddenly stops working. The trigger seems to be switching network from wifi to cellular.

It also sometimes seems to work on wifi but not cellular. And sometimes not at all.

Pixel 7p and element x 25.03.4

Let me know how if I can help debug

lasse-aagren avatar Apr 09 '25 05:04 lasse-aagren

Additional notes:

When the app enters this "bad state" -- i.e. When not receiving notifications / push, I also can't send messages either. They queue (with the infinite spinning circle). No offline message, No syncing failures, etc. Connected to the internet, can access the homeserver URL via other apps (am connected to a VPN).

  • Sometimes, it will eventually works.
  • Usually will have to kill and restart the app. This gets it instantly working again. (Both receives and sends those queued outgoing messages)

One example of when this Element X entered this "bad state":

  • The phone was locked, having kept Element X in the foreground.
  • Element X is excluded from Battery Optimatisations, and are allowed unrestricted background data.
  • Phone is not connected to charger (though have seen this occur when is was)
  • VPN connected (also excluded from Battery Optimatisations and allowed unrestricted background data.)
    • Note, despite Element X being in "bad state", all other apps can access network just fine.
  • When phone is unlocked:
    • Chat list doesn't show any new messages sent.
    • No notifications.
    • Opening the room still does not show the new messages / trigger getting them.
    • When sending a message, the message is sitting "waiting to send".
    • All green on the notification troubleshooter test. (The fake notification comes in).
    • Back to chat list, still no new messages, or sent message.

After an hour or so, this specific instance "fixed" itself, all that was done was:

  • Went through grabbing all the debug logs. Saved them to phone storage.
  • Re-Locked phone. Let it sit for a bit.
  • Suddenly everything suddenly came in, and all the queued outbound messages came through on their web client.

kieranlane avatar Apr 09 '25 11:04 kieranlane

I turned on my A35's hotspot yesterday and attached another phone to it for connectivity. So far from what I can tell, notifications have been reliably coming in. I think having the hotspot enabled is preventing the phone from going into Doze or some other power saving state that was causing problems with EX. I haven't pulled any logs yet to see what's happening underneath the hood to confirm my theory.

Going to send test instructions RE: manually testing Doze. We didn't try before as the issue was already affecting the test device.

kieranlane avatar Apr 09 '25 15:04 kieranlane

Hello, We have made several improvements regarding the notification stability, available starting from EXA 25.06.2:

  • When a push is received and the application is not able to resolve the Event, the Push is not silently ignored anymore. In this case, the application will render a generic notification with the text "You have new messages". (https://github.com/element-hq/element-x-android/pull/4889)
  • When there is such unresolved event, the application will render a banner in the room list to suggest user to disable the battery optimization (if it is not already disabled). Disab ling battery optimization is helping the application to get access to the network and so will limit the number of errors when retrieving the error data. (https://github.com/element-hq/element-x-android/pull/4845). I think that will all this improvements, we can close this issue now.

bmarty avatar Jun 20 '25 12:06 bmarty