I am getting the “[ERROR] dalvikvm: JNI ERROR (app bug): local reference table overflow (max=512)” issue when simply calling Ti.Contacts.getAllPeople(). Literally, that ONE line of code is causing the error.
* I have 2900 contacts (and I know plenty of people with more), so I am not an abnormal use case.
* I know it is this one line because I have removed any other code around it (after the permissions of course), and the call works on Android 6.0+, but does not work on versions prior to Android 6.0.
* It works perfectly fine when I run it against an emulator with 0 contacts, or even 5 contacts. I suspect that it is not releasing the memory when it iterates over the contacts that it is retrieving.
The environments that I tested this on were:
1. Multiple Android emulators, but they all follow the same specs (besides the screen size) as the attached image shows
2. On a Galaxy S4 running Android 4.4.2
Here is a snippet of the code:
// Get permission to access the user's contacts
var contactsAuthorizationValue = Ti.Contacts.getContactsAuthorization();
if (contactsAuthorizationValue === Ti.Contacts.AUTHORIZATION_AUTHORIZED) {
var rawContacts = Ti.Contacts.getAllPeople(); // This is where the crash occurs
// Do more things down here
}
I've heard other users who had the same thing with only 1 person in the address book so for sure this is a bug.
Great, let me know if you need any more information provided. You guys are quick!
@Fokke / @Radamantis, this is getting to a point where it is starting to block us. Is there any update on this? Thanks guys! =)
[~Yrkh8trnoy] could you make sure this is still a bug using the 5.2.0 nightly?
[appc] ti sdk install -b 5_2_X
@Fokke it seems to be working on the latest nightly build. Thank you! I will let you know if we encounter this any more. Would you be able to shed some light on the final investigation discovery, and what the fix ended up being? I'd like to be able to identify this issue a lot quicker if it happens again elsewhere.
That's good news. What SDK version did you use before? Because since 5.1.2 nothing changed on the contacts front AFAIK: https://github.com/appcelerator/titanium_mobile/search?l=java&q=contacts
We were on 5.1.1.GA! and prior to that, 5.0.2.GA. When using an earlier build of 5.2, we encountered some issues which made us retreat to 5.1.1. Thanks for checking back in!
[~Yrkh8trnoy] could you check if 5.1.2 also fixes it for you?
Sure, I will check that today. I'll check back soon.
@Fokke, it works fine on 5.1.2. Thank you!
@Fokke, belay that last message. We looked at the wrong version for that test. I'll let you know as soon as we ACTUALLY test on 5.1.2 whether it works on there or not. Sorry for jumping the gun on that.
Hi Fokke, we've verified this time that we are actually on 5.1.2.GA, and Ti.Contacts.getAllPeople() works well with ~3,000 contacts. (y)(y)
Hi Fokke, This issue has resurfaced as of 5.2.2.GA. This is a major issue for us, any idea if the previous fixes were undone? Thanks.
Reopening as it appears to be a problem again in 5.2.2
Thanks. @Ashraf, I tested back to 5.2.0.GA, and it's still an issue. Maybe whatever fix was in the nightly build somehow was reverted prior to the GA? I don't remember what nightly build I had installed when it worked. But it seems that the only time it was truly working fine was with that nightly build.
[~Yrkh8trnoy] Very odd. Will line this up to get this investigated.
Thanks Ashraf! Hugely important because so many people still use Android < 6, unfortunately!
+1 vote
Is there a workaround that is suggested for this? According to the documentation (http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Contacts-method-getAllPeople) a "limit" that can be set on the number of contacts that I want to be retrieved, but it doesn't seem that I can page through that limit. You see, what I was thinking could be the workaround would be to retrieve 500 contacts on each pull. Say the user has 2,000 contacts, it would take four calls to
Ti.Contacts.getAllPeople(500, <page_number>)
to get all 2,000 of those contacts. That's fine by me, as a workaround for now, but it seems that I cannot currently perform such an operation.[~Yrkh8trnoy] there seems to be no way to paginate indeed: https://github.com/appcelerator/titanium_mobile/blob/415bd6c66dcc55b1a59a59574f3babd3c3a84ede/android/modules/contacts/src/java/ti/modules/titanium/contacts/ContactsApiLevel5.java#L224-L235 Could you create a JIRA ticket to request this to be added?
Sure, you can see it at AC-3628
Hi folks. Any updates on this? Thanks!
[~cng] [~hpham] how is this issue a duplicate of TIMOB-15765? I don't see how.
Hi folks, it's been about two weeks since Fokke commented and we still do not know why this was marked as "Resolve" as a duplicate of TIMOB-15765. I'm not sure what to do here as this blocks our ability to reliably retrieve contacts in our application, which is a blocker for us releasing our application to the public. Furthermore, there has been absolutely no movement since June 8 on TIMOB-15765, so that one seems to be stagnant as well. Can you PLEASE provide an update as your investigation into this, and when you can have this fixed?
You are right, not sure how this is a duplicate of this. Reopening this ticket.
Thanks Ashraf. What are your targeted plans on getting this resolved? Can you share some of the underlying issues that you have found that may be causing this? Are there any PRs that we could look at that may have tried to resolve this?
[~Yrkh8trnoy] I'm trying this out but not able to reproduce the crash. The test code that I've been using is:-
I've 1000+ contacts and it doesn't crash. I'm also looking at the possibility of using a paginate but that might not be the best idea. I'm looking into this. Could you add the logs that you get from such a crash? running "adb logcat -c" to clear the logs and running "adb logcat" to get the logs.
Able to reproduce it. Crash Logs as follows:-
Will probably carry out the solution/workaround for pagination.
Yep, that's the exact crash that we have experienced as well.
@ashraf, is there a hyperloop workaround for this, possibly?
[~Yrkh8trnoy] There's no hyperloop workaround for this at the moment.
This was fixed by TIMOB-15765
Hi [~Yrkh8trnoy] , I've been investigating this issue in an attempt to verify that the fix is valid, however I am unable to reproduce the crash that you are experiencing using a 4.4.2 Android device, and SDK version 5.2.2.GA. Additionally, I created ~4,000 contacts on the device to see if that would cause the crash, but still could not reproduce. If it is not inconvenient for you, could you please try the latest 5.4.0 version and let me know if you are still experiencing the crashes? This can be obtained by using:
appc ti sdk install -b 5_4_X)
Thanks in advance, _Harry Bryant - Quality Engineering_Ran
appc ti sdk install -b 5_4_X
that installed5.4.0.v20160724194540
No Errors. Everything works correctly as mentioned in TIMOB-15765 using Android 4.4.2 Adding the test code that was used for testing here:Thanks Ashraf. Harry, it was fixed in the latest 5.4.X build that we tried thanks to the ticket (and embedded PR) that Ashraf mentioned. The underlying issue itself was fixed by Chris Williams, so I don't believe it will pop up again in the future (fingers crossed!!!!)
Thank you for your feedback [~Yrkh8trnoy], glad to know that your issue has been resolved. Tested On: Android Samsung Galaxy S5 (4.4.2) Device Mac OSX El Capitan 10.11.5 Ti SDK: 5.4.0.v20160725003348 Appc Studio: 4.7.0.201607111053 Appc NPM: 4.2.7 App CLI: 5.4.0-34 Xcode 7.3 Node v4.4.7 *Closing ticket.*