-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Suspend function #2239
Comments
So basically you're saying that the suspend function works, but that it would be nice if we could get an idle state that only consumes 2mA? |
Hmm... That would suggest that Nickel's "Menu Idle"/background processing = 2mA drain. Some of that would be the touchscreen monitoring. The 15 or 16 seconds is interesting as well, there are deliberate delays applied to KOReader's current suspend function. I would assume that the need to save position and other data enters into the delay. |
@Markismus , @KenMaltby |
I am not seeing anything that KSM has running in the background, when it calls koreader.sh, unless one of the other utilities like WiFi or USB services were started by the user, as well. (Plugging in the USB cable, might also.) The 13mA idle you show for KSM suggests that more than the 2mA [Correction there is only 1mA above true sleep] Nickel needs (to monitor the touchscreen and whatever else) is involved in the KSM idle, as you made the measurement. It still is a mystery, but you have certainly provided some data I haven't seen before. |
Thanks @oldhasbeen for the data! They are very useful. I have never thought of do this kind of checking before. This is something we should have done better from the beginning. I think the high idle consumption rate has something to do with KSM. IIRC, it actually runs in the background if that's what you use to start KOReader. I need to double check on this one though. The bigger issue, as you pointed out, is not putting the device in the sleep properly in some of the scenarios. We should definitely fix this. Without actually testing myself, my initial guess would be event triggered by closing sleep cover interrupts the sleep and wakes up the kernel. But KOReader never puts the system into sleep after by calling suspend script again because it thinks the device is already suspended due to pressed power button. |
Tagged this issue to stable release for further investigation. |
@houqp |
@oldhasbeen thank you for your great analyses of power consumption for kobo reader, it is really helpful in my opinion and you even went step up from the one on forum.
This also shows something I felt happening (and never was sure if it really is so), that for some reason sleep cover is causing battery drain. That's why I was asking for ability to disable sleep cover: #1733 I really hope that koreader will achieve power efficiency as nickel, as this is only thing in my opinion where nickel has some advantage. Of course, koreader is much superior in any other way that charging battery more frequently is something I gladly do. Just to mention, it looks that in some scenarios there could be even worse battery drain, something I mentioned here: http://www.mobileread.com/forums/showpost.php?p=3379558&postcount=42 In that instance, over less than 24 hours battery dropped from 100% to 72% and there was loss of 3 minutes (clock was late 3 minutes), suggesting that something impacted whatever takes care of clock accuracy. But, this is rare. This with sleep cover, this happens more often. |
@oldhasbeen could you help test #2245 to see if it makes a difference? @AlanSP1 if you know how to reproduce the clock skew issue, please do let us know, I will take a look. |
@houqp |
Copy content fromt he web and saving files with notepad++ might introduce weird encoding issues. It's better to download them directly and copy them to the device :) links: Also make sure you don't have |
About clock, that is something I noticed when there was also battery drain. I didn't do anything special. And this is rare. After that I started using again CoolReader suspend script and even tried powering off device completely. Strange thing is, when I power off device there's also loss of battery and clock is late about same amount. This is pretty confusing. Power off script I use points to KSM's own power off script. So, this probably isn't koreader related. |
@houqp |
That's awesome! Thanks again for the help! What radio device are you using for the test? I would like to get my aura one first before opening up my hd :P |
@houqp
When false sleep is present the screen shows book cover and no touch actions. The Infrared touch system is however active as well and touches (with nonconductive pointer) gives responses on AM monitor. I have done all this with coolreader but have not found a way to goof it's sleep function. Works every time no matter what I throw at it. Closed cover results always in true sleep and short pressing power then will wake the system briefly but is will fall back into true sleep. Closed sleep cover overrides everything else. About AM monitoring:
I myself place the ereader on top of my radio in a fixed position to have some signal when the reader is awake. The change to true sleep is clearly discernible and a stopwatch helps with timing. Data processing and house keeping can be observed as well. |
Just to comment that CoolReaders suspend script can have problems (some users report it, I also had some), but they seem to be less pronounced, far less pronounced. |
@houqp |
I also wanted to add to this discussion, good stuff... But I also notice drain in Koreader without having KSM installed. I now installed Koreader on my Aura One using the Filemonitor method and also then I notice draining. (Last night it went from 97% to 46% over ~7 hours in sleep mode. Pressed the power button from within Koreader to put it to sleep after which it showed the book cover (as expected). Woke it up this morning and battery was down by ~50%, I also noticed that from within Koreader it doesn't seem to go to sleep automatically... But perhaps that's some setting I missed somewhere. Already put on the patches mentioned in this thread btw... |
Koreader at the moment AFAIK don't have automatic sleep. If you left it on, it should stay on indefinitely (i.e. till battery runs out). There were discussion about this feature, but I think it still isn't implemented. But, I can be wrong here. |
My previous change only fixes the issue you mentioned earlier, i.e. after putting the device into suppend through power button, closing the cover will wake up the device and never puts it back to true sleep. Could you help verify that this is indeed fixed?
This is interesting. I can't come up with a good explanation on why this is happening yet. I just ordered a radio receiver online so I will reproduce it this weekend.
Thanks for confirming this. That means our suspend code is working properly but something weird happens when that code path is triggered by the sleep cover.
Good catch. This should be fixed by my latest changes, again, you can download them from: |
@Hzj-jie already implemented the autosuspend feature for kobo. By default, the timeout is set to 3600 (1 hour). You can change it by tweaking the reader setting |
I am not sure how well koreader works with fmon since, IIRC, nickel is running in the background. koreader does not communicate with nickel during suspend. So maybe that causes the battery drain. |
Thanks for the feedback! Just wanted to add something else wrt the drain... I found this thread: https://www.tapatalk.com/topic/270306-50705 So one of the things there suggested the 10s delay might not be enough to finish necessary processes before going into suspend and thus failing. As a result I modified the following line in koreader\frontend\device\generic\device.lua
to
Thinking along the lines of 'higher resolution so perhaps needing more time for drawing the cover, etc'. 15 was just a 'really should be enough if this is the issue'. An no idea if it's a coincidence but after a 1 hour suspend it now didn't loose a single percentage of battery. Also checking the log I now see:
Before there was a In between the Asking for a Suspend to RAM... and Zzzz ZzZ ZzZ? (0) lines. I now have no drain in Koreader (in combination with filemonitor) anymore it seems. Also after a reboot all is still good. No clue if this did the trick, but might be worth a try as well... gonna keep an eye on it (and perhaps start from scratch to really identify what did the trick (if any trick has really been done ;) ) I will check the timeout setting as well wrt auto-suspend. Things are getting better and better ;) Edit |
Where this setting is stored? Defaults.lua? |
@AlanSP1 : It's in the Koreader folder once you started (and closed?) Koreader for the first time. Btw, today I did a reinstall of the kobo firmware and reinstalled Koreader with KSM08. Everything seems to work great INCLUDING sleep! I think the 15s tweak mentioned above indeed does the trick: koreader\frontend\device\generic\device.lua
to
Both after autosleep after 4 mins and manual sleep I don't have battery drain. |
@houqp This observation may be a red herring (?): when true sleep works there is a brief burst of activity about 1 second before switching to true sleep. When true sleep is lost there is no burst but idling continues. |
The autosleep timeout can be set in the settings.reader.lua file (in the koreader folder, koreader has first to be started (and closed?) in order for it to be created). There you can add a line to set timeout in seconds, such as below (where the time is set to 240seconds, meaning 4 minutes). Take note that the lines, except the last one, are seperated by a comma:
|
I think this is too technical for other users :) What I prefer is to have all these system info (including disk usage) shown in a modal that can be triggered from the menu. Or even better, have koreader automatically monitor the memory usage in background and trigger an alert to user when it meets a threshold. |
@poire-z |
@houqp |
Has anyone knowledge how other readers (nickel, kindle etc.) handle memory and memory leaks? |
You could check for "pkill -15"s, wonder how suspend would clear the blitbuffers memory and still have the image displayed. I don't think the e-Ink display refreshes that way, but I don't know how it would work. |
It's indeed a wild ride (more than 100+ technical comments) ;) We couldn't have gone this far without help from everyone especially your detailed hardware level analysis, @dagrim1's 15s discovery and @poire-z's insight. I still can't explain why 15s is the magic number though, maybe it's kernel related. Please don't close this issue yet since we still have couple more actionable items:
As I mentioned in my previous comment, they simply launch one process for each opened book. Once we move to this model, it will "fix" most of our memory leak issue too. This model also has the extra benefit of isolating crashes from books to the main koreader process which will make koreader able to reopen a book if a crash is detected instead of going back to KSM. |
I am now convinced that the memory leak is the root cause. After starting koreader the resident/virtual memory size was 19/69, creeping up eventually to 355/521 where the dictionary lookup stopped to work. At 443/617 I tried to suspend and koreader crashed. Restarting restored full memory and all functions worked ok. There was never any false sleep - that seems a thing of the past. |
Memory leaks related to images should be fixed in current nightly (>=813), so you may wish to upgrade to see how that goes, and tell us if it leaks less quickly (there are still some leaks when switching documents). |
@poire-z In versions before v.813 on my Aura H2O resident size was increasing by 12MB each time after "suspend (show book cover) - wake up" action. After v.813 in that scenario it is inreasing by 2MB (some small leak was left). All in all, thank you all for determination narrowing suspend/memory problems. |
@j4w0r: i just checked that (cover image - i usually use files), and i may see the same increase you do (may, as i'm not sure, the increase is small, there may be some increase when turning pages, and sometimes there's a decrease). |
@poire-z I'd like to have this added as an additional option, that users can choose to use or not. It is very useful now, but can be handy in the future also. |
@poire-z |
Just checked with the emulator (no suspend, but calling screensaver.show() & close()), that there is a 0.2M memory leak after each, whether cover image is stretched or not, and even when it is displaying text. Image display eats 2-4M, but this seems released or reused. Numbers may be bigger on our devices, dunnoy why, arm stuff ? For these other leaks (dict, suspend), well, I don't know, it's less obvious than what i saw with blitbuffers. BUT : we may all watch this after a fresh start, and notice memory usage grows after most actions. May be there's some delay for garbage collection/memory re-use to happen. Just saw some graph at #1060 which may indicates that it needs some time to reach some state where there is enough holes in the already allocated memory to be reused. About the memory usage footer item, i'll wait for @houqp 's ok. |
For reference: just tried dict lookup with this pure LUA json decode in place of the lpeg based one, with no noticable difference in the (small) memory increase. |
@poire-z |
Thank you for the tests and numbers. |
Just want to comment on too much info in footer is distraction. I think that if we have option to turn on/off individual items in footer, we can control our "footer irritation level" to our liking. Some would have problems with many items in footer, some would like to keep eye, but we all can control that to our liking, thus having more options we can control to our liking is always better than having less options. About virtual memory usage, I'm not sure if this is important number, it depends on system. If anything, we can split this in two options, one for resident memory, one for virtual. |
@poire-z |
update: I have never seen a false sleep again since the suspend script is in lua. I am constantly in koreader and have never turned the device off. No crash or dictionary lookup failures either since knowing how much memory is allocated and restart koreader before memory becomes too tight. |
I was concerned with difficulty of removing memory info from footer in the future when memleak issue is fixed. Now that I have a pending patch for configuration updater module, this kind of configuration migration can be handled much cleaner. So I have no objection adding memory info into footer since it does help improve usability at this stage. @oldhasbeen good to know! I will do the final test for my unexpected wakeup patch then move on to look into the memory leak issue. |
With batterystats plugin, I still see my Kobo Aura HD wakes up randomly. Indeed, I almost have not used it during last week, but the awake time is ~4500 minutes, I.e. half of the week. I have set the auto suspension time to 15 minutes, and auto restart KOReader after crashes. But it's not likely KOReader dies once per 15 minutes. |
I think the suspend part of this has been taken care of by now, right? ;). |
Issue Device seems to sleep but it is draining power like in page display or menu modes
Steps to reproduce
I have measured the battery currents of my Aura H2O and made this observations:
Off state: approx 40 microamps
KSM 08 idle: 13 mA average
Koreader idle book open: 13mA average
Koreader in true sleep mode: 1mA average
Nickel Menu idle: 2 mA avg
Nickel sleep: 1mA avg
maximal working current 320 mA
Coolreader and other apps in the vlasovsoft package
have also 1mA sleep current
True Sleep (suspend)is a three stage process:
With open sleep cover and pushing the power button briefly Coolreader goes to true sleep. Closing now the sleep cover will wake the device briefly followed by the suspend chain. Coolreader will always true suspend when the sleep cover is closed. (I have not tested Nickel).
The latest releases of Koreader do go into true sleep when sleep cover is closed. They will also go into true sleep when power button is briefly pressed.
With open sleep cover and pressing power button true sleep is initiated. Closing the sleep cover will wake the device briefly (full 300 mA current) it will proceed to stage 2 (13 mA) and will remain there. The screen shows the book cover and the device appears to sleep but it is not. The current drain is the same as with a displayed page in reading mode.
Disconnecting a charging cable with closed sleep cover will also result in a false sleep state and 13 mA drain.
I have measured with Fluke 87 (average mode) direct in the positive battery lead.
The device activity can be non-intrusive observed with an AM radio: Place the ereader within a few centimeters to the ferrite antenna and select a long or medium wave range. Select an unoccupied frequency and listen to the speaker noise. Move the ereader around to get the feel what to look at.
Stage 1 and 2 are not easy to discriminate but stage 3 is significantly quieter. The jump to stage 3 occurs after about 16 seconds from triggering the suspension chain and is easily to recognize.
I hope this helps to improve the sleep function.
The text was updated successfully, but these errors were encountered: