Repository navigation
Cancelled streaming requests leave waiting animation running, preventing Kobo suspend and draining battery #215
Closed
fernandeslouro
started this conversation in
Bug Reports
Replies: 1 comment
|
Thanks for the detailed report and the tested patch. The fix is merged as |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Cancelling an Assistant streaming request before response text arrives leaves the waiting animation running after the dialog closes. On my Kobo Clara B&W, this prevents actual suspend and drains the battery while the sleep image remains visible. A small local patch fixes the reproduced failure.
Hardware and software
Kobo_spaBW.MediaTek MT8110 TPV board.mediatek,mt8110,mediatek,mt8512.821e4df-20250506T120645-B0506121817.Confirmed plugin defect
UIManager:scheduleIn()returns nil.showStremDialog()stores that return value inanimation_task, then only callsunschedule()when that variable is truthy. The waiting animation therefore cannot be cancelled through that code.If a streaming dialog closes before receiving content,
first_content_receivedstays false andupdateAnimation()keeps re-enqueuing itself every 0.4 seconds. Cleanup is also missing afterprocessStream()returns an error, empty response or tool call, or raises an exception.StreamText:initTextBox()callsUIManager:setDirty()with a refresh callback. KOReader queues and executes these callbacks even when the associated widget is absent from the window stack, so the orphan animation can keep requesting display refreshes.Observed battery-drain incident
The device last successfully returned from suspend at 2026-10-11 11:56:52 UTC. At 12:01:05 the log records
User interrupted the stream processing. At 12:01:15 Wi-Fi was disabled; the suspend attempt at 12:01:31 failed:All subsequent recorded suspend attempts failed through 2026-10-12 00:53:02. The device was rebooted by the time it was inspected at 21:54 UTC, so the kernel diagnostics from the failing boot are unavailable. The battery was 8% and charging at inspection. Auto-suspend is 900 seconds; auto-shutdown is 259200 seconds (three days). KOReader stops retrying after 20 failures and waits for shutdown, allowing substantial drain while a sleep screen remains visible.
The unplugged hardware reproduction also triggered the suspend failure. After interrupted requests at 2026-10-12 22:06:15 and 22:06:24 UTC, all six suspend attempts failed. Kernel suspend statistics identify
14000000.hwtcon, errno-1, stepsuspend. The saved kernel log reports:This matches the display-refresh explanation and the HWTCON failure discussed in koreader/koreader#12787. After installing the patch and restarting KOReader (without rebooting the device), the user repeated the interrupted-stream steps: interruption at 22:10:44 UTC, successful suspend at 22:11:20, and resume at 22:12:49. The kernel reports 89.121 seconds suspended; counters changed from success 1 / fail 6 to success 2 / fail 6, with no new failures. This provides a successful before-and-after hardware reproduction.
Reproduction and proposed fix
Start a streaming request and close it before the first response text. Confirm that no waiting-animation callback remains queued after close. Also exercise an API error, empty response, thrown exception, and tool-only response before text.
The patch keeps the scheduled function reference rather than the return value of
scheduleIn(), cancels it before interrupting the stream, and cancels it when stream processing returns on every exit path.Validation
Querier:showStremDialog()method. Original code fails all five cleanup scenarios; patched code passes all five.git diff --checkpasses.test_markdown_css.assistant_querier.lua.before-suspend-fix.Tested patch
Automation disclosure
The investigation, patch preparation, and report were automated with Codex using GPT-6.1 Sol. I performed the physical cancellation, restart, and sleep tests on the Kobo. This report includes a tested patch; no pull request has been opened yet.
All reactions