-
Notifications
You must be signed in to change notification settings - Fork 91
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
libpd to android, NewStringUTF error #4
Comments
I am getting this as well. (Nexus 7 version 1, android v 4.3) After about 30 minutes of sending constant messages from android to libpd, I get the below stacktrace. Please advise if there is an existing workaround within PdBase 08-23 16:56:56.630: W/dalvikvm(4233): JNI WARNING: input is not valid Modified UTF-8: illegal continuation byte 0x62 |
oops, I pulled in the most recent changes, and the problem looks to be fixed. Thanks! |
what changes you have pulled you think this is the answer of above questions ? @monkeyswarm |
I actually am still seeing this crash, I spoke too soon before. |
I have identified the issue. It's pretty deep, and I'm not sure how to best solve it. When sending a list out of Pd, we write two chunks of data to the circular buffer. Normally, the sequence for a 3-element list would be something like this.
However, the crash occurs when a buffer read occurs between the two buffer writes. This happens
So how can we make sure that the two buffer writes in listhook() (or message hook or print hook) are treated atomically? I'm rusty on my C-level threading, and I can't find where the read/write threads are set up within PdCore. What would happen if we used the same thread for reading and writing? Thanks for any help, this would be a huge benefit to the stability of libpd on Android! (And maybe iOS as well, though I haven't really hit this issue there since it wouldn't trigger a crash on malformed data). I may also put this on libpd, since it is within that library that the threading issue occurs... |
P.S. I've made my own workaround by only allowing a single write message at a time:
It (seems to) solve the issue, but has the downside of allocating and freeing memory on each call. I'm assuming there's a better solution... |
Sorry about the very tardy reply; the past few weeks have been rather insane... First of all, thanks for investigating and diagnosing the problem, Daniel! My take is that there should be a way to write multiple buffers to the ring buffer at the same time (and update the indices only once). I'm not sure whether this should be done with varargs or whether a second write method for a pair of buffers would do. I'll mull this over and get back to you. |
closed by libpd/libpd#95 |
It seems that android NDK API crashes sometimes on the JNI part when converting data to a jstring.
This does not happen always, just under intensive message passing and it throws this error:
05-13 11:28:25.387: W/dalvikvm(17566): JNI WARNING: input is not valid Modified UTF-8: illegal start byte 0xf4
i found this workarround that could help:
http://stackoverflow.com/questions/12127817/android-ics-4-0-ndk-newstringutf-is-crashing-down-the-app
The text was updated successfully, but these errors were encountered: