Skip to content

my application using ctypes crashes on Kivy 1.9.2 and not on 1.8 #858

@gued100x12

Description

@gued100x12

Hi,

I would like to share an issue i am getting while building an APK using the latest python-for-android package (1.9.x). The same code works fine on an old version of Kivy (1.8.).

I will try to describe how i get to this and please let me know if more clarification is needed:

  1. So, I am a C code where i am calling a callback function defined in python.
    Basically the code consists of (mydll.c):

`
typedef int (*callback_type)(float, float);

DLLEXPORT int our_callback(callback_type callbackHandler)
{
float a = 10;
float b = 50;
float count = 0;

for (count=0; count<60;count=count+10)
{
(*(callbackHandler))((a+count),b);
}

return 0;
`

  1. The python code consists of (main.py):

`
callback_type = CFUNCTYPE(c_int, c_float, c_float)

if name == 'main':

def greater_than(a,b):
    if a > b:
        Logger.info(u"GUED case1 {} is greater than {}".format(a,b))
        return 1
    else:
        Logger.info(u"GUED case1 {} is lower than {}".format(a,b))          
        return 0

    my_ctype_lib = cdll.LoadLibrary(os.path.join("my_clibrary"))
my_ctype_lib.our_callback.argtypes = [callback_type]

ret = my_ctype_lib.our_callback(callback_type(greater_than))
Logger.info(u"GUED ret= {}".format(ret))

`

Find attached the complete files:
python_ctype.zip

This works perfectly on PC (win32) and on android when using Kivy 1.8.
But when i build an APK using Kivy 1.9, i am getting a crash in the c library when referring to the callback (see the attached log file retrieved from logcat).
log_python4android_Kivy1.9_crash.txt

  1. How did i create the 1.9 Kivy distribution?
    I used the following command:
    python-for-android create --dist_name=batch2 --bootstrap=pygame -- requirements=hostpython2,python2,pyjnius,sdl,pygame,android,kivy

I am running out of ideas here and wondering what could have changed between 1.8 and 1.9?
Am i doing something wrong? or could it be that i am missing some modules?
I've checked the Cython version, i am using 0.23.

Let me know if you need more info.

Any help would be highly appreciated:-).
Thanks in advance.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions