[Cs-dev] LuaCsound, Android
Date | 2013-07-05 21:39 |
From | Steven Yi |
Subject | [Cs-dev] LuaCsound, Android |
Hi All, I've taken a look at the changes from Michael. For Android, to get things working to use downloadDependencies.sh and build-all.sh, I made the following modifications: 1. I updated the fluidsynth-android Bitbucket repository with the Application.mk and Android.mk that MIchael recently committed, and consequently removed the ones from Csound6's git repo. This means the repo for fluidsynth-android will have the most up to date files. 2. I moved luajit-2.0 from plugins to plugins/patches. downloadDependencies.sh now copies over the jni folder from plugins/patches/luajit-2.0 to the place where it checked out from GIT for luajit. I did some further testing about plugins and I think at this point, the crashing problem on my device is not with loading of libs but specifically the Lua opcodes. If I remove just that library, I can load/reload/render multiple times without crashes. I believe Andres had posted an issue where the Lua opcodes was crashing on load for his system but that seems to be resolved for him. I haven't found a good way to debug this on Android (I haven't gotten ndk-gdb to connect). Thanks! steven ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2013-07-05 21:50 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Hi Steven, It was solved for me by removing libLuaOpcodes... :PBTW, I'm having a similar issue with libsignalflow opcodes, so I've had to take those out as well. They seem not to be cleaning up correctly. I think it's important to fix these before release or not include them in installers as they will crash all hosts that do more than one run. Cheers, Andrés On Fri, Jul 5, 2013 at 1:39 PM, Steven Yi <stevenyi@gmail.com> wrote: Hi All, |
Date | 2013-07-05 21:53 |
From | Steven Yi |
Subject | Re: [Cs-dev] LuaCsound, Android |
Hi Andres, Thanks for following up on that. Yes, I think we need to ensure that these are not going to crash on multiple renders. Do you or anyone else have time to write a quick .c program that will render a csd multiple times so that we can reproduce the crash and trace with GDB easily? (I need to look at other things for the next bit of my work time, but can help debug/test later) Thanks! steven On Fri, Jul 5, 2013 at 4:50 PM, Andres Cabrera |
Date | 2013-07-05 21:58 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
You can use the test programs to check: Cheers,testChannels will run fine, but testCsoundTypeSystem will fail. Andrés
On Fri, Jul 5, 2013 at 1:53 PM, Steven Yi <stevenyi@gmail.com> wrote: Hi Andres, |
Date | 2013-07-05 22:12 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Is that on Linux? On OSX 10.6, I've tested from Python and I can run multiple times the following code cs = csnd6.Csound() cs.Compile("my.csd") cs.Perform() cs = None But then I don't have the LuaOpcodes built. Signal flow opcodes seem fine, as far as I can tell. Victor On 5 Jul 2013, at 21:50, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-07-05 22:22 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
I just ran the testCsoundTypeSystem here, it appears to pass alright: coltrane:c victor$ ./testCsoundTypeSystem CUnit - A unit testing framework for C - Version 2.1-2 Suite: Type System Tests Test: Test Type System ...virtual_keyboard real time MIDI plugin for Csound 0dBFS level = 32768.0 Csound version 6.00 (double samples) Jul 4 2013 libsndfile-1.0.21 passed Test: Test getVarSimpleName ...virtual_keyboard real time MIDI plugin for Csound 0dBFS level = 32768.0 Csound version 6.00 (double samples) Jul 4 2013 libsndfile-1.0.21 passed Run Summary: Type Total Ran Passed Failed Inactive suites 1 1 n/a 0 0 tests 2 2 2 0 0 asserts 9 9 9 0 n/a Elapsed time = 0.061 seconds end of score. overall amps: 0.0 overall samples out of range: 0 0 errors in performance Elapsed time at end of performance: real: 0.251s, CPU: 0.001s end of score. overall amps: 0.0 overall samples out of range: 0 0 errors in performance Elapsed time at end of performance: real: 0.316s, CPU: 0.020s On 5 Jul 2013, at 21:58, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-07-05 23:21 |
From | Steven Yi |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
The test also runs for me, and I am not building the Lua opcodes here on OSX. I haven't had any issue with the signal flow opcodes OSX or Android. I am going to boot up a Linux VM in a bit and see if I can reproduce Andres' issue there. On Friday, July 5, 2013, Victor Lazzarini wrote:
|
Date | 2013-07-05 23:39 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
But then you don't have the Lua opcodes... I'll look again at the signal flow opcodes to see if it's a problem on my end. Andrés On Fri, Jul 5, 2013 at 2:22 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2013-07-06 01:56 |
From | Steven Yi |
Subject | Re: [Cs-dev] LuaCsound, Android |
I ran "make test" on a Debian system and I get 3 failures. CTest reports 2 of them are failed tests and one is a segfault. I ran the failed tests with gdb and got: with testCsoundTypeSystem: Program received signal SIGSEGV, Segmentation fault. 0x00007ffff702b806 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 (gdb) bt #0 0x00007ffff702b806 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 #1 0x00007ffff52b2286 in std::__copy_move |
Date | 2013-07-06 02:38 |
From | Steven Yi |
Subject | Re: [Cs-dev] LuaCsound, Android |
Just some follow up, I had put a breakpoint on manageLuaState. Using testCsoundOrcSemantics, I saw five calls with "O" during the tests, then ctest printed its report, then with the call to manageLuaState with "C", I get the crash with the call to erase. I'm not used to debugging C++, but what I'm seeing is that the iterator it during the "O" calls is: {_M_current = 0x6f3370} but on the "C" call I see: {_M_current = 0x6f3380} which is equal to the luaStatesForThreads.end(). So... I'm not sure what's going on. Perhaps Michael could help debug/test. I also don't know if this is the cause of the issue on Android as I haven't been able to really get gdb going there. On Fri, Jul 5, 2013 at 8:56 PM, Steven Yi |
Date | 2013-07-06 03:03 |
From | Michael Gogins |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
I'm happy to help, the information supplied will be helpful. Unfortunately, I don't get this crash here... but I can probably figure out what is going on. The module cleanup function is probably not being called. I'll see if there's a workaround or if it is being called at an inopportune time, or I'll just preallocate a fixed number of Lua states (one per Csound thread) and keep them around. Something. Regards, Mike =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Fri, Jul 5, 2013 at 9:38 PM, Steven Yi <stevenyi@gmail.com> wrote: Just some follow up, I had put a breakpoint on manageLuaState. Using |
Date | 2013-07-06 15:49 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Yes, these are the issues I'm having. I think they don't occur on windows because there is no function registered with atexit (see csoundInitialize), but I'm not sure why it's not crashing on Os X. Cheers, On Jul 5, 2013 7:03 PM, "Michael Gogins" <michael.gogins@gmail.com> wrote:
|
Date | 2013-07-06 15:53 |
From | Steven Yi |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
It's not crashing on OSX because we don't build or distribute the Lua Opcode's on that platform. The reason had to do with issues with luajit and x86_64 I think. There was a thread from some time ago on this list where I wrote about the findings on why it doesn't work on OSX. Dealing with movers at the moment so I can't look it up at the moment. On Jul 6, 2013 10:49 AM, "Andres Cabrera" <mantaraya36@gmail.com> wrote:
|
Date | 2013-07-06 16:44 |
From | Michael Gogins |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
I changed the code some time ago so that this atexit stuff would not be called on WIndows, because it always caused a crash on exit and I had no idea how to fix it. On Android, the NDK docs advise allowing Android itself to do all cleanup on exit, so I will change the CsoundAndroid or CSDPlayuer code, whichever is most appropraite, to pass the CSOUNDINIT_NO_ATEXIT flag to csoundInitialize. Or something to avoid the atexit stuff on Android.
I don't know why I don't see this bug on the Galaxy S4. Regards, Mike
=========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Sat, Jul 6, 2013 at 10:49 AM, Andres Cabrera <mantaraya36@gmail.com> wrote:
|
Date | 2013-07-06 17:24 |
From | Michael Gogins |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
I have pushed code to call csoundInitialize(CSOUNDINIT_NO_ATEXIT) in CSDPlayer's static initialization block. As I understand it, this function only needs to be called once in process, is that correct? By the way, Steven, thanks for doing the patches directory. Regards, Mike ===========================
Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Sat, Jul 6, 2013 at 11:44 AM, Michael Gogins <michael.gogins@gmail.com> wrote:
|
Date | 2013-07-08 17:32 |
From | Steven Yi |
Subject | Re: [Cs-dev] LuaCsound, Android |
Hi Michael, I just tried CSDPlayer and it's still crashing. I imagine Linux will still crash since this change doesn't apply for it there. I wonder if there's some weird issue with how static is treated on *nix with gcc (which would apply to Linux and Android both). Seems like a longshot but I'm really not sure what's going on. :) I'm catching up a bit today on things before heading back to unpacking, but will try to do some further gdb diagnosis on Linux. Thanks! steven On Sat, Jul 6, 2013 at 12:24 PM, Michael Gogins |
Date | 2013-07-08 17:40 |
From | Michael Gogins |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Did you try from a fresh build or from a SourceForge app download? I haven't updated the latter with my fix yet. Regards, Mike =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Jul 8, 2013 at 12:32 PM, Steven Yi <stevenyi@gmail.com> wrote: Hi Michael, |
Date | 2013-07-08 18:05 |
From | Steven Yi |
Subject | Re: [Cs-dev] LuaCsound, Android |
I tried with a fresh build from GIT. BTW: perhaps a hint, I put a breakpoint in the == function (line 122, LuaCsound.cpp). When the manageLuaState with 'C' is called on LInux, this gets called from the STL find, and I get this: (gdb) print a.thread $17 = 6311936 (gdb) print b.thread $18 = 140737353996128 So the threads are no longer matching up by the time 'C' is called. During the initial 5 'O' calls, I get this: Breakpoint 3, operator== (a=..., b=...) at /home/steven/csound/csound6/Opcodes/LuaCsound.cpp:122 122 if (pthread_equal(a.thread, b.thread)) { (gdb) print a.thread $19 = 140737353996128 (gdb) print b.thread $20 = 140737353996128 Note, I'm pretty sure a in this case is the value held within the vector, as printing luaStateForThread.thread in the manageLuaState funciton shows the long thread id. On Mon, Jul 8, 2013 at 12:40 PM, Michael Gogins |
Date | 2013-07-08 19:04 |
From | Steven Yi |
Subject | Re: [Cs-dev] LuaCsound, Android |
Hi Michael, I've pushed a workaround fix. I'm able to do multiple renders on Android and no longer get a crash on Linux. I'm still not sure what the root cause of the original problem is, but I suspect that once atexit is called, somehow the static memory for the lua states is wiped. It's odd since we're in the same thread id, but that's as far as I can imagine as a guess. Anyways, the code does make more sense to me that if it's == to end(), not to try to erase anyways. At least for now this prevents crashes. I can render multiple times with Lua_ScoreGen and trapped on Android. I have no idea if this introduces a memory leak at all; maybe you can take a look as my C++ skills are not up to par to diagnose this. Otherwise, I'm at least glad that this is working. I'd like to get confirmation from Andres on Linux and would also like if you could post a new Android build and we can get confirmation from others with Android. Seems though we're getting closer for a release. :) Thanks! steven On Mon, Jul 8, 2013 at 1:05 PM, Steven Yi |
Date | 2013-07-08 20:34 |
From | Michael Gogins |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Erasing at end() would be a bug and should crash! If so mea culpa. I am investigating further. One this is for sure, process lifecycle and handling are VERY different on Android. In general, apps don't know whether they are alive or dead. The OS keeps pushing apps that the user doesn't interact with further into the grave. Generally, apps don't exit because the user did anything but because the OS kills them.
POSIX also gives no precise guarantees about the order of things at exit. I would prefer to let the OS clean up unless we have locks that it can't unlock. I'll review your code re: memory leaks, but if this is at exit, not to worry.
I will post a new build tonight. Regards, Mike =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Jul 8, 2013 at 2:04 PM, Steven Yi <stevenyi@gmail.com> wrote: Hi Michael, |
Date | 2013-07-08 20:44 |
From | Steven Yi |
Subject | Re: [Cs-dev] LuaCsound, Android |
Just a note, I realized I hadn't pushed the change (git was waiting for me to enter password). I just pushed the change now, thanks! On Mon, Jul 8, 2013 at 3:34 PM, Michael Gogins |
Date | 2013-07-08 20:51 |
From | Michael Gogins |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Right now, for some minutes, Csound6 git for the master branch is not accessible. Either it is busy, or it is messed up. Regards, Mike =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Jul 8, 2013 at 3:44 PM, Steven Yi <stevenyi@gmail.com> wrote: Just a note, I realized I hadn't pushed the change (git was waiting |
Date | 2013-07-08 21:58 |
From | Michael Gogins |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Still not there an hour later... =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Jul 8, 2013 at 3:51 PM, Michael Gogins <michael.gogins@gmail.com> wrote:
|
Date | 2013-07-08 22:10 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Not sure, I was able to pull earlier on, with no problems coltrane:debug victor$ git pull Password: remote: Counting objects: 10, done. remote: Compressing objects: 100% (6/6), done. remote: Total 6 (delta 4), reused 0 (delta 0) Unpacking objects: 100% (6/6), done. 19c8d93..8e97e56 master -> origin/master Updating 19c8d93..8e97e56 Fast-forward Opcodes/LuaCsound.cpp | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) coltrane:debug victor$ git log commit 8e97e56468af04d66c1988431da25788fa63b5b7 Merge: c91d7e3 19c8d93 Author: Steven Yi <stevenyi@gmail.com> Date: Mon Jul 8 15:41:52 2013 -0400 Merge branch 'master' of ssh://git.code.sourceforge.net/p/csound/csound6-git commit c91d7e3245480faf32162a33da05c7e0e8a3ecd5 Author: Steven Yi <stevenyi@gmail.com> Date: Mon Jul 8 13:59:04 2013 -0400 Workaround fix for lua crashes on Android and Linux: only call erase if the iterator is != vector.end() On 8 Jul 2013, at 21:58, Michael Gogins wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-07-08 22:36 |
From | Michael Gogins |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Yes, it seems to OK here (at home now, was at work). Regards, Mike ===========================
Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Jul 8, 2013 at 5:10 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2013-07-08 22:38 |
From | Michael Gogins |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Your fix looks correct to me. Regards, Mike =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Jul 8, 2013 at 3:44 PM, Steven Yi <stevenyi@gmail.com> wrote: Just a note, I realized I hadn't pushed the change (git was waiting |
Date | 2013-07-08 23:29 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Nice one. Fixes the problems for me too. Cheers, Andrés On Mon, Jul 8, 2013 at 12:44 PM, Steven Yi <stevenyi@gmail.com> wrote: Just a note, I realized I hadn't pushed the change (git was waiting |
Date | 2013-07-08 23:58 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Are we good now for the release? On 8 Jul 2013, at 23:29, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-07-09 00:25 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Let me quickly look at the alsa issue John reported. I think we should be good after that. Have all the tests been run and passed?Cheers, Andrés On Mon, Jul 8, 2013 at 3:58 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2013-07-09 00:33 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
The Lua issue is fixed, but if I use the default atexit function, I'm still getting a crash on cleanup for the signalflow opcodes. Maybe there is a similar fix for those? And I can't reproduce John's failure for the alsa raw module when listing devices. Anyone else having issues there?Cheers, Andrés On Mon, Jul 8, 2013 at 4:25 PM, Andres Cabrera <mantaraya36@gmail.com> wrote:
|
Date | 2013-07-09 00:39 |
From | Michael Gogins |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
I looked through the commits. I don't think my code for closing a thread's Lua state was ever truly correct. Thanks for finding this one, Steven. Best,
Mike =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Jul 8, 2013 at 6:29 PM, Andres Cabrera <mantaraya36@gmail.com> wrote:
|
Date | 2013-07-09 00:42 |
From | Michael Gogins |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
I'm looking at that. Mike =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Jul 8, 2013 at 7:33 PM, Andres Cabrera <mantaraya36@gmail.com> wrote:
|
Date | 2013-07-09 01:08 |
From | Michael Gogins |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
I have made the module destroy code for the signal flow graph opcodes a little Tighter. Tested on Android only. Regards, On Jul 8, 2013 7:42 PM, "Michael Gogins" <michael.gogins@gmail.com> wrote:
|
Date | 2013-07-09 01:16 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Fixed the hanging for me. Csound is now exiting nice and clean here with all the bells and whistles. Andrés On Mon, Jul 8, 2013 at 5:08 PM, Michael Gogins <michael.gogins@gmail.com> wrote:
|
Date | 2013-07-09 01:46 |
From | Michael Gogins |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
I've posted a new build of Csound6.apk for Android with Steven's fix and my fixes to http://sourceforge.net/projects/csound/files/csound6/Csound6.0rc4/Csound6.apk/download. Please test. Regards, Mike =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Jul 8, 2013 at 8:16 PM, Andres Cabrera <mantaraya36@gmail.com> wrote:
|
Date | 2013-07-09 03:02 |
From | Steven Yi |
Subject | Re: [Cs-dev] LuaCsound, Android |
Attachments | None None |
Hi Michael, You're very welcome! Glad I could assist on this one. I'm happy to report I downloaded the new apk you posted on my Nexus 4. I was able to render the Lua examples as well as Xanadu without crashes. Seems like we're good for this issue. Steven On Jul 8, 2013 7:39 PM, "Michael Gogins" <michael.gogins@gmail.com> wrote:
|