Skip to content
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

device doesnt go on sleep mode #969

Closed
razzbee opened this issue Dec 26, 2016 · 26 comments · Fixed by kivy/kivy#4921
Closed

device doesnt go on sleep mode #969

razzbee opened this issue Dec 26, 2016 · 26 comments · Fixed by kivy/kivy#4921

Comments

@razzbee
Copy link

razzbee commented Dec 26, 2016

Hello I have successfully compiled and installed my kivy app on android 6 device , but the device doesnt go on sleep mode even though I havent enabled wake lock

I am using the master branch of kivy , python for android and buildozer. Thank you

@KeyWeeUsr
Copy link
Contributor

Are you sure you haven't enabled it in Developer settings or in a similar OS settings? Don't you have it connected via USB or something? The basic app isn't able to make Android stay awake.

@razzbee
Copy link
Author

razzbee commented Dec 26, 2016

the same happens even without usb attached , besides I havent enabled 'Stay Awake' mode in developers settings (Off)

@KeyWeeUsr
Copy link
Contributor

Can you provide the APK and/or the code?

@razzbee
Copy link
Author

razzbee commented Dec 26, 2016

let me send apk , do I upload it here?

@razzbee
Copy link
Author

razzbee commented Dec 26, 2016

App Uploaded here : http://playslack.com/mediamate.apk

@razzbee
Copy link
Author

razzbee commented Dec 26, 2016

I have opensourced the core part (as planned ) docs is not very good , but that should at least help. https://github.com/razzbee/kivy-android-webview

@razzbee
Copy link
Author

razzbee commented Dec 26, 2016

any solution yet?

@KeyWeeUsr
Copy link
Contributor

The apk seems corrupted for some reason, can't open it on both phone or pc. However, the code doesn't seem to have any issues with the lock itself. Have you tried it on some other device with higher/lower/same android version? Apparently if the apk is really corrupted, you'll need to paste here the AndroidManifest.xml file.

I still think it's something enabled on your device that forbids the phone to sleep.

@razzbee
Copy link
Author

razzbee commented Dec 26, 2016

I have reuploaded the apk , http://playslack.com/mediamate.apk , again the app crashes for android version less than 4.4

@KeyWeeUsr
Copy link
Contributor

Confirmed, yet I have no clue why. App doesn't use any related permission to wake lock (check manifest), I have no such option enabled and even the code seems to be correct. Webview bootstrap too.

Android 4.4.2

@razzbee
Copy link
Author

razzbee commented Dec 26, 2016

okay , but about this launch crash on android < 4.4 , is there any solution to that?

@KeyWeeUsr
Copy link
Contributor

Lowering minimal api for your app, otherwise I don't know. Logcat would be needed for the crash.

@razzbee
Copy link
Author

razzbee commented Dec 27, 2016

I think te non sleep mode is not from my code , because I tried compiling hello world and had the same bug, tried on android 5 & 6 devices

@razzbee
Copy link
Author

razzbee commented Dec 27, 2016

Well I figured out that this error happens with the sdl2 backend , pygame backend doesnt have this bug

@KeyWeeUsr
Copy link
Contributor

@inclement I tested it with both pygame and sdl2 launchers + that testapp_setup:

  • neither of launchers have this bug in project chooser screen
  • pygame after app launch sleeps well
  • sdl2 doesn't sleep
  • testapp doesn't sleep

any idea why? Webview isn't build upon sdl2, is it?

@razzbee
Copy link
Author

razzbee commented Dec 28, 2016

I cant use the pygame bootstrap , app crashes randomly with the pygame bootstrap , Please is there a fix for sdl2 bootstrap??

@razzbee
Copy link
Author

razzbee commented Dec 28, 2016

@inclement , @tito PLEASE can you investigate into this since its not only webview apps, any app I compile using the sdl2 bootstrap prevents device from entering sleep mode

@FeralBytes
Copy link
Contributor

@razzbee, why not just have your program stop after a set amount of time? Then the device will do it's normal sleep routine. Also if you want the device to sleep and still want to do things then you should make a service. If you service has forefront priority with a icon in the menu you can also get rid of that using some pyjinus; I put some code for that into the wiki.

@razzbee
Copy link
Author

razzbee commented Dec 29, 2016

I have posted a demo , you can test it, besides , have you tried the new toolchain with sdl2 bootstrap (using buildozer) : http://playslack.com/mediamate.apk

@inclement
Copy link
Member

I've checked the wakelock defaults, but it does default to 0 as it should. I guess this depends on something slightly different, and I'll keep looking into it.

@inclement
Copy link
Member

It looks like this is the Android manifestation of SDL2's screensaver suspension by default, as described here. You can try setting the env var as explained there as a temporary workaround. I'll look at a proper fix sometime soonish.

@razzbee
Copy link
Author

razzbee commented Jan 13, 2017

This might be a silly question to ask but any idea on how to set the ENV variable in my code ???

@inclement
Copy link
Member

inclement commented Jan 13, 2017

I was thinking it would be sufficient to add from os import environ; environ['SDL_VIDEO_ALLOW_SCREENSAVER'] = '1' at the top of your python file (before any other imports). On reflection I'm not sure if that is early enough, but it should be okay.

@razzbee
Copy link
Author

razzbee commented Jan 13, 2017 via email

@inclement
Copy link
Member

I've just checked this myself, and adding this env var does allow the device to sleep properly. I'm looking at how this should be fixed fully in Kivy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants