Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wake-up timer not working #957

Closed
meyou69 opened this issue Apr 11, 2022 · 16 comments · Fixed by #1089
Closed

Wake-up timer not working #957

meyou69 opened this issue Apr 11, 2022 · 16 comments · Fixed by #1089
Labels
always-fresh Issues that will never become stale bug Something isn't working

Comments

@meyou69
Copy link

meyou69 commented Apr 11, 2022

Description

The wake-up timer seems to only work on my phone when the phone itself is unlocked and awake.
When I leave the phone locked and the screen black, the timer never goes off at the set hour. I'm not sure if the app gets optimized into the background to save battery life or what else could be going on but I simply can't use the app as an alarm clock.

To Reproduce

Steps to reproduce the behavior:

  1. Set a Wake-up timer to trigger in the next 3 minutes
  2. Schedule it
  3. Lock your phone screen and don't touch the phone anymore
  4. After 3 minutes or even more, you'll see that nothing happens. The Wake-up timer should have triggered in this time

Others

  • Device: Oneplus 5T running lineageos 18.1 (on latest update)
  • Android Version: 11
  • App Version: v1.3.3
@meyou69 meyou69 added the bug Something isn't working label Apr 11, 2022
@ashutoshgngwr
Copy link
Member

ashutoshgngwr commented Apr 11, 2022

You can try disabling the battery optimisation settings for Noice by navigating to Device Settings > Apps > Noice > Battery. The exact steps may vary for Lineage OS.

@meyou69
Copy link
Author

meyou69 commented Apr 11, 2022

I did as you suggested. Sadly, disabling battery optimizations did not solve my issue. The wake-up timer still doesn't wake the phone up to activate the alarm.
At lwast now we know it's not a battery optimization issue

@meyou69
Copy link
Author

meyou69 commented Apr 11, 2022

Another interesting tidbit I found out is that the wake-up timer only activates if the Noice app is in the foreground on the phone. You don't even need to lock the screen.
Just switch to an entirely different app before the timer goes off and it will never go off anymore

@ashutoshgngwr
Copy link
Member

ashutoshgngwr commented Apr 11, 2022

This issue comes around every now and then. Usually, turning off battery optimisation fixes the problem. The feature works as-is on most devices (and Android distributions) (including my own and the emulator). It essentially boils down to how a specific Android distribution handles background activity from an app, which is pretty much out of our control. Moreover, we use AlarmManager API from the Android Framework to set up alarms. Its whole point is to let an app schedule delayed callbacks. The platform guarantees that these callbacks will be delivered when the time comes, even if the app is not active.

@meyou69
Copy link
Author

meyou69 commented Apr 11, 2022

Well, I'm out of ideas then. I uninstalled the app from F-Droid, reinstalled it from Google play, and I still get the same issue.
I also cleared out its local storage and cache and again, the problem still persists.
This could very well be a lineageos problem although the regular Clock app does work so I'm assuming the AlarmManager API is doing its job.
If you believe that there's nothing you can do about this issue, should l cap se this ticket?

@meyou69
Copy link
Author

meyou69 commented Apr 11, 2022

*should I close this issue

@ashutoshgngwr ashutoshgngwr added the always-fresh Issues that will never become stale label Apr 11, 2022
@ashutoshgngwr
Copy link
Member

No no. Let's keep this open. I want to know where it works and where it doesn't. There can be any reason why it isn't working as expected. To quote a StackOverflow answer:

I'm trying to solve it several weeks already. I found nothing. Huawei just kill all the alarms after some time. If I put the app to the protected app in their battery saver it does't help. But If I change package name of my app to contain words like alarm, clock or calendar, it works absolutely normal like on any other devices. I don't understand how Google can give certification for this crap. I think that OEM should not modify core platform in such way. I understand that they have own batter saver which kill the app after some time, when user don't use it. But this killing alarms also of protected apps.

I am reasonably confident that it isn't a bug in Noice because the same code works on other devices. So as long as the alarm indicator gets triggered in the notification bar on scheduling an alarm, there's nothing more we could do to mitigate this issue.

@meyou69
Copy link
Author

meyou69 commented Apr 11, 2022

"as long as the alarm indicator gets triggered in the notification bar" I am unsure what you mean by this.
The only thing that appears after I schedule an alarm is the clock icon on my lock screenthat indicates that an alarm is set along with the exact time for when the alarm is set to go off. The time that appears on the lock screen does indeed coincide with the time for the wake up timer I set in noice.
But as soon as the minute for when the alarm is supposed to go off in arrives, that icon disappears from the lock screen mysteriously, as if the alarm had gone off and was dismissed.

@ashutoshgngwr
Copy link
Member

ashutoshgngwr commented Apr 11, 2022

The only thing that appears after I schedule an alarm is the clock icon on my lock screenthat indicates that an alarm is set along with the exact time for when the alarm is set to go off.

The indicator is exactly what I meant. It implies that Noice correctly schedules the alarm with the system. After this step, it's up to the system to fire it when the time comes.

Would it be possible for you to monitor device logs at the time when the alarm is supposed to go off? I want to completely eliminate the possibility of a bug here.

@meyou69
Copy link
Author

meyou69 commented Apr 11, 2022

I would love to help but I'm unsure how to access such logs. Do I need to use adb to shell into my phone? Or where can I find such logs?

@ashutoshgngwr
Copy link
Member

ashutoshgngwr commented Apr 11, 2022

Did you provide data collection consent? If so, then I am not seeing any crash logs in Firebase Console so we're good.

Otherwise, to collect logs, you need to install adb on a computer. You also need to enable developer options on your device. Then connect your device to the computer, and schedule the alarm. A few seconds before the alarm goes off, you can run the following from a terminal/console on your computer.

adb logcat -c
adb logcat > logcat.txt

A few seconds after the scheduled time, press Ctrl + C. Now, you should have a logcat.txt file in your current directory. Upload its content, or the file itself here. If you're concerned about unintended data exposure, you could email it to me @ trynoiceapp@gmail.com


To avoid all the hassle, you can just turn on data collection in Noice and reproduce this issue a few times. If it's indeed a crash, I'll automatically get the logs Firebase Crashlytics.

@meyou69
Copy link
Author

meyou69 commented Apr 11, 2022

logcat.txt
I hope this helps. I did indeed curate some details from the log which contained sensitive information about me. You can read the log now

@ashutoshgngwr
Copy link
Member

Thank you for taking the time to collect and upload the logs. It appears that the alarm is fired precisely so it is a problem with Noice. It appears to be a silent error (i.e. doesn't cause a crash) and is indeed documented. I am not sure why it works flawlessly on my device and emulators. I will create a fix for it once I am done with v2 implementation, or if I find some time in the middle.

@meyou69
Copy link
Author

meyou69 commented Apr 11, 2022

Thank you for your time. If you need any more details about my device or setup, please feel free to just ask away

@sevmonster
Copy link

sevmonster commented Oct 2, 2022

This is also an issue on GrapheneOS (Android 13). Since this is my sole reason for using Noice the app is pretty useless to me.

@ashutoshgngwr
Copy link
Member

@sevmonster AFAIK, it only happens on devices running Android higher than 11. It is why I haven't had a lot of complaints regarding this. As of now, I am busy with the Chromecast implementation. I'll try to resolve it as soon as I finish that. I'd estimate it within two weeks, but it might be longer. Please subscribe to this issue to receive updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
always-fresh Issues that will never become stale bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants