Skip to content
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

[TIMOB-15765] Android: TableView - JNI ERROR (app bug): local reference table overflow (max=512) #8147

Merged
merged 1 commit into from Jul 21, 2016

Conversation

sgtcoolguy
Copy link
Contributor

JIRA: https://jira.appcelerator.org/browse/TIMOB-15765

Description:

  • Fixes the JNI local ref overflow seen on older Android (< 6)
  • Fixes the JNI weak global ref overflow seen on Android 6+

Ultimately we had a JNI ref leak when we had arrays containing proxy objects. So this would crop up with huge TableViews, or huge sets of contacts, or even arg arrays of XML nodes.

This also contains a tweak for emulator detection, since I don't think we actually properly detected "newer" x86 emulators, or Genymotion, or a number of other cases.

@ashcoding
Copy link
Contributor

Tested with test code in https://jira.appcelerator.org/browse/TIMOB-15765
as well as for https://jira.appcelerator.org/browse/TIMOB-20279

No issues.
Code for TIMOB-20279 that was tested on an Android 4.4.2 device with an account with 600+ google contacts:

Ti.UI.backgroundColor = 'white';
var win = Ti.UI.createWindow({
    exitOnClose : true,
    layout : 'vertical'
});

var button = Titanium.UI.createButton({
    title : 'Get Contacts Here',
    top : 60
});

win.add(button);

win.open();

var performAddressBookFunction = function() {
    var singleValue = ['recordId', 'firstName', 'middleName', 'lastName', 'fullName', 'prefix', 'suffix', 'nickname', 'firstPhonetic', 'middlePhonetic', 'lastPhonetic', 'organization', 'jobTitle', 'department', 'note', 'birthday', 'created', 'modified', 'kind'];
    var multiValue = ['email', 'address', 'phone', 'instantMessage', 'relatedNames', 'date', 'url'];
    var people = Ti.Contacts.getAllPeople();
    Ti.API.info('Total contacts: ' + people.length);

    for (var i = 0,
        ilen = people.length; i < ilen; i++) {
        Ti.API.info('---------------------' + i);

        var person = people[i];
        if (person != null) {
            var firstname = person.firstName || "Null";
            var lastname = person.lastName || "Null"
            Ti.API.info(firstname + "-" + lastname);
        } else {
            Ti.API.info("Person is null at" + i);
        }
    }

};
var addressBookDisallowed = function() {
    alert("Not Allowed");
};

button.addEventListener('click', function(e) {
    if (Ti.Contacts.hasContactsPermissions()) {
        performAddressBookFunction();
    } else {
        Ti.Contacts.requestContactsPermissions(function(e) {
            if (e.success) {
                performAddressBookFunction();
            } else {
                addressBookDisallowed();
            }
        });
    }
});

Works well!

@ashcoding ashcoding merged commit 818309f into tidev:master Jul 21, 2016
@mrkiley
Copy link
Contributor

mrkiley commented Jul 21, 2016

Awesome, thanks for getting this in guys. We will be giving it a whirl shortly, but I'm sure it's good to get since you guys tested it!

@sgtcoolguy sgtcoolguy deleted the TIMOB-15765 branch July 21, 2016 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants