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/ART crash Invalid instance of… #92

Closed
tshirtman opened this issue Dec 15, 2013 · 8 comments
Closed

Android/ART crash Invalid instance of… #92

tshirtman opened this issue Dec 15, 2013 · 8 comments

Comments

@tshirtman
Copy link
Member

I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/app/main.py", line 195, in <module>
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/app.py", line 735, in run
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/base.py", line 472, in runTouchApp
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/core/window/window_pygame.py", line 335, in mainloop
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/core/window/window_pygame.py", line 241, in _mainloop
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/base.py", line 315, in idle
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/base.py", line 300, in dispatch_input
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/base.py", line 266, in post_dispatch_input
I/python  (18450):    File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4428)
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/uix/behaviors.py", line 110, in on_touch_up
I/python  (18450):    File "_event.pyx", line 312, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4377)
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/lang.py", line 1256, in custom_callback
I/python  (18450):    File "/data/data/org.kivy.showcase/files/lib/python2.7/site-packages/kivy/data/style.kv", line 184, in <module>
I/python  (18450):      on_release: root.do('copy')
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/uix/textinput.py", line 250, in do
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/uix/textinput.py", line 1259, in _copy
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/core/clipboard/clipboard_android.py", line 36, in put
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/core/clipboard/clipboard_android.py", line 50, in called
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/android/runnable.py", line 46, in f2
I/python  (18450):    File "/mnt/Data/code/test/test/main/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/android/runnable.py", line 22, in __init__
I/python  (18450):    File "jnius_proxy.pxi", line 31, in jnius.jnius.PythonJavaClass.__init__ (jnius/jnius.c:21377)
I/python  (18450):    File "jnius_proxy.pxi", line 182, in jnius.jnius.create_proxy_instance (jnius/jnius.c:23587)
I/python  (18450):    File "jnius_export_class.pxi", line 556, in jnius.jnius.JavaMethod.__call__ (jnius/jnius.c:17355)
I/python  (18450):    File "jnius_conversion.pxi", line 57, in jnius.jnius.populate_args (jnius/jnius.c:5361)
I/python  (18450):    File "jnius_utils.pxi", line 70, in jnius.jnius.check_assignable_from (jnius/jnius.c:3395)
I/python  (18450):  jnius.jnius.JavaException: Invalid instance of 'org/jnius/NativeInvocationHandler' passed for a 'java/lang/reflect/InvocationHandler'
I/python  (18450): Python for android ended.

To reproduce, try to copy text in a kivy TextInput on android using ART instead of Dalvik.

Tested on android 4.4.2 on nexus 7 2013.

@tito
Copy link
Member

tito commented May 16, 2014

Ok, got the same with 2048. #113

@tito
Copy link
Member

tito commented May 16, 2014

Difference with there tests at https://android.googlesource.com/platform/art/+/ecbce8f/test/044-proxy/src/BasicTest.java: the invoke methods have throws Throwable. Not us.

@tito tito closed this as completed in f5b555d Jul 31, 2014
@tito tito reopened this Aug 20, 2014
@tito
Copy link
Member

tito commented Aug 20, 2014

I got another issue after this one, so i think it's still not enough

@tito
Copy link
Member

tito commented Aug 28, 2014

@dheeraj1991 This issue is not the place to discuss about your issue. Please use the mailing list, or open a new issue with logs.

@tito
Copy link
Member

tito commented Nov 12, 2014

So, i get this one easily now:

NfcAdapter = autoclass("android.nfc.NfcAdapter")
PythonActivity = autoclass("org.renpy.android.PythonActivity")
context = PythonActivity.mActivity
NfcAdapter.getDefaultAdapter(context)

Again, after debugging, the code fail during the ExceptionDescribe() after the IsAssignableFrom(): the first was hiding the second one.

After commenting out the ExceptionDescribe() in check_assignable_from(), i found that IsAssignableFrom() does'nt see the relation between the context and the signature:

I/python  (16912):  Traceback (most recent call last):
I/python  (16912):    File "/home/tito/code/testnfc/main.py", line 75, in <module>
I/python  (16912):    File "/home/tito/code/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/app.py", line 766, in run
I/python  (16912):    File "/home/tito/code/testnfc/main.py", line 70, in build
I/python  (16912):    File "/home/tito/code/testnfc/main.py", line 36, in nfc_init
I/python  (16912):    File "jnius/jnius_export_class.pxi", line 847, in jnius.jnius.JavaMultipleMethod.__call__ (jnius/jnius.c:22614)
I/python  (16912):    File "jnius/jnius_export_class.pxi", line 558, in jnius.jnius.JavaMethod.__call__ (jnius/jnius.c:19141)
I/python  (16912):    File "jnius/jnius_conversion.pxi", line 58, in jnius.jnius.populate_args (jnius/jnius.c:5741)
I/python  (16912):    File "jnius/jnius_utils.pxi", line 91, in jnius.jnius.check_assignable_from (jnius/jnius.c:3739)
I/python  (16912):  jnius.jnius.JavaException: Invalid instance of 'org/renpy/android/PythonActivity' passed for a 'android/content/Context'

So the previous fix is not enough, we need to find out why IsAssignableFrom was working with Dalvik and not ART.

@tito
Copy link
Member

tito commented Nov 12, 2014

I just found that: https://android.googlesource.com/platform/art/+/1268b74%5E!/

The message:

Fix broken JNI IsAssignableFrom.

The expected argument order was the opposite of what the spec
dictated.

@tshirtman
Copy link
Member Author

So it's not a bug in pyjnius, closing, nice digging!

@tito tito reopened this Nov 13, 2014
@tito
Copy link
Member

tito commented Nov 13, 2014

We cannot just said to our users: Try to upgrade android. Most of phones (even mine) still don't have the fix, and is not going to until Lolipop (maybe? no idea).

I'm doing a fix for it.

@tito tito closed this as completed in 5fb4667 Nov 13, 2014
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