kivy-ios: pyobjus code crashing on 64 bit devices after using new toolchain
First, I am not sure if this should be here or in the pyobjus repo. Since this is what triggered it, and the problem files are in the kivy-ios/build directroy, I decided to start here.
First, the old code worked on all simluators and devices previously. I can replicate crashes on start sometimes with every 64 bit simulator and real device listed. For the simluators, it will sometimes start the app and display the ad, but after rotating a bit it will crash. I have included the errors I have seen so far.
simluator: iphone 4s: ok iphone 5: ok iphone 5s: sometimes on start, xcode debugger stops at:
kivy-ios/build/python/x86_64/Python-2.7.1/Modules/gcmodule.c
gc->gc.gc_refs = Py_REFCNT(FROM_GC(gc)); Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
or xcode debugger stops at:
kivy-ios/build/python/x86_64/Python-2.7.1/Modules/gcmodule.c
if (PyObject_IS_GC(op)) { Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
it will sometimes start, able to toggle ad, then sometimes on rotate, xcode debugger stops at:
kivy-ios/build/sdl2/x86_64/slime73-sdl-experiments-a66a7f7e8cd8/src/video/uikit/SDL_uikitevents.m
result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, seconds, TRUE); Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
iphone 6: same as iphone 5s, but sometimes also see it crash at start with, xcode debugger stops at:
kivy-ios/build/python/x86_64/Python-2.7.1/Modules/gcmodule.c
_PyObject_GC_UNTRACK(op); Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
iphone 6 plus: cannot test, see issue #122 ipad 2: ok ipad air: same as iphone 5s ipad retina: ok
It seems all 32 bit devices work properly.
Real devices: iphone 5s: on start always crashes with xcode debugger stopping at:
kivy-ios/build/python/arm64/Python-2.7.1/Objects/listobject.c
op->ob_item = (PyObject **) PyMem_MALLOC(nbytes); Thread 1: signal SIGABRT
xcode log:
kivy-iad-sample(2549,0x1997e5310) malloc: *** error for object 0x17420c320: Invalid pointer dequeued from free list
*** set a breakpoint in malloc_error_break to debug
(lldb)
Confirmed removing all pyobjus code allows it to run properly
ipad air 2: same as real iphone 5s
I don’t have a 32-bit real ios device to test on, I suspect it would work.
<bountysource-plugin> --- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/9465241-pyobjus-code-crashing-on-64-bit-devices-after-using-new-toolchain?utm_campaign=plugin&utm_content=tracker%2F9081&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F9081&utm_medium=issues&utm_source=github). </bountysource-plugin>About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 16 (8 by maintainers)
@zoltan-fedor awesome advice. Your approach is by far superior, I actually wish I had taken the 5 minutes to learn about cocoapods when I was initially doing this. I ended up needing to use cocoapods to get the Google iOS game services dependencies correct as the instructions for manually including the libraries are just plain wrong and I couldn’t manage to resolve all the linker errors myself.
I’ll start with the bad news: I still have absolutely no idea what’s causing the crash, largely because I don’t know what the fuck I’m doing lol. But seriously there’s a lot of moving pieces here. I can try to get better familiarized with things a later date and hopefully be of more use. This issue needs someone with the python/C/objective-c skills plus knowledge of the kivy-ios toolchain and pybojus codebase.
Now the good news is I’ve managed to integrate Admob using pyobjus. No, really.
Step 1: Aimlessly flop around for a few of days. Step 2: Integrate Admob Basically all I had to do was write a simple NSObject class to create and toggle ads. I found an open source sdl project and made use of most of its banner ad class(credited and linked in gist).
Working sample here - https://gist.github.com/AllieCarver/7c1bce67e9e1b723fa4866c37b61b56a
I did have one other issue I should mention when adding the Google Firebase and AdMob frameworks in xcode. (linker flags are new to me) First follow the instructions to manually add firebase and admob to your xcode project(or the pod method if you know how that works, I don’t). Then I had to change the Other Linker Flags found in xcode project Linking settings, load_all or whatever was default was causing compilation errors, I replaced it with -ObjC flag (as stated in Google docs not actually sure if this was necessary) , -Wl,-no_compact_unwind (this just suppressed some errors, so optional, note that is a " , " this is all one flag), and finally add -force_load path-to/kivy-ios/dist/lib/libsdl2_ttf.a for all libraries in lib folder. Compile the app a couple of times it will fail there are a couple of other iOS frameworks that need to be added I just googled the class names in the errors and found the associated framework. Off the top of my head they were CoreTelephony, MediaPlayer , GLKit and maybe one more.