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

Android event loop is incompatible with Python 3.13 #2907

Closed
mhsmith opened this issue Oct 13, 2024 · 1 comment · Fixed by #2908
Closed

Android event loop is incompatible with Python 3.13 #2907

mhsmith opened this issue Oct 13, 2024 · 1 comment · Fixed by #2908
Labels
android The issue relates to Android mobile support. bug A crash or error in behavior.

Comments

@mhsmith
Copy link
Member

mhsmith commented Oct 13, 2024

The following traceback is from the Toga main branch, but the code in question has been there for over a year, so it'll also affect the stable version. I'm not familiar enough with this area to suggest an immediate fix.

Testing this will require a new version of Chaquopy (beeware/briefcase-android-gradle-template#94).

E/AndroidRuntime: FATAL EXCEPTION: main
E/AndroidRuntime: Process: org.beeware.toga.examples.canvas, PID: 5835
E/AndroidRuntime: com.chaquo.python.PyException: AttributeError: 'AndroidSelector' object has no attribute '_key_from_fd'
E/AndroidRuntime:   at <python>.toga_android.libs.events.handle_fd_wakeup(events.py:347)
E/AndroidRuntime:   at <python>.toga_android.libs.events.onFileDescriptorEvents(events.py:414)
E/AndroidRuntime:   at <python>.chaquopy_java.call(chaquopy_java.pyx:352)
E/AndroidRuntime:   at <python>.chaquopy_java.Java_com_chaquo_python_PyObject_callAttrThrowsNative(chaquopy_java.pyx:324)
E/AndroidRuntime:   at com.chaquo.python.PyObject.callAttrThrowsNative(Native Method)
E/AndroidRuntime:   at com.chaquo.python.PyObject.callAttrThrows(PyObject.java:232)
E/AndroidRuntime:   at com.chaquo.python.PyInvocationHandler.invoke(PyInvocationHandler.java:31)
E/AndroidRuntime:   at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
E/AndroidRuntime:   at $Proxy4.onFileDescriptorEvents(Unknown Source)
E/AndroidRuntime:   at android.os.MessageQueue.dispatchEvents(MessageQueue.java:304)
E/AndroidRuntime:   at android.os.MessageQueue.nativePollOnce(Native Method)
E/AndroidRuntime:   at android.os.MessageQueue.next(MessageQueue.java:346)
E/AndroidRuntime:   at android.os.Looper.loopOnce(Looper.java:189)
E/AndroidRuntime:   at android.os.Looper.loop(Looper.java:317)
E/AndroidRuntime:   at android.app.ActivityThread.main(ActivityThread.java:8705)
E/AndroidRuntime:   at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime:   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
E/AndroidRuntime:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
@mhsmith mhsmith added bug A crash or error in behavior. android The issue relates to Android mobile support. labels Oct 13, 2024
@freakboy3742
Copy link
Member

Looks like the internal API for getting the event key from the file descriptor has changed - it's gone from _key_from_fd(), which is a wrapper around a straightforward dictionary lookup, into an API that does the lookup directly on the dictionary with a .get() call.

As far as I can tell, nothing else has changed, so it should be fairly straightforward to add a wrapper around _key_from_fd() usage in AndroidSelector that can accomodate the two implementations (or just wrap the two uses with a if sys.version... check).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android The issue relates to Android mobile support. bug A crash or error in behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants