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

Global varible/objetct isn't being shared between multiple files on Android, while the same code works normally under Windows. #2485

Closed
5 tasks
killangell opened this issue Aug 29, 2021 · 3 comments

Comments

@killangell
Copy link

Checklist

  • the issue is indeed a bug and not a support request
  • issue doesn't already exist: https://github.com/kivy/python-for-android/issues
  • I have a short, runnable example that reproduces the issue
  • I reproduced the problem with the latest development version (p4a.branch = develop)
  • I used the grave accent (aka backticks) to format code or logs when appropriated

Versions

  • Python: 3.8
  • OS: Android 10
  • Kivy:
  • Cython: 0.29.19
  • OpenJDK: jdk1.8.0_301

Description

A.py including a global variable, say x = 1.
B.py: import A, then print(A.x), it's correct, but if sometime when A.x got updated in A.py, A.x in B.py didn't get updated.

The same code works correctly under windows but doesn't work on android.

buildozer.spec

Command:

// REPLACE ME: buildozer command ran? e.g. buildozer android debug
// Keep the triple grave accent (aka backquote/backtick) to have the code formatted

Spec file:

// REPLACE ME: Paste your buildozer.spec file here

Logs

// REPLACE ME: Paste the build output containing the error
// Keep the triple grave accent (a.k.a. backquote/backtick) to have the code formatted
@inclement
Copy link
Member

inclement commented Aug 29, 2021

Python isn't running differently on Android in any way that I'd expect to cause this mismatch. I think it's more likely that there's an issue with your code that manifests differently for a reason other than the platform change.

If you want to prove this is a real issue, please provide a minimal app example that reproduces the issue. We'll certainly log the bug if we can see this way that something is wrong.

@killangell
Copy link
Author

If you want to prove this is a real issue, please provide a minimal app example that reproduces the issue. We'll certainly log the bug if we can see this way that something is wrong.

You are right, it looks that it's not an issue of python for android, but for global variable sharing between android service and activity, though those are python code, but global variable is losing sync up between them.
Any suggestion for such situation?

@inclement
Copy link
Member

The service and activity are running separate python processes that don't share memory, if you want to pass messages you should do so explicitly with e.g. oscpy.

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

2 participants