chrono icon indicating copy to clipboard operation
chrono copied to clipboard

Alarm not ringing or ringing later than specified

Open Rafee-M opened this issue 1 year ago • 58 comments

Describe the bug The alarm seems to ring ~10 minutes late or doesn't ring at all sometimes

To Reproduce Steps to reproduce the behavior:

  1. Set an alarm more than 30 minutes away
  2. Wait

Expected behavior Ring at specified time

Smartphone Information

  • Device: OnePlus 9RT
  • OS: Android 13
  • App version: 4.1 (clean install)

Additional context I had enabled foreground, background usage, turned off optimization, enabled auto launch. Still the alarm ringing is a hit or miss. In contast, I gave Simple Clock only foreground usage and it still seems to ring at specified times

Screenshots

Example 1: At 8:30 AM an alarm was set for 9:35 AM. It rang at 9:39 only after unlocking the phone and opening Chrono

Untssitled Untitled

Example 2: A notification for upcoming alarm at 11:15 AM (set at 10:30 AM) was receieved. But the alarm failed to ring. Opening the app also didn't make the alarm ring as well. Screenshot_2024-04-19-11-29-13-07

https://github.com/vicolo-dev/chrono/assets/69535896/43aac825-14e0-4826-ae0e-75e262609b9e

Battery settings for Chrono: (Simple Clock only had the Foreground activity enabled)

Untiasatled

Rafee-M avatar Apr 19 '24 05:04 Rafee-M

Have you tried everything listed here: https://dontkillmyapp.com/oneplus

And here: https://oneplus.gadgethacks.com/how-to/disable-setting-if-notifications-are-delayed-your-oneplus-0192639/

Especially the Advanced Optimization thing.

I don't own a OnePlus device but can you also make sure that 'Show on Lock Screen' or something similar and 'Show Fullscreen Notifications' or something similar is enabled for the app?

AhsanSarwar45 avatar Apr 19 '24 06:04 AhsanSarwar45

Have you tried everything listed here: https://dontkillmyapp.com/oneplus

Pretty much

Especially the Advanced Optimization thing.

That is not a thing in current OxygenOS. The only settings related to battery is the one shown in the screenshot and also Special App Access > Battery Optimization.

I don't own a OnePlus device but can you also make sure that 'Show on Lock Screen' or something similar and 'Show Fullscreen Notifications' or something similar is enabled for the app?

Yeah it is. Besides, the alarm does show up on lock screen if it's set not too far long (~20 minutes?). Like I've mentioned I didn't face the same thing with Simple Clock. Maybe they're doing something extra to get the alarm go off?

Other battery settings:

