AutoSuspend: Handle a few corner-cases better (#10797)

* Enforce a minimal standby timer for the first standby after a resume.
* On Kobo, sleep a bit before standby.

This aims to alleviate race conditions causing visible refresh glitches on sunxi, especially when using an extremely low standby timer (i.e., below the defaults).
This commit is contained in:
zwim
2023-09-01 17:55:24 +02:00
committed by GitHub
parent ed2ea6803f
commit bedd422669
2 changed files with 15 additions and 4 deletions

View File

@@ -1181,6 +1181,12 @@ function Kobo:standby(max_duration)
logger.dbg("Kobo standby: asking to enter standby . . .")
local standby_time = time.boottime_or_realtime_coarse()
-- The odd Sunxi needs some time to settle before entering standby.
-- This will avoid the screen puzzling effect documented in
-- https://github.com/koreader/koreader/pull/10306#issue-1659242042 not only for
-- WiFi toggle, but (almost) everywhere.
ffiUtil.usleep(90000) -- sleep 0.09s (0.08s would also work)
local ret = ffiUtil.writeToSysfs("standby", "/sys/power/state")
self.last_standby_time = time.boottime_or_realtime_coarse() - standby_time

View File

@@ -20,6 +20,7 @@ local T = require("ffi/util").template
local default_autoshutdown_timeout_seconds = 3*24*60*60 -- three days
local default_auto_suspend_timeout_seconds = 15*60 -- 15 minutes
local default_auto_standby_timeout_seconds = 4 -- 4 seconds; should be safe on Kobo/Sage
local default_standby_timeout_after_resume_seconds = 4 -- 4 seconds; should be safe on Kobo/Sage, not customizable
local default_kindle_t1_timeout_reset_seconds = 5*60 -- 5 minutes (i.e., half of the standard t1 timeout).
local AutoSuspend = WidgetContainer:extend{
@@ -366,7 +367,11 @@ function AutoSuspend:onResume()
self:_start()
self:_start_kindle()
self:_unschedule_standby()
self:_start_standby()
-- Use a default value for first scheduled standby after a suspend here.
-- This avoids screen glitches after a full suspend
-- and avoids broken refreshes after aborted suspend (when standby_time is 1s).
-- (And we like 1s for power saving reasons!)
self:_start_standby(default_standby_timeout_after_resume_seconds)
end
function AutoSuspend:onUnexpectedWakeupLimit()
@@ -590,7 +595,7 @@ Upon user input, the device needs a certain amount of time to wake up. Generally
self:pickTimeoutValue(touchmenu_instance,
_("Timeout for autostandby"), _("Enter time in minutes and seconds."),
"auto_standby_timeout_seconds", default_auto_standby_timeout_seconds,
{3, 15*60}, 0)
{1, 15*60}, 0)
end,
}
end
@@ -617,7 +622,7 @@ function AutoSuspend:AllowStandbyHandler()
wake_in = math.huge
end
if wake_in >= 3 then -- don't go into standby, if scheduled wakeup is in less than 3 secs
if wake_in >= 1 then -- Don't go into standby, if scheduled wakeup is in less than 1 second.
logger.dbg("AutoSuspend: entering standby with a wakeup alarm in", wake_in, "s")
-- This obviously needs a matching implementation in Device, the canonical one being Kobo.
@@ -679,7 +684,7 @@ function AutoSuspend:onNetworkDisconnected()
self:_start_standby()
end
--[[ -- not necessary right now
--[[-- not necessary right now
function AutoSuspend:onNetworkDisconnecting()
logger.dbg("AutoSuspend: onNetworkDisconnecting")
end