You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Plugins android_alarm_manager] Invoking oneShot() from within a oneShot callback creates infinite threads #26813
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 time oneShot is called (and never released).
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 AndroidAlarmManager.oneShot from within the alarm handler, without calling initialize first, seems to correct the issue. I'm wondering however, if this is the expected way of re-enqueuing an alarm from within the handler or just a fluke that it happens to work?
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 flutter doctor -v and a minimal reproduction of the issue.
Activity
Kartik1607 commentedon Jan 20, 2019
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.
eligt commentedon Jan 21, 2019
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?
eligt commentedon Jan 21, 2019
It looks like just calling
AndroidAlarmManager.oneShotfrom within the alarm handler, without callinginitializefirst, seems to correct the issue. I'm wondering however, if this is the expected way of re-enqueuing an alarm from within the handler or just a fluke that it happens to work?stuartmorgan-g commentedon May 27, 2021
Closing as
android_alarm_manageris deprecated in favor ofandroid_alarm_manager_plus.302fbf4 Revert "Issues/80711 reland (flutter#26813)" (flutter-team-ar…
302fbf4 Revert "Issues/80711 reland (flutter#26813)" (flutter-team-ar…
302fbf4 Revert "Issues/80711 reland (flutter#26813)" (flutter-team-ar…
302fbf4 Revert "Issues/80711 reland (flutter#26813)" (flutter-team-ar…
302fbf4 Revert "Issues/80711 reland (flutter#26813)" (flutter-team-ar…
github-actions commentedon Aug 1, 2021
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
flutter doctor -vand a minimal reproduction of the issue.