Display over other apps: (Chrono doesn't show up here and Simple Clock was disabled as well

Special App Access > Battery Optimization:

Rafee-M avatar Apr 19 '24 19:04 Rafee-M

App Ops and Uses permissions of Simple Clock are given below. The only thing stood out to me was the "Start Foreground" option. And Chrono seems to have quite a bit more Uses permissions.

App Ops:

Uses Permissions:

Rafee-M avatar Apr 19 '24 20:04 Rafee-M

Thanks, I'll take a look what SimpleClock does differently. Also, when did this issue first started for you? After 0.4.0/0.4.1 update or before that?

AhsanSarwar45 avatar Apr 20 '24 06:04 AhsanSarwar45

Also, when did this issue first started for you? After 0.4.0/0.4.1 update or before that?

I had some reliability issues as well, so that is why I was going back and forth between Chrono and Simple Clock.

Also, I have resolved the issue with the alarm by disabling the "Battery Optimization" option inside App Manager. Not sure what setting it enables/disables, but it does use root permissions. For now, the issue seems to have been resolved for me. Feel free to close it! Also, there seems to be an issue with the timer as well. I'll try to do some more testing and create a new issue.

The App Manager option:

https://github.com/vicolo-dev/chrono/assets/69535896/92d6aefc-d709-43de-a3ac-c56d8b7cb4f5

Rafee-M avatar Apr 20 '24 18:04 Rafee-M

I have this same behavior on a Moto G7 running LineageOS, I'm afraid. It only started happening after upgrading from LineageOS 20 (Android 13) to LineageOS 21 (Android 14). Battery optimization is off, and notifications are on.

What specifically happens is that the alarm does not go off at all, but the upcoming alarm notification is shown. The alarm does not go off after opening the app.

I don't know if this will help - Android 14 seems to have broken a lot of things that use background processing for me, from alarms to offline music players.

jfmcbrayer avatar Apr 23 '24 10:04 jfmcbrayer

I don't know if this will help - Android 14 seems to have broken a lot of things that use background processing for me, from alarms to offline music players.

Don't have a real Android 14 device at the moment but I've tested it on a stock android 14 emulator, and it works well there. So probably a real device specific optimization.

AhsanSarwar45 avatar Apr 23 '24 13:04 AhsanSarwar45

I had this happen on my Pixel 7 pro. Did not happen before 0.4.0. I disabled battery optimization in app manager, will see if that helps. Though I had it disabled anyway.

aronovgj avatar Apr 23 '24 20:04 aronovgj

The alarm didn't go off 3 nights in a row. It works after not touching the phone for about half an hour. Tinkering with app manager did not help. Trying to figure out if the issue is connected with turning on rising volume.

aronovgj avatar Apr 25 '24 13:04 aronovgj

I mentioned it in another issue, but will also mention it here. I am currently looking at adding a foreground service (optional in the settings), which will show a peristent notification and hopefully prevent the app from being killed. It will help in fixing alarm reliability issues.

Also, if possible, can you guys run the benchmark in DontKillMyApp from the app store and report the results?

It would also be helpful if you guys can suggest opensource apps that work correctly in the background on your devices, and whether they do it through a persistent notification (foreground service).

AhsanSarwar45 avatar Apr 25 '24 20:04 AhsanSarwar45

I think the apps I have that are not having problems with being killed on Android 14 all have foreground services (and thus persistent notifications). I'm talking about music apps here, though, not clock apps. The only other clock app I have tried is LineageOS stock, which rings, but only silently.

jfmcbrayer avatar Apr 25 '24 20:04 jfmcbrayer

Don't kill my app returns 100%.

K9 Mail runs well on my phone. I think it also uses a foreground service.

I deleted the old alarm that was failing and created a new one without rising volume and alarm worked this morning. Might be luck. Not sure.

aronovgj avatar Apr 26 '24 07:04 aronovgj

On my device, DontKillMyApp returns 100%.

I also created an alarm without rising volume after I saw the previous comment this morning, and it worked correctly (my phone had been asleep for about an hour). The same thing fixes the silent alarms on the stock LineageOS/AOSP clock, so I'm guessing this is an exception that is being handled differently by the two clocks.

jfmcbrayer avatar Apr 26 '24 12:04 jfmcbrayer

I deleted the old alarm that was failing and created a new one without rising volume and alarm worked this morning. Might be luck. Not sure.

If you turn on rising volume, and create an instant alarm (which rings after 5 second, button can be turned on through settings -> developers options -> show instant alarm button), does the alarm still not work?

AhsanSarwar45 avatar Apr 26 '24 18:04 AhsanSarwar45

Turn on rising volume where? Do I set it in default settings or do I create an alarm first?

I turned it on in the default settings and it works with instant alarm. It just fails after not touching it for a longer time. As already mentioned, after about one hour it still works but after a whole night it doesn't. But there is a notification showing that the alarm rang. It is like the app fails to increase the volume.

aronovgj avatar Apr 26 '24 22:04 aronovgj

It would also be helpful if you guys can suggest opensource apps that work correctly

  1. Simple Clock
  2. Fairemail (uses persistent notification)
  3. tasks.org (Reminders)

Note: As of now the alarm and timers (except timer notification) has been working flawlessly after the App Manager setting

Rafee-M avatar Apr 28 '24 10:04 Rafee-M

Instant alarm with rising volume works for me. Overnight with rising volume does not.

jfmcbrayer avatar Apr 28 '24 12:04 jfmcbrayer

And I'm afraid I spoke too soon. Even with rising volume turned off, my alarms have failed to go off for the last two days. So I think these are separate problems that are interacting with each other.

jfmcbrayer avatar May 01 '24 14:05 jfmcbrayer

After like two weeks it failed again for me

aronovgj avatar May 08 '24 21:05 aronovgj

This is a complete shot in the dark, but if you open the Android system settings and go to Apps → Special app access (might be located somewhere else on non-stock Android ROMs) there's a permission called Alarms and reminders, with the following description:

ResizedImage_Screenshot_20240509-080008(1344)x(579)2024-05-09_08-00-21_4398

Maybe Chrono needs to request this permission? It currently doesn't.

TheLastZombie avatar May 09 '24 06:05 TheLastZombie

also having this issue on lineage android 14, on a oneplus 6, battery optimization disabled

theotheroracle avatar May 09 '24 15:05 theotheroracle

go to Apps → Special app access (might be located somewhere else on non-stock Android ROMs)

Not available on OxygenOS 13

Rafee-M avatar May 09 '24 16:05 Rafee-M

This is a complete shot in the dark, but if you open the Android system settings and go to Apps → Special app access (might be located somewhere else on non-stock Android ROMs) there's a permission called Alarms and reminders, with the following description:

ResizedImage_Screenshot_20240509-080008(1344)x(579)2024-05-09_08-00-21_4398

Maybe Chrono needs to request this permission? It currently doesn't.

I think this refers to the SCHEDULE_EXACT_ALARM permission, which is only required for apps that aren't alarm clock apps. For alarm clock apps, this permission isn't needed and we instead use USE_EXACT_ALARM which is granted automatically by the system. Anyhow, if setting an alarm 1 minute into the future rings correctly, this likely isn't the issue in your case.

AhsanSarwar45 avatar May 11 '24 16:05 AhsanSarwar45

Just a bit of update, all my current research does lead to this being a battery optimization issue specific to some roms, which would need either a foreground service, or something else that I'm not aware of, to work correctly. I've planned out how the foreground service will be implemented. Currently finishing up the 0.5.0 version which brings widgets and localization and language support. After that, all my focus will be on implementing foreground service and fixing this issue.

AhsanSarwar45 avatar May 11 '24 16:05 AhsanSarwar45

There's an open source clock/alarm app that works at here Apache 2.0 licensed. Might want to look at what they're doing?

Yes, I'm having these issues. Tried everything that "don't kill my app" recommends. And the test returns 100%. Alarms almost never work. Neither do timers. On a moto stylus 4G 2021 running android 11.

So I'm using "Clock" now.

jgilmore avatar May 12 '24 15:05 jgilmore

Getting this same problem on my Pixel 6,running GrapheneOS on Android 14. Chrono App version is 0.4.2

Timers won't go off after the screen times out. I can see the notification icon on the lock screen, but it won't ring with the fullscreen alert until I unlock my phone.

TBat avatar May 22 '24 15:05 TBat

This is a continuation of the #286


Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I don't know why, alarms often don't go off, usually when they're close by.

Describe the solution you'd like On several other alarm applications, it is possible to define an application as "alarm and reminder" in "special access" (see photo below).

It says:

"Alarms and reminders

Allow this application to set alarms and schedule actions at certain times. It will then run in the background, which can battery.

If authorisation is disabled, existing alarms and events alarms and events programmed by the the app will not work."

334299083-be69bfa0-10da-44f8-9554-be29b329cbc2

Off-topic: do you know how to reduce the size of photos on github for this type of issues ?

STVGecko avatar Jun 07 '24 07:06 STVGecko

I have also encountered this issue on my Pixel 8 with GrapheneOS. Already two times this week, the alarm did not go off at all

jhvoigts avatar Jun 19 '24 06:06 jhvoigts

Hi everyone. I have added option to enable foreground notification in v0.5.2-beta1. You can turn it one by going to Settings > General > Reliability > Show Foreground Notification. Please try it and let me know if it helps in any ways.

Also let me know if you experience increased battery consumption by turning on foreground notification (compared to having it off). A little bit increase is expected, but too much increase will be an issue so I will try dialing down the frequency in that case.

I have also added another alarm permission. The docs said it is not needed on newer android versions so I had disabled it on new Android versions previously, but I have re-enabled it now, because why not. It might also help.

AhsanSarwar45 avatar Jun 29 '24 14:06 AhsanSarwar45

Not sure if this will fix issue on devices where alarm does not ring after screens time out. Let me know if thats the case.

AhsanSarwar45 avatar Jun 29 '24 14:06 AhsanSarwar45