Closed freakboy3742 closed 2 years ago
I can also reproduce this with the Toga handlers example, which calls add_background_task on startup.
This was a bug in android_events.py. Every time call_soon is called, it adds a Runnable to the Android event queue, which repeatedly re-enqueues itself when it runs. However, call_soon is also called internally by the event loop base class as part of processing the coroutine. So this caused each iteration of the couroutine to accumulate one additional Runnable. The actual coroutine was still only executed once: all the other Runnables would find that no tasks were due.
Fixed in the Chaquopy template PR by making the event loop cancel its existing Runnable (if any) before queuing a new one.
Fixed by beeware/rubicon-java#76
Reported via #1538.
When a background worker (possibly any async handler?) is invoked, it doesn't appear to be fully cleaned up; as a result, a proliferation of no-op handler operations are performed. This can be observed in the logs as a steady increase in the number of "Native Invocation: run/Native Invocation: done" messages; over time, it leads to degradation in the performance of the app.
To Reproduce Steps to reproduce the behavior:
def startup(self): self.add_background_task(self.update_gui)