Schedule next standby on AutoStandby plugin init#12815
Conversation
|
InkView doesn't care about whatever we're doing (i.e., if we allow standby [more accurately on PB, if we do not prevent standby], it should be aggressively trying to standby regardless of what we're doing), so I'm mildly surprised this works. |
|
Hi, @sebastien-maillard! Welcome to lua. It is a very easy and fun language. Quite powerful too! Please move your Please consider a simpler name like Then please try again with self references. If you find other issues then please keep the PR updated with your reports :) |
|
Thanks both for the feedback!
I'm assuming you're referring to my point about not preventing standby during the view transition. According to my tests, when I completely disable the This is actually how I use my device now (
Thanks for the tip and dully noted!
To be clear, the code I submitted does work as of right now, i.e. both
I followed your instructions, i.e.:
However, I still run into the same issue as before, i.e. This happens on the following line: Basically, all the methods that could successfully be called on I have to say I'm still quite confused with the usage of Please note I added a commit for the first two points in this PR. But I pushed the commit for the third point (regarding |
|
Keep in mind Also, the AutoStandby plugin is a special snowflake in that it explicitly only calls class methods (and potentially only as functions to make it clear) & attributes, IIRC, so the |
That's potentially a separate issue, in that I would assume disabling AutoStandby leaves the system in a state that forcibly prevents standby, which isn't what's currently happening. |
Co-authored-by: Benoit Pierre <benoit.pierre@gmail.com>
…`AutoStandby:onInputEvent()`
I wasn't aware of that, thanks for pointing it out!
100%
Dully noted!
By disabling Thanks to this suggestion, I was able to solve both:
See latest commits for reference. As a side note, I'm still able to call |
|
Please use Does that fixes the issue? |
|
Note that self: whatever() is short for self.whatever(self, etc) |
Yes, it's solved following this suggestion! |
Nah. You can ignore my first message alltogether. I was thinking about circular dependencies on function calls or something like that. But I'm struggling figuring out why the |
My bad, I didn't thought of changing this call too. It does work indeed! |
|
Indeed that looks much better. Sorry about the false hints :p |
pazos
left a comment
There was a problem hiding this comment.
Does _scheduleNext needs some kind of guard?
ie: when the autostandby is disabled we shouldn't schedule standby at all.
Are you referring to the case where standby is forbidden (i.e. Or to the case where the plugin is disabled? In which case you seem to have the same opinion as expressed here. But that would be a separate issue I guess. To be noted that the current situation allows both forbidding standby and allowing systematic standby, as I highlighted in the wiki. If disabling the plugin would have the same effect as forbidding standby, the option to allow standby without any delay should probably be implemented. |
|
Sorry for the delay!
Yup, exactly that. Thank you! |
Yup. I assumed that too. IMHO it doesn't matter. Now we have A+ tier documentation in https://github.com/koreader/koreader/wiki/Auto-Standby It should be a matter of link that in the user guide in troubleshooting. It aplies to pocketbook users. Many users won't be affected but those who rely on timers will (ie: autoscroll/page or notification/message timeouts). Those users will want to read the awesome wiki documentation and figure out a setting that work for them. |
NiLuJe
left a comment
There was a problem hiding this comment.
Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @benoit-pierre)
This PR attempts to fix #12814.
Following this suggestion and that one, I tested the fix vs. standard plugin settings and the plugin appears to work as expected, even with a never-opened-before complex EPUB. To be clear, this is not an attempt to fix the other issues reported for this plugin, c.f. #9493.
Current approach
Based off of this suggestion, schedule the next standby when the plugin is initialized, either:
Since calling
AutoStandby:onInputEvent()oninitwould actually likely result in filtering out the call (because the view transition happens right after pressing the screen), I isolated this section in a separate function which is now also called inAutoStandby:init().Undesirable side-effect of the current approach
Since the standby previously scheduled has just been unscheduled by
AutoStandby:onCloseWidget()and another one is scheduled pretty much right away byAutoStandby:init(), this results in increasing the standby delay because of the multiplier effect.Important note regarding the current approach
The approach is to schedule the next standby on
initbecause it has been unscheduled inAutoStandby:onCloseWidget(). It seems the original purpose of unscheduling the standby is to "prevent standby during a view transition". However, with the proposed fix, when opening a never-opened-before complex EPUB and/or in case the plugin is set to its aggressive mode (e.g. battery below the Always standby if battery below threshold),AutoStandby:allow()will actually be invoked oninit, i.e. during the transition.I've tested this use-case (e.g. set Always standby if battery below to
100and open/close a book) with the patch. And it works fine, i.e. the device instantly goes into standby but only after the view transition is fully over.As far as I understand, it's because the role of the plugin is not to put the device into standby, it's actually to prevent the device from going into standby. Indeed, when
forbidden == false(i.e. Allow auto-standby is unchecked), the device always goes into standby instantly after every event. But only after everything this event has triggered has been fully executed.If I understand correctly, the plugin has been created precisely to prevent the device from going into standby right away, so that some automatic events scheduled in the future (such as auto page turning, frontlight dim, etc.) will be able to be triggered before the device goes into standby.
If the above is correct, a better approach would probably be to simply not unschedule the next standby in
AutoStandby:onCloseWidget()anymore, since there's no risk for the device to go into standby during the view transition. This would have the benefit to avoid the undesirable side-effect mentioned in the previous section.However, to fix the other bug mentioned in #12814 (device goes into standby instantly when KOReader starts), it would still be necessary to invoke
AutoStandby:scheduleNextStandby()oninit. But only if the plugin is initialized for the first time, e.g. probably inside this block.I'd be quite interested to further discuss this point.
Disclaimer
Not only this is my first experience with KOReader, its code-base and the PocketBook InkPad platform, this is also my first experience with Lua. I struggled quite a bit with variable visibility and function arguments and I'd really appreciate some extra guidance. In particular:
AutoStandby:scheduleNextStandby(t, config)AutoStandby:onInputEvent()andconfigis also already available inAutoStandby:init(), so I only would've needed to addos.time()in that caseselfin the code I extracted fromAutoStandby:onInputEvent()selfcouldn't be recognized whenAutoStandby:scheduleNextStandby()was invoked fromAutoStandby:onInputEvent()(e.g.attempt to index local 'self' (a nil value)), event though it would be fine when invoked fromAutoStandby:init()selfwas actually recognized inAutoStandby:onInputEvent()CC:
This change is