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
[Plugins android_alarm_manager] Invoking oneShot() from within a oneShot callback creates infinite threads #26813
Comments
void alarmServiceHandler() {
...
AndroidAlarmManager.initialize().then((bool ready) {
...
AndroidAlarmManager.oneShot(const Duration(seconds: 1), alarmID, alarmServiceHandler, exact: true);
}
....
} The handler is re-initializing AlarmManager, which in turn again calls up the handler after duration of 1 second. This seems to be a case of recursion. |
It's not recursion in that the alarm is re-enqueued once the old alarm handler has finished, so my expectation would be for the old thread to be released and a new one to be created for the new alarm - I'm not saying this should occur instantly but at some point the old threads should be released. Instead what I'm noticing is that new threads keep being created and the old ones are never released. Unless you're saying that the initialize() call holds the thread in some kind of loop? In that case, what's the best way to invoke an alarm handler from inside another alarm handler? |
It looks like just calling |
Closing as |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
The following code will end up creating an ever-increasing amount of threads:
After execution of the function and new
oneShot
alarm is registered, I'd expect the thread to finish and get freed but that doesn't seem to happen. Note that the Isolate hash stays the same, but a new thread is created each timeoneShot
is called (and never released).The text was updated successfully, but these errors were encountered: