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

App crashes Android TV on system startup if the scheduled shutdown has been skipped #30

Open
30cent-man opened this issue Jan 11, 2025 · 5 comments

Comments

@30cent-man
Copy link

Hi,

First of all, huge thanks for an extremely useful app which I have utilized on my Raspberry Pi-Android TV setup.

I've scheduled the app to shutdown the device every night at 9 PM (because children often forget/don't know how to manually shutdown Raspberry Pi through the menus or settings of Android TV itself). However, if the device is turned off before the scheduled shutdown (or not used at all during that day), the next time the system is booted Android TV will crash totally and the only option to proceed is to unplug the power cable or long press the physical power button of Raspberry Pi 5 after which the startup is normal.

This is currently the only "real" issue which I have faced. Unfortunately it is also the only reason why I can't use the app currently, because the kids are not able to use the device the next time it is turned on unless I'm there helping them to restart it.

@maforn
Copy link
Owner

maforn commented Jan 20, 2025

Hello, this is quite strange. Frankly speaking this does not look like a "my app" problem but more like a "Android TV OS" problem. If it's not my app that it's crashing I can't do much about it, it's probably some weird function that is implemented normally on the Android OS but in a strange way in the Android TV OS. Do you have any more info?

@30cent-man
Copy link
Author

30cent-man commented Jan 28, 2025

Yeah it is quite strange. Unfortunately I haven't had time to test and debug the system/app recently. Do you have any idea how to gather, for example, system logs to provide more detailed information for you?

Based on my usage, this issue could have something to do with "wrong time" during the Android TV startup. What I mean is that when Android TV is turned on, the clock first shows wrong time and then after maybe 10 seconds returns to correct time. Now if the scheduled shutdown has been passed/skipped due to initial (wrong) system time, it would trigger the shutdown and the crash occurs because the system time changes suddenly? There appears an app notification "Shutting down in XX milliseconds" and that's when the whole system crashes.

I think I could at least try to increase the initial general delay time more to see if that has an effect (I've already set it to 10 000 milliseconds).

@30cent-man
Copy link
Author

I managed to play with the device last night after my previous post so here's some additional information:

First, I noticed that the app does not allow to increase the initial general delay over 10 000 milliseconds. I can enter greater values (I tried 20 000 & 50 000 ms) but it won't keep it regardless of saving the config, whereas 2 000 ms delay time was saved correctly based on my testings.

Secondly, I mentioned that the "Shutting down in XX milliseconds" notifcation pops up on screen before/during crashing. Actually that notification pops up repeatedly maybe five times until the crash occurs.

Could it be that the shutdown happens anyway once the signal (i.e. system time matches the scheduled time) is triggered and thus it cannot be aborted even if the system time is corrected during the initial general delay? So could it be possible to somehow abort the shutdown if the system time changes during the delay time?

Another suggestion could be to allow to setting a second timer, starting at the timed shutdown, to check whether the system time has changed and abort the shutdown if necessary.

@maforn
Copy link
Owner

maforn commented Jan 30, 2025

First, I noticed that the app does not allow to increase the initial general delay over 10 000 milliseconds. I can enter greater values (I tried 20 000 & 50 000 ms) but it won't keep it regardless of saving the config, whereas 2 000 ms delay time was saved correctly based on my testings.

Yes, this is intentional, in the code I clipped the values of the delay between 50 and 10000, I did this because I thought it could create problems with battery optimization but I could raise the upper limit if you think it's useful.

Could it be that the shutdown happens anyway once the signal (i.e. system time matches the scheduled time) is triggered and thus it cannot be aborted even if the system time is corrected during the initial general delay?

That's probably it. In the app, if I see that I set an alarm and the system says the time it should go off has already passed it will probably fire it. This error does not make any sense, why would an operating system boot with a wrong clock and then change it? I'll consider how to fix it, but it sounds like a really stupid and specific bug to fix. I mean, the TV OS is engineered badly if it has this kind of problems.

@30cent-man
Copy link
Author

30cent-man commented Jan 31, 2025

Yes, this is intentional, in the code I clipped the values of the delay between 50 and 10000, I did this because I thought it could create problems with battery optimization but I could raise the upper limit if you think it's useful.

I don't think there is a need to have an upper limit at all. However, in neither case it would have an effect on the original issue as the shutdown process has already been initiated.

That's probably it. In the app, if I see that I set an alarm and the system says the time it should go off has already passed it will probably fire it. This error does not make any sense, why would an operating system boot with a wrong clock and then change it? I'll consider how to fix it, but it sounds like a really stupid and specific bug to fix. I mean, the TV OS is engineered badly if it has this kind of problems.

Well, the wrong time issue might be caused by the fact that we usually completely shutdown the Raspberry Pi 5 from the power outlet (after it has been first turned off via Android's power menu). Thus, I think maybe the device loses the real time and after a cold boot it takes a moment to adjust it. I noticed this when after a crash I plugged off the power cable, booted back to Android and the crash occured again. Instead, when I turned off the device by holding the power button of RPi5 (power LED was red) and then booted, it worked normally.

I totally agree that the TV version is in many respects lagging behind or worse implemented than regular Android. I still think this is more Raspberry Pi (and other devices which are completely shutdown, versus Android phones) than Android TV related issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants