-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Android service crashes when Kivy frontend app is stopped #2053
Comments
note: after a look at the code, I actually think that this is an issue with SDL2 bootstrap with Python for Android. If it is actually the case, is it possible to move this issue to P4A issues? |
I believe that this relates to the discussion at #1784 |
See also this: #2021 |
@goffi-contrib This is how you can restart your service. in my case this solved my problem. add these codes within your service codes . |
hi @quitegreensky thanks for the tips, I'm actually already doing that. But this is not a good option, that means that my backend has to restart each time the frontend is closed. It's a chat app so that means reconnecting and re-downloading necessary bootstrap data, etc. It is time and resource consuming. So this is a workaround, but not a good option for the long term, this bug needs to be fixed. |
@gbm001 Indeed. This needs to be fixed. Even with using |
Hi, I have same problem. There is any solution? at least something temporarily? When I close the app, notifications are stopped. I need that notifications always remaining. My service code is very simple: from time import sleep
from datetime import datetime
import plyer
import os
argument = os.environ.get('PYTHON_SERVICE_ARGUMENT','')
from jnius import autoclass
service = autoclass('org.kivy.android.PythonService').mService
service.setAutoRestartService(True)
if __name__=='__main__':
while True:
sleep(2.)
dt = datetime.now().strftime('%H:%M:%S')
plyer.notification.notify('Hora actual', dt) Any suggeration? |
@sfcaracciolo Did you find a solution? |
Versions
Description
When a backend service is used on Android, exiting Kivy frontend app will kill it (it receives a SIGKILL by Android) while it should continue to run in the background.
The
on_stop
method is never called, the backend is killed before.Code and Logs
To make testing easier, I've made a tarball containing a minimal frontend app and backend service, with the appropriate
.p4a
file (you need to adapt the--sdk-dir
and--ndk-dir
to your own installation before building the apk). The archive is available here: kivy_backend_bug.tar.gzI've also uploaded the built
.apk
so it can be tested directly, I had to rename it to.zip
otherwise github would not upload the file, so you need to rename it back to.apk
once downloaded: test_kivy_bug_service_build__armeabi-v7a-debug-0.1-.zipsteps to reproduce
APK
on an Android deviceadb logcat
Test Kivy Bug Service
application, observe that the backend is running (it prints every second aBackend is still running
message)App.stop()
is called, you can reopen the app by clicking on its screenshot while listing applications (the frontend is restarted but the backend continue as expected)Test Kivy Bug Service
(which kills the frontend)expected result: The frontend is killed, but the backend continues in the background
actual result: after a crash backtrace, the backend receives a
SIGKILL
.logs
Here are the Android logs when the frontend app is killed by user, please note that:
SDL : onDestroy()
is senton_stop
is never called (it should print==> stopping
)SIGKILL
signal (number9
) is sent to the backend after theWindowManager: java.lang.IllegalArgumentException
exceptionLogs:
The text was updated successfully, but these errors were encountered: