AutoSuspend: Don't send LeaveStandby events from a zombie plugin instance (#9124)

Long story short: the LeaveStandby event is sent via `tickAfterNext`, so if we tear down the plugin right after calling it (in this case, that means that the very input event that wakes the device up from suspend is one that kills ReaderUI or FileManager), what's in UIManager's task queue isn't the actual function, but the anonymous nextTick wrapper constructed by `tickAfterNext` (c.f., 
https://github.com/koreader/koreader/issues/9112#issuecomment-1133999385).

Tweak `UIManager:tickAfterNext` to return a reference to said wrapper, so that we can store it and unschedule that one, too, in `AutoSuspend:onCloseWidget`.

Fix #9112 (many thanks to [@boredhominid](https://github.com/boredhominid) for his help in finding a repro for this ;)).
Re: #8638, as the extra debugging facilities (i.e., ebb81b9845) added during testing might help pinpoint the root issue for that one, too.

Also includes a minor simplification to `UIManager:_checkTasks`, and various other task queue related codepaths (e.g., `WakeupMgr`) ;).
This commit is contained in:
NiLuJe
2022-05-25 23:36:41 +02:00
committed by GitHub
parent 46f09b9e6c
commit ae5b2d68ca
6 changed files with 50 additions and 29 deletions

View File

@@ -996,7 +996,7 @@ function ReaderDictionary:showDict(word, results, boxes, link)
if not results.lookup_cancelled and self._lookup_start_time
and (time.now() - self._lookup_start_time) > self.quick_dismiss_before_delay then
-- If the search took more than a few seconds to be done, discard
-- queued and coming up input events to avoid a voluntary dismissal
-- queued and upcoming input events to avoid a voluntary dismissal
-- (because the user felt the result would not come) to kill the
-- result that finally came and is about to be displayed
Input:inhibitInputUntil(true)