views:

24

answers:

1

I'm on Titanium 1.2.1 using SDK 4.0 compiling to a device with 3.1.3. This crash doesn't manifest itself in the simulator, but only on the device. I have a tableView listing a list of contacts. When clicking on a contact name, it opens a new heavyweight window (in a different execution context). The new window shows details of the contact such as their name and picture, and then it makes an ajax request to the server to fill out all other details.

contactTableView.addEventListener('click', function(evt) {
    var contactWin = Ti.UI.createWindow({
        url: "contacts_show.js",
        title: evt.rowData.title,
        backgroundColor: colors.window_bg_color,
        barColor: colors.topbar_bg_color
    });
    contactWin.contact = evt.rowData.contact;

    Ti.UI.currentTab.open(contactWin, { animated: true });
});

This generally works on the device, unless you go back and forth a couple of times between the contact details and the contact list--then it crashes.

Here is the crash log: http://gist.github.com/557988

From the crash log, it seems like when I was going back and forth, it got to a point where it decided it needed to kill an execution context in order to save memory. But at that point, it looks like it crashes when it tries to remove an event listener. I don't think I'm doing anything strange with the event listeners. Anyone know how I can go about debugging this problem? Thanks in advance.

A: 

I figured it out. The short version of the answer was that I put addEventListeners inside of files that were being included multiple times. Hence, the array that contained the eventlisteners, when being destroyed when the execution context was being destroyed, was being mutated while being iterated on. Hence, the SIGABORT.

I moved any addEventListener calls to the top level window file of any execution context, and never put it in any included files.

Wilhelm