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

App close when device is flipped #732

Closed
Tungsteno74 opened this issue May 6, 2016 · 13 comments
Closed

App close when device is flipped #732

Tungsteno74 opened this issue May 6, 2016 · 13 comments

Comments

@Tungsteno74
Copy link

Tungsteno74 commented May 6, 2016

05-06 04:00:06.523 9423-9443/? I/python: [INFO              ] [Android     ] Must go into sleep mode, check the app
05-06 04:00:06.523 9423-9443/? I/python: [INFO              ] [Android     ] App paused, now wait for resume.
05-06 04:00:06.533 9423-9443/? I/python: [INFO              ] [Android     ] Android wants to close our app.
05-06 04:00:06.543 9423-9443/? I/python: [INFO              ] [Base        ] Leaving application in progress...
05-06 04:00:06.953 9423-9443/? I/python: Python for android ended.
05-06 04:00:06.983 793-1738/? I/ActivityManager: Process pytbepygame.test.pytbepygame:python (pid 9423) (adj 0) has died.
05-06 04:00:06.983 793-1737/? I/WindowState: WIN DEATH: Window{4215d150 u0 pytbepygame.test.pytbepygame/org.renpy.android.PythonActivity}
05-06 04:00:06.983 793-1737/? W/WindowManager: Force-removing child win Window{421832e8 u0 SurfaceView} from container Window{4215d150 u0 pytbepygame.test.pytbepygame/org.renpy.android.PythonActivity}
05-06 04:00:06.983 793-1738/? W/ActivityManager: Force removing ActivityRecord{42bf5d30 u0 pytbepygame.test.pytbepygame/org.renpy.android.PythonActivity t157}: app died, no saved state
05-06 04:00:07.033 793-1738/? I/WindowManager: Screen frozen for +629ms due to AppWindowToken{45bc4e50 token=Token{451d5010 ActivityRecord{42bf5d30 u0 pytbepygame.test.pytbepygame/org.renpy.android.PythonActivity t157}}}

The on_pause method is present. The app work well when the device is flipped in sdl2, but is closed with pygame backend.

kivy 1.9.1

It just happens to me?

thanks

@dessant
Copy link
Contributor

dessant commented May 6, 2016

Possible duplicate of #730.

@kived
Copy link
Contributor

kived commented May 6, 2016

05-06 04:00:06.533 9423-9443/? I/python: [INFO ] [Android ] Android wants to close our app.

This means onDestroy() was called on your Activity. Please post a complete log rather than the small part you think is the problem.

@Tungsteno74
Copy link
Author

Tungsteno74 commented May 7, 2016

The bug happens in all the kivy app i have tested that use pygame as backend.

test code:

<InnerScrollForm@ScrollView+GridLayout>
    size_hint_y: None
    height: dp(50)

BoxLayout:
    orientation: "vertical"
    BoxLayout:
        orientation: "vertical"
        BoxLayout:
            Button:
                text: "outScrollButton"
        InnerScrollForm:
            GridLayout:
                orientation: "vertical"
                cols: 1
                size_hint_y: None
                height: self.minimum_height         
                BoxLayout:
                    orientation: "vertical"
                    size_hint_y: None
                    height: sp(100)
                    Button:
                        text: "theButton"                           
                BoxLayout:
                    id: "theBox"
                    size_hint_y: None
                    orientation: "vertical"
                    height: sp(200)
                    Button:
                        text: "theInnButton"
                    Button:
                        text: "theInnButton"
                    Button:
                        text: "theInnButton"
                    Button:
                        text: "theInnButton"
                    Button:
                        text: "theInnButton"
                    Button:
                        text: "theInnButton"
                BoxLayout:
                    size_hint_y: None
                    orientation: "vertical"
                    height: sp(80)
                    Button:
                        text: "yetAbutton"
                    Button:
                        text: "yetAbutton"
from kivy.app import App
from kivy.uix.button import Button

class mainApp(App):
    def on_pause(self):
        print "enter pause mode"
        return True

mainApp().run()

Full logcat log and my buildozer.spec:
https://gist.github.com/Tungsteno74/c12892ac223f4270f5548ba5b10b80cd

@Zen-CODE
Copy link
Member

Having the same issue, but rears it's head differently. The app is set to portrait and runs fine. You can switch between apps and it works. When it wakes up from sleep, it crashes without any useful logs.

When run in portrait mode, it wakes up without problems. There is an orientation change request just before the crash.

https://gist.github.com/Zen-CODE/d83fdd00d83b4e3721fa69d28a241745

@Zen-CODE
Copy link
Member

Zen-CODE commented May 18, 2016

Can confirm that setting 'android.minapi = 13' in the buildozer.spec file worked for me.
@Tungsteno74. Have you tried that?

@Tungsteno74
Copy link
Author

@Zen-CODE I tested right now and not work for me :( Always the same problem. When i flip the device, the app is closed (with no relevant error log)

@kollivier
Copy link
Contributor

Well, believe it or not, the close behavior is actually by design. :( See the "Caution" note on the Android Activity lifecycle about how it closes and restarts the app each time the app changes rotation:

https://developer.android.com/training/basics/activity-lifecycle/recreating.html

I guess completely reloading the app is one way to ensure it will load properly in the current rotation.... ;-) Doesn't explain the crash, but perhaps it relates to the app closing at an unexpected time? One other weird thing is that it seems Android has a Bundle instance object which saves certain app state and restores it automatically, and if it only partially restores the state or the app isn't expecting Android to do any restoration, it may be creating weird effects.

@Zen-CODE
Copy link
Member

@Tungsteno74. Please could you test and give some feedback using trunk (given kolliviers' merge: #797).

@Tungsteno74
Copy link
Author

Tungsteno74 commented Aug 19, 2016

@Zen-CODE Hello. Sorry for late reply. I tried just now the master 0.33dev with pygame and given me the same issue.
I checked the kollivier's merge and it should already be merged in the master. Confirm me that?

@Zen-CODE
Copy link
Member

Okay. And does setting 'android.minapi = 13' in the spec file work? This is still not clear.

@Tungsteno74
Copy link
Author

Unfortunately no. At the moment the problem remains even with android.minapi = 13.

@Tungsteno74
Copy link
Author

Tungsteno74 commented Aug 26, 2016

@Zen-CODE Ok i re-installed all; the OS, buildozer and all dependencies and now work correctly with 0.33dev and android.minapi = 13.
Thanks at all!

@Zen-CODE
Copy link
Member

Awesome :-)

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

No branches or pull requests

5 participants