-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
PM: Minor refactor to suspend/resume code flow #10426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Draft because lightly tested and heavily sleep deprived ;p. (I was supposed to test Android stuff tonight, not lose my mind >_<"). EDIT: Oh, and leftover debugging to be removed, too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 7 of 17 files at r1, 13 of 15 files at r2, 2 of 2 files at r3, 11 of 11 files at r4, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @NiLuJe)
API With the goal of deduplicating the slight madness involved here, and, most importantly, not calling them when we don't actually suspend or resume...
Makes more sense, ensures it deals with sleepcover events, too (lathough good luck tripping that ;p), and should dedupe a bunch of code.
And make sure we don't fire duplicate events (Might be tricky in practice, given that we're following system events, IIRC, and they should already be guarded properly).
And move things around so it's close to setEventHandlers
for us to be late, so, eh.
It effectively delays it until after the full refresh, and that's... a lot. Will have to see how the previous approach behaves on other, non awful devices. (Testing on an H2O right now)
Thankfully, newer, SMP devices can power through the resource contention. (i.e., on a Sage, it will smoothly ramp *during* the refresh. This is robably for a mix of reasons: because it's SMP, more powerful, and also because the display driver doesn't really give us great vsync fences, so we unblock earlier after the flashing refresh).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r5, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @NiLuJe)
Oohkay, me and my trusty fridge magnet haven't managed to break this on a few other devices, so this should be ready. A bit more churn than I would have initially hoped, but the gist of it is to move the emission of Suspend/Resume Events from the input handlers to the actual PM logic, so as not to send spurious events when the logic does something more complex than what the input could entail (this usually involves sleepcover interactions ;)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay, but it's quite large so the impact's a bit hard to gauge. If you think it's ready.
It shouldn't be any worse, yeah ;o). (Famous last words ^^). |
Fixes a regression introduced in #10426, when suspending during night and resuming during daylight.
* afterResume had *two* different implementations, so the historical one that handled frontlight fixups no longer ran (regression since koreader#10426) * isFrontlightOn was completely broken, for a couple of reasons: * There was no is isFrontlightOnHW implementation, so when it ran, it mostly always thought the frontlight was on, because self.fl_intensity doesn't change on toggle off. * _decideFrontlightState was never called on Kindle, so isFrontlightOnHW was never really called, making isFrontlightOn completely useless. Call it in setIntensityHW's coda, as it ought to be. And properly document that. Generic *was* calling _decideFrontlightState is setIntensity, but *before* actually setting the frontlight, which makes no goddamn sense, so get rid of that, too. * Also fix frontlight toggle notifications (regression since koreader#10305) TL;DR: The PowerD API being a mess strikes again.
* afterResume had *two* different implementations, so the historical one that handled frontlight fixups no longer ran (regression since #10426) * isFrontlightOn was completely broken, for a couple of reasons: * There was no is isFrontlightOnHW implementation, so when it ran, it mostly always thought the frontlight was on, because self.fl_intensity doesn't change on toggle off. * _decideFrontlightState was never called on Kindle, so isFrontlightOnHW was never really called, making isFrontlightOn completely useless. Call it in setIntensityHW's coda, as it ought to be. And properly document that. Generic *was* calling _decideFrontlightState is setIntensity, but *before* actually setting the frontlight, which makes no goddamn sense, so get rid of that, too. * Also fix frontlight toggle notifications (regression since #10305) TL;DR: The PowerD API being a mess strikes again.
If we get the events, it means stuff happened, we can't just only honor it in the most common workflows ;). This effectively reverts a tiny bit of koreader#10426 (I was sort of expecting this to be problematic at the time, and I most likely hadn't tested it).
If we get the events, it means stuff happened, we can't just only honor it in the most common workflows ;). This effectively reverts a tiny bit of koreader#10426 (I was sort of expecting this to be problematic at the time, and I most likely hadn't tested it).
If we get the events, it means stuff happened, we can't just only honor it in the most common workflows ;). This effectively reverts a tiny bit of koreader#10426 (I was sort of expecting this to be problematic at the time, and I most likely hadn't tested it).
If we get the events, it means stuff happened, we can't just only honor it in the most common workflows ;). This effectively reverts a tiny bit of koreader#10426 (I was sort of expecting this to be problematic at the time, and I most likely hadn't tested it).
Fix #11164 and involves a drive-by fix: Kindle: Send Suspend/Resume event regardless of the screen saver state If we get the events, it means stuff happened, we can't just only honor it in the most common workflows ;). This effectively reverts a tiny bit of #10426 (I was sort of expecting this to be problematic at the time, and I most likely hadn't tested it).
Make sure we only send Suspend/Resume events when we actually suspend/resume. This is done via the Device
_beforeSuspend
/_afterResume
methods, and those were called by the input handlers, not the PM logic; which means they would fire, while the PM logic could actually take a smarter decision and not do what the event just sent implied ;).(i.e., sleep with a cover -> suspend + actual suspend, OK; but if you then resume with a button -> input assumes resume, but PM will actually suspend again!).
Existing design issue made more apparent by #9448 ;).
Also fixes/generalizes a few corner-cases related to screen_saver_lock handling (e.g., don't allow USBMS during a lock).
And deal with the fallout of the main change to the Kobo frontlight ramp behavior ;).
This change is