Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Oh, wait, that's the whole point ;p. (I was mixing clock sources in my head, never mind me ;p). |
|
It appears GitHub ate my first comment (or I'm so tired that I messed up ;p), so: Just as a heads up, I won't be able to properly review/test this until next week ;). |
Absolutely no problem, as this is draft. I will have to figure out the open tasks and test it myself. You don't need to test it yourself until it is "ready for review". But I would appreciate anything jumping out :) |
|
@NiLuJe Rebased and ready from my side. But no hurry. |
|
After rebaseing I got some strange behaviour. So draft now until I can explain or fix. |
|
Update: I had plugged the device onto a different power source as usual (I knew, that the device sometimes gets crazy after using that charger), but forgot about that (but I am sure it was this way, now). So from my side no changes. |
|
I've had the PowerCover break suspend in fun and interesting ways until a reboot, yeah... |
|
Ready from my side. |
Frenzie
left a comment
There was a problem hiding this comment.
lgtm, but I haven't tested it yet
|
I've slacked off a bit, and only juuust started reinstalling my linux env, so I still haven't tried this either. Hopefully this weekend ;). |
|
@NiLuJe Maybe off-topic here, but I don't want to open an additional issue for this. I am sure I saw this behavior before, and it can be provoked in the Terminal emulator (which has not been touched with this PR). When playing with my Sage sometimes I get strange screen refreshes during reading. The refreshes look like that the screen is split into 4 parts, which are refreshed clockwise starting from the bottom left. Very fast, hard to follow. I can provoke these refreshes in the Terminal emulator when entering: The refresh will always happen, when I get a Interestingly I found this strange refreshes during read, and I have also notices that the device sometimes does not enter standby. But after seeing this, I looked closely to the fact, that the device does not enter standby.
So I guess there might be a race hazard. I have tried to add a Do you have any ideas about the root of the problem? |
That's a kernel issue. It appeared with the first kernel update that touched the collision handling code (can't remember the FW version), and subsequent tweaks haven't really managed to entirely squash it. It's specific to the Sage; the Elipsa has a different collision handling code (also broken, but slightly less user-visibly so). |
|
FWIW, I hadn't traced it to PM at all, as the main spot I was seeing it was actually inside Nickel (and I wasn't the only one ^^); I've only very rarely seen in KOReader. Then again, if I think about it, I think I added a slight delay to the screensaver display on sunxi because I was tripping another collision handling bug there (I don't think it was this exact one, though, but I can't quite remember), so it makes sense. |
|
As for the Notification thing, that's interesting, but I'd be inclined to leave it alone: it's perfectly normal for PM to fail if it happens too soon after a screen update. We handle that gracefully by waiting for the timeout again, and since it's likely to be in the one digit range of seconds, it feels like a non-issue to me ;). |
|
(Still have'nt had time to test this; I'm hoping to deal with it tomorrow, but we'll probably merge this tomorrow regardless, as it looks perfectly sensible to me ;)). |
The NO_MERGE flag might help (because it bypasses said broken collision handling codepath), but we're probably already using it for Notifications because of my last attempt at dealing with the Libra 2 crashes? (Can't check right now, though). |
|
I think I have solved that issue (minimal invasive) by adding and test for Anyway I want to test this solution and optimize the time distance (the |
|
Fair warning: I'll probably veto something like that, FWIW ;). |
NiLuJe
left a comment
There was a problem hiding this comment.
A few wording issues with some comments, but code looks good ;).
Speaking of comments, some stuff around self.going_to_suspend usage may also need to be reviewed (at least one of those instances mentions onLeaveStandby, which doesn't exist anymore).
Reviewed 2 of 4 files at r1, 4 of 5 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @zwim)
frontend/ui/uimanager.lua line 249 at r3 (raw file):
-- UIManager uses CLOCK_MONOTONIC (which doesn't tick during standby), so shifting the execution -- time by a negative value will lead to an execution at the expected time. -- @param time if positive execute the tasks later, if negative the should be executed earlier
nit: still a minor wording snafu left near the end there ;).
plugins/autosuspend.koplugin/main.lua line 644 at r3 (raw file):
UIManager:consumeInputEarlyAfterPM(true) -- If we are leaving this method we are sure, that the input polling deadline is zero (consumeInputEarly). -- Then the input waiting is executed, so it is save to schedule a new task.
Second sentence is a tad clunky, making it hard to grok. (So's the comma placement in the first one, but that's less problematic).
plugins/autosuspend.koplugin/main.lua line 650 at r3 (raw file):
end else -- If we are leaving this method we are sure, that the input polling deadline fits the next scheduled task (deadline).
Comment slightly unclear. That's simply input deadline >= next task, right?
NiLuJe
left a comment
There was a problem hiding this comment.
One final nit ;).
Reviewed 2 of 2 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @zwim)
plugins/autosuspend.koplugin/main.lua line 644 at r4 (raw file):
-- When we exit this method, we are sure that the input polling deadline is zero (consumeInputEarly). -- UIManagerger will check newly scheduled tasks before going to input polling again (with a new deadline).
nit: UIManager ;o).
To expand a bit on that, I'm happy with the current behavior (i.e., that PM fails too soon after a screen update is perfectly normal, we should handle that properly (and we do)), so attempting to deal with this corner-case seems like gratuitous complexity at first glance. On the other hand, if that happens to, as a byproduct, workaround a sunxi display driver issue, that's another kettle of fish, and I might be more lenient with this ;). |
NiLuJe
left a comment
There was a problem hiding this comment.
Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @zwim)
KOReader 2023.04 "Solar Panel"  It's been another busy month squashing many bugs. Our Mac users will be happy to hear that I told macOS we've supported HiDPI since long before anyone came up with such terminology (koreader#10341), and that the program can now natively build on M1 devices (koreader#10291). Solar panel credit: <https://openclipart.org/detail/294030/solar-energy> by gnokii We'd like to thank all contributors for their efforts. Some highlights since the previous release include: * Readerzooming: fix use of default settings (koreader#10205) @hius07 * ButtonDialog/ButtonDialogTitle: consistent 'width' handling (koreader#10230) @poire-z * MovableContainer: add support for anchoring initial position (koreader#10230) @poire-z * Book map, Page browser: add top left menu (koreader#10230) @poire-z * Book style tweak: add button with CSS suggestions (koreader#10230) @poire-z * crengine: fix parsing of multibytes encodings (koreader#10230) @poire-z * readerstyletweak: update profiles on unregistering in dispatcher (koreader#10247) @hius07 * Filesearcher: add search in book metadata (koreader#10198) @hius07 * Fix: Updated legacy directory, which crashed the program (koreader#10260) @Mochitto * ReaderLink: allow a forward location stack (koreader#10228) @yparitcher * BookInfo: add page information (koreader#10255) @hius07 * Center pdf manual zoom mode (koreader#10246) @nairyosangha * File browser: add Folder Menu (koreader#10275) @hius07 * Calendar view: add options to change start time of days (koreader#10254) @weijiuqiao * filechooser: fix crash on "unreadable content" (koreader#10283) @hius07 * Sync book statistics: add to dispatcher (koreader#10285) @ptrm * [plugin] Exporter: use util.getSafeFilename() to remove illegal characters from output filename (koreader#10282) @Mochitto * readerbookmark: fix writing pdf annotation (koreader#10287) @hius07 * Folder Menu: sign for Home folder (koreader#10288) @hius07 * ListMenu: show mark for books with highlights (koreader#10276) @hius07 * Calendar view's day view: thicker separator at 00:00 (koreader#10289) @poire-z * PageBrowser: tweak scrolling behaviour at book start/end (koreader#10289) @poire-z * Make `kodev check` feature complete (koreader#8682) @yparitcher * macOS: support for M1 building (koreader#10291) @ptrm * Reader: do not apply font size and spacing out of range (koreader#10295, koreader#10307) @hius07 * File browser: show Folder Menu on long-press on Home icon (koreader#10298) @hius07 * SSH.koplugin: fix cant stop SSH server bug when pid file's stale (koreader#10300) @weijiuqiao * PM: Optimize task queue handling around standby (koreader#10203) @zwim * statistic.koplugin: fix today's timeline showing next day when within custom offset (koreader#10299) @weijiuqiao * ReaderThumbnails: update cached page thumbnail on bookmark note change (koreader#10303) @hius07 * SDL: add multitouch support (koreader#10334) @Frenzie * SDL: add HiDPI support (koreader#10341) @Frenzie * BookInfo: fix crash on show cover (koreader#10315) @hius07 * Deal with table.pack corner-cases properly (koreader#10350) @NiLuJe * Android: add Tagus Gea support (<koreader/android-luajit-launcher#412>) @Alfedi [Full changelog](koreader/koreader@v2023.03...v2023.04) — [closed milestone issues](https://github.com/koreader/koreader/milestone/63?closed=1) --- Installation instructions: [Android](https://github.com/koreader/koreader/wiki/Installation-on-Android-devices) • [Cervantes](https://github.com/koreader/koreader/wiki/Installation-on-BQ-devices) • [ChromeOS](https://github.com/koreader/koreader/wiki/Installation-on-Chromebook-devices) • [Kindle](https://github.com/koreader/koreader/wiki/Installation-on-Kindle-devices) • [Kobo](https://github.com/koreader/koreader/wiki/Installation-on-Kobo-devices) • [PocketBook](https://github.com/koreader/koreader/wiki/Installation-on-PocketBook-devices) • [ReMarkable](https://github.com/koreader/koreader/wiki/Installation-on-ReMarkable) • [Desktop Linux](https://github.com/koreader/koreader/wiki/Installation-on-desktop-linux) • [MacOS](https://github.com/koreader/koreader/wiki/Installation-on-MacOS)
Instead of firing on(Enter|Leave)Standby Events, and having every other piece of code that might care about that handle re-scheduling their stuff themselves; simply make the standby implementation (i.e., AutoSuspend's) shift the whole task queue by the amount of time spent in standby to re-sync everything automatically. (This is necessary in the first place because Linux, as the task queue ticks in CLOCK_MONOTONIC, which does *not* tick during suspend/standby; while we expect most of the tasks scheduled to actually reflect real world clock delays).
Here I want to optimize the standby behavior, by minimizing the usage of the
onEnterStandbyandonLeaveStandbyhandlers.The goal is to eliminate most of that handlers and optimize (speed) up the rest.
This can be achieved by just shifting the execution time of scheduled tasks by
- Device.last_standby_time(notice the sign, which means they should be executed earlier.)So it is not necessary to unschedule related tasks in
onEnterStandbyand reschedule them inonLeaveStandby.The savings in the unschedule part might be smaller than the savings in the rescheduling part. (We will save a table delete and a binary insert in every case.)
As I won't eliminate the
onXXXStandbyevents, everything will work as usual. The only difference is, that scheduled tasks will get executedlast_standby_timeearlier, as the clock has not ticked for exactly thatlast_standby_time(this is what we want, anyway).This initial commit is just a POC with changes in the
autosuspend-plugin together with header and footer (and a private userpatch). Seems to work so far.autosuspend-pluginUIManagerreaderfooterreadercoptlistenerautowarmth-pluginautoturn-pluginautodim-pluginAs always: Throw thoughts on my brain until it gets muddy or find logical errors. ;-)
This change is