felixwiemuth / SimpleReminder

Efficient creation of simple reminders on Android.
Other
57 stars 9 forks source link

Notifications not showing reliably on Redmi5+ #13

Open Sergei-Alekseev opened 3 years ago

Sergei-Alekseev commented 3 years ago

just report: on my device redmi5+ reminder doesn't work when device is in sleep. notification popup immediately after switching device on. battery optimization is disabled , everything is granted.

maybe its a good idea to bind system jobs for notifications?

felixwiemuth commented 3 years ago

Hi, can you please add Android version (and custom ROM if any) and app version?

Do you have any special system modifications or settings that could hold notifications back?

Does this happen for other notifications too? Are there other open source apps where notifications reliably work when the device is in sleep?

It seems like for you the app supports a feature that is not yet implemented (first show notifications on screen on) :D.

So the way scheduling happens is with exact alarms which I think is the strongest time guarantee you can get on Android. The alarm starts an IntentService to show the notificaction - the problem might be here, the docs now say that IntentService doesn't work correctly on newer versions of Android. However, I did not see any problem with notifications on Android 8,9,10 and 11 on different devices.

Not sure what you mean by binding system jobs?

Sergei-Alekseev commented 3 years ago

Android 8.1, MIUI 11, latest off. global firmware. Okay, sometimes notification works, sometimes not. Binding jobs i mean some apps can startup in background for notification popup or other things. For exam i can setup alarm using miui clock app and kill app using task manager. At selected time clock app will start, light screen, play sound etc. Its good because reminder will works even if app is killed by oom.

felixwiemuth commented 3 years ago

Android 8.1, MIUI 11, latest off. global firmware.

Thanks. And app version? The app is currently targeting exactly up to Android 8.1, so that should not be the problem.

Okay, sometimes notification works, sometimes not.

Probably the notifications are more likely to be delayed when the device sleeps for longer? That's how it is without battery optimization disabled (even though then it doesn't show the notification at all).

Binding jobs i mean some apps can startup in background for notification popup or other things. For exam i can setup alarm using miui clock app and kill app using task manager. At selected time clock app will start, light screen, play sound etc. Its good because reminder will works even if app is killed by oom.

So in general it does not matter whether the app is closed (manually or by the OS because of low resources), the scheduled event will still fire and start the service which shows the notification. However, if one force-closes the app (e.g. via App info -> Force stop, which also gives a warning that the app might misbehave), then even scheduled events won't fire, and notifications first work again after starting the app manually. But I don't think that your OS freely force closes apps, that would be fatal (like in this case). Also, then you probably wouldn't see the notification when turning the screen on.

I rather guess that the OS/MIUI has some additional power saving features which hold back activities when the device sleeps. Do you have any of those turned on? Is it possible to add SimpleReminder as an exception?

If you can name some open source apps where notifications or alarms are shown reliably, I can see whether they schedule events differently.

Sergei-Alekseev commented 3 years ago

App is latest from fdroid. Battery optimization is disabled. But i guess MIUI is treating non-system, non-root apps as not important or something like that) Even Whatsapp sometimes stop working in the background and i miss some calls. I am not programmer etc but maybe this https://developer.android.com/training/scheduling/alarms is what i call system jobs) I can force stop Clock and app start at alarm time.

felixwiemuth commented 3 years ago

App is latest from fdroid.

v0.9.7

Battery optimization is disabled. But i guess MIUI is treating non-system, non-root apps as not important or something like that) Even Whatsapp sometimes stop working in the background and i miss some calls.

Yeah that really sounds like a general problem with your system which might be overly aggressive with additional battery saving measures. Normally there should be ways of disabling that, also for single apps. You can probably find more info about your device regarding this topic in general Android forums. Let me know if you come across anything useful or you get it resolved.

I am not programmer etc but maybe this https://developer.android.com/training/scheduling/alarms is what i call system jobs) I can force stop Clock and app start at alarm time.

I am aware of how scheduling generally works on Android (and have been through all the trouble with battery optimization when it was introduced) and probably there is nothing wrong with how reminders are currently scheduled (i.e., it should work according to the specification).

However, in the next months I might make an update to how the task of showing notifications is performed, maybe that will make a difference.

felixwiemuth commented 1 year ago

Please try the following guide (and/or app): https://f-droid.org/en/packages/com.urbandroid.dontkillmyapp/ and let me know whether it helps.

In addition, the new version 0.9.11 changes a lot regarding scheduling. Please also test after the update whether you observe the same problem and whether anything has changed.

There is also a new discussion #35 regarding similar problems on a Redmi device.