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.on_pause / on_resume on iOS not called properly? #3202
Comments
I'll second this. I've seen in in the simulator (iOS 6 and 8) and on an Ipad running 7.0. on_stop does not appear to be called either. |
Hi, any new insights on this? |
@dessant on android pause and resume events work fine for me. have you encountered this issue on android as well? And referring iOS. Anybody with the required knowledge motivated to take a look about this? |
I can confim, that on Android 5 the on_resume is called very unreliable. It's called most of the time, but not every time. I didn't had this issue with 4.4 |
This issue may be related #1261 |
The iOS App lifecycle, states and corresponding events are documented here I greped my project and kivy-ios for those events but cannot find anything. Where does the code for bridging iOS lifecycle events to kivy lifes? Is it implemented at all? |
@rnixx somebody on irc reported the same issue on android iirc. |
now i tried to react as delegate via pyobjus directly. The code looks something like:
But i cannot get this work either. How do i correctly setup the app lifecycle delegates? |
I don't think adding specific delegates will work, we are using SDL2, and so, we need to double-check why SDL2 doesn't send the events at all. Or if we correctly manage them or not. |
Ok, we completly missed thoses when switching to SDL2: SDL_APP_TERMINATING Will add them and test it right now. |
Reference: https://wiki.libsdl.org/SDL_EventType |
So weird. Even without implementing theses event, i can actually pause/resume the pictures demo. I see the vent called. Currently, pause/resume are implemented on the window minimzed/restored. We could change to will enter background/foreground for android/ios, but still, i don't get the issue on iPad 2 simulator, iPad 3 real device, both iOS 8.2. Checking iPad mini air on iOS 8.4 in simulator. |
Ok no, my bad, i did change the implementation. One change in kivy for minimizing the app did break this behavior. Fixing it; |
You need to use kivy master, not kivy 1.9.0 when compiling (1.9.0 is the default in the recipe). Enjoy! |
Huzzah! Thanks tito! |
Thanks! |
I think you've got a bad copy paste:
SDL_APP_DIDENTERBACKGROUND is repeated twice and SDL_APP_DIDENTERFOREGROUND is missing I think. |
The return statement needs to be fixed as well for the same reason. |
Fixed, thanks for your eyes ^^ |
Unfortunately the behavior is still not correct on iOS (tested on ipad mini with ios 8.3)
Update:
@kmonson can you confirm this? or anybody else? |
For me this looks like a timing problem and the app not receives the event before going into sleep or similar. pause event on emulator happens somewhat deferred. Also https://github.com/kivy/kivy/blob/master/kivy/core/window/window_sdl2.py#L542 might be related to the whole story |
can someone reopen this please? |
The related SDL documentation (https://wiki.libsdl.org/SDL_EventType) says: "These events must be handled in an event filter, since often the OS needs an immediate response and will terminate your process shortly after sending the event, and if it sits in the SDL event queue, it'll be too late." and "You can handle everything else through a normal SDL_PollEvent() loop, but you should set up a callback with SDL_SetEventFilter() for these specific events." grep'ing kivy for SDL_PollEvent and SDL_SetEventFilter tells me:
Looks like the event filter callback is missing for the lifecycle events |
That's what i found in the SDL sources https://hg.libsdl.org/SDL/file/704a0bfecf75/README-ios.txt#l58 |
Here i began to integrate SDL_EventFilter master...rnixx:sld2_mainloop_overhauling. Took me some time with my rudimentary cython skills, but maybe it saves you some minutes ;) |
Hi @tito, I have the same problem on Android 5.1 (ie on_pause() does not get called when it should). I've just tried this again with current master (commit 0c7cd9e) My app is a simple one that uses the camera: it correctly calls out to the Android Camera app, but will not return due to this bug. Here's a snippet of the logs, and I have logging in my on_pause/on_resume() methods which never get called (on_pause does return True by the way):
I've been struggling for a while to get the camera on Android working with Kivy (not easy), and this bug is the latest blocker..can you re-open this issue please? Thanks. |
Please open a new issue, this one for iOS is solved. If possible, give us a snippet to reproduce it. |
It seems that on_pause/on_resume is not called properly on iOS (iPad mini with iOS 8.2).
Neither when leaving the app via home button, nor when pressing power button on_pause is called, on_resume is not called either when reentering the application.
Any hints?
The text was updated successfully, but these errors were encountered: