kivy / plyer

Plyer is a platform-independent Python wrapper for platform-dependent APIs
https://plyer.readthedocs.io
MIT License
1.61k stars 427 forks source link

OverflowError: Python int too large to convert to C long [android lollipop] #103

Closed ghost closed 9 years ago

ghost commented 9 years ago

With android lollipop and the gps example, i get the following error when i try to start the gps service (from the gui) :

I/python ( 9571): Android kivy bootstrap done. name is main I/python ( 9571): Run user program, change dir and execute main.py I/python ( 9571): [INFO ] Kivy v1.8.0 I/python ( 9571): [INFO ] [Logger ] Record log in /data/data/org.test.gpsexample/files/.kivy/logs/kivy_14-12-22_2.txt I/python ( 9571): [INFO ] [Factory ] 157 symbols loaded I/python ( 9571): [DEBUG ] [Cache ] register with limit=None, timeout=Nones I/python ( 9571): [DEBUG ] [Cache ] register with limit=None, timeout=60s I/python ( 9571): [DEBUG ] [Cache ] register with limit=None, timeout=Nones I/python ( 9571): /data/data/org.test.gpsexample/files/lib/python2.7/site-packages/kivy/core/image/img_pygame.py:12: RuntimeWarning: import cdrom: No module named cdrom I/python ( 9571): (ImportError: No module named cdrom) I/python ( 9571): [INFO ] [Image ] Providers: img_tex, img_dds, img_pygame, img_gif (img_pil ignored) I/python ( 9571): [DEBUG ] [Cache ] register with limit=1000, timeout=60s I/python ( 9571): [DEBUG ] [Cache ] register with limit=1000, timeout=3600s I/python ( 9571): [DEBUG ] [App ] Loading kv <./gpstest.kv> I/python ( 9571): [DEBUG ] [App ] kv <./gpstest.kv> not found I/python ( 9571): [DEBUG ] [Window ] Ignored (import error) I/python ( 9571): [INFO ] [Window ] Provider: pygame(['window_egl_rpi'] ignored) I/python ( 9571): [DEBUG ] [WinPygame ] Set window to fullscreen mode I/libSDL ( 9571): SDL_SetVideoMode(): application requested mode 1080x1701 I/python ( 9571): [DEBUG ] [Window ] Display driver android I/python ( 9571): [DEBUG ] [Window ] Actual window size: 1080x1701 I/python ( 9571): [INFO ] [GL ] OpenGL version <OpenGL ES 3.0 V@95.0 AU@ (GIT@I68fa98814b)> I/python ( 9571): [INFO ] [GL ] OpenGL vendor I/python ( 9571): [INFO ] [GL ] OpenGL renderer <Adreno (TM) 330> I/python ( 9571): [INFO ] [GL ] OpenGL parsed version: 3, 0 I/python ( 9571): [INFO ] [GL ] Texture max size <4096> I/python ( 9571): [INFO ] [GL ] Texture max units <16> I/python ( 9571): [DEBUG ] [Shader ] Fragment compiled successfully I/python ( 9571): [DEBUG ] [Shader ] Vertex compiled successfully I/python ( 9571): [DEBUG ] [ImagePygame ] Load </data/data/org.test.gpsexample/files/lib/python2.7/site-packages/kivy/data/glsl/default.png> I/python ( 9571): [INFO ] [Support ] Android install hooks I/python ( 9571): [INFO ] [Window ] virtual keyboard not allowed, single mode, not docked I/python ( 9571): [INFO ] [Text ] Provider: pygame I/python ( 9571): [INFO ] [OSC ] using for socket I/python ( 9571): [DEBUG ] [Base ] Create provider from android I/python ( 9571): [INFO ] [Base ] Start application main loop I/python ( 9571): [INFO ] [Android ] found 17 joystick I/python ( 9571): [INFO ] [Android ] create joystick <0> I/python ( 9571): [INFO ] [Android ] discard joystick <0> cause no button I/python ( 9571): [INFO ] [Android ] create joystick <1> I/python ( 9571): [INFO ] [Android ] create joystick <2> I/python ( 9571): [INFO ] [Android ] create joystick <3> I/python ( 9571): [INFO ] [Android ] create joystick <4> I/python ( 9571): [INFO ] [Android ] create joystick <5> I/python ( 9571): [INFO ] [Android ] create joystick <6> I/python ( 9571): [INFO ] [Android ] create joystick <7> I/python ( 9571): [INFO ] [Android ] create joystick <8> I/python ( 9571): [INFO ] [Android ] create joystick <9> I/python ( 9571): [INFO ] [Android ] create joystick <10> I/python ( 9571): [INFO ] [Android ] create joystick <11> I/python ( 9571): [INFO ] [Android ] create joystick <12> I/python ( 9571): [INFO ] [Android ] create joystick <13> I/python ( 9571): [INFO ] [Android ] create joystick <14> I/python ( 9571): [INFO ] [Android ] create joystick <15> I/python ( 9571): [INFO ] [Android ] create joystick <16> I/python ( 9571): [INFO ] [GL ] NPOT texture support is available I/python ( 9571): [DEBUG ] [Atlas ] Load </data/data/org.test.gpsexample/files/lib/python2.7/site-packages/kivy/data/../data/images/defaulttheme.atlas> I/python ( 9571): [DEBUG ] [Atlas ] Need to load 1 images I/python ( 9571): [DEBUG ] [Atlas ] Load </data/data/org.test.gpsexample/files/lib/python2.7/site-packages/kivy/data/../data/images/defaulttheme-0.png> I/python ( 9571): [DEBUG ] [ImagePygame ] Load </data/data/org.test.gpsexample/files/lib/python2.7/site-packages/kivy/data/../data/images/defaulttheme-0.png> D/audio_hw_primary( 183): disable_audio_route: reset and update mixer path: low-latency-playback D/audio_hw_primary( 183): disable_snd_device: snd_device(2: speaker) I/python ( 9571): Traceback (most recent call last): I/python ( 9571): File "jnius_proxy.pxi", line 143, in jnius.jnius.py_invoke0 (jnius/jnius.c:23653) I/python ( 9571): File "jnius_conversion.pxi", line 368, in jnius.jnius.convert_python_to_jobject (jnius/jnius.c:8386) I/python ( 9571): OverflowError: Python int too large to convert to C long W/System.err( 9571): java.lang.NullPointerException: Expected to unbox a 'int' primitive type but was returned null W/System.err( 9571): at $Proxy0.hashCode(Unknown Source) W/System.err( 9571): at java.util.Collections.secondaryHash(Collections.java:3405) W/System.err( 9571): at java.util.HashMap.get(HashMap.java:300) W/System.err( 9571): at android.location.LocationManager.wrapListener(LocationManager.java:849) W/System.err( 9571): at android.location.LocationManager.requestLocationUpdates(LocationManager.java:864) W/System.err( 9571): at android.location.LocationManager.requestLocationUpdates(LocationManager.java:490) W/System.err( 9571): at org.renpy.android.SDLSurfaceView.nativeInit(Native Method) W/System.err( 9571): at org.renpy.android.SDLSurfaceView.run(SDLSurfaceView.java:726) W/System.err( 9571): at java.lang.Thread.run(Thread.java:818) I/python ( 9571): [INFO ] [Base ] Leaving application in progress... I/python ( 9571): Traceback (most recent call last): I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/app/main.py", line 63, in I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/app.py", line 792, in run I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/base.py", line 481, in runTouchApp I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/core/window/window_pygame.py", line 381, in mainloop I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/core/window/window_pygame.py", line 287, in _mainloop I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/base.py", line 324, in idle I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/base.py", line 309, in dispatch_input I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/base.py", line 220, in post_dispatch_input I/python ( 9571): File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4552) I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/core/window/init.py", line 648, in on_motion I/python ( 9571): File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4552) I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/core/window/init.py", line 660, in on_touch_down I/python ( 9571): File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4552) I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/uix/widget.py", line 284, in on_touch_down I/python ( 9571): File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4552) I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/uix/widget.py", line 284, in on_touch_down I/python ( 9571): File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4552) I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/uix/behaviors.py", line 92, in on_touch_down I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/uix/behaviors.py", line 191, in _do_press I/python ( 9571): File "properties.pyx", line 345, in kivy.properties.Property.set (kivy/properties.c:3591) I/python ( 9571): File "properties.pyx", line 377, in kivy.properties.Property.set (kivy/properties.c:4066) I/python ( 9571): File "properties.pyx", line 431, in kivy.properties.Property.dispatch (kivy/properties.c:4659) I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/lang.py", line 1299, in custom_callback I/python ( 9571): File "", line 18, in I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/plyer/facades.py", line 199, in start I/python ( 9571): File "/home/pla/Dev/gpstest/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/plyer/platforms/android/gps.py", line 84, in _start I/python ( 9571): File "jnius_export_class.pxi", line 830, in jnius.jnius.JavaMultipleMethod.call (jnius/jnius.c:21138) I/python ( 9571): File "jnius_export_class.pxi", line 562, in jnius.jnius.JavaMethod.call (jnius/jnius.c:17919) I/python ( 9571): File "jnius_export_class.pxi", line 656, in jnius.jnius.JavaMethod.call_method (jnius/jnius.c:19004) I/python ( 9571): File "jnius_utils.pxi", line 43, in jnius.jnius.check_exception (jnius/jnius.c:3237) I/python ( 9571): jnius.jnius.JavaException: JVM exception occured I/python ( 9571): Python for android ended. I/art ( 9571): System.exit called, status: 0

kived commented 9 years ago

This may be a problem with the implementation of hashCode() returning id(self). In CPython, id() returns the virtual memory address of the object. The result is the equivalent of an unsigned long, but jnius needs to convert this to a signed long, resulting in the overflow above.

thorin-schiffer commented 9 years ago

Workaround is to return id(self) % 2147483647

lipi commented 9 years ago

I can confirm that the workaround solves the issue, thanks

depau commented 9 years ago

@eviltnan Can you provide a patch?

thorin-schiffer commented 9 years ago

@Davideddu are you sure this dirty hack should be accepted as a fix?

depau commented 9 years ago

I don't know, I just wanted to implement it in my app