Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Images in TableView crashing app with null pointer failures

$
0
0

Hi folks. I'm getting an intermittent error that happens regularly enough that it's making the app unusable.

I think it could have something to do with the resizing of the image - see the

image.width="120%"
Here's some code to illustrate:
var args = [];
//adding stuff to stage
 
/*
 * replace the contents of index.xml with this
 * 
  <Alloy>
    <Window class="container" title="Innovation Cafe Community">
 
        <TableView id="ideaList" class="bodyContent">
        </TableView>
 
    </Window>
</Alloy>
 
 */
 
function populateTable() {
var datenow = ((new Date).getTime()) / 1000;
 
    showDel = true;
    var tableData = [];
 
    for (var i = 0; i < 100; i++) {
        var dataRow = {image:"https://community.innovationcafe.com/sites/community/uploads/ideas/img_53c68ecdd8a89.jpg"};
        var row = Ti.UI.createTableViewRow({
            height : 80
        });
 
        var image = Ti.UI.createImageView({
            defaultImage : "/images/all-ideas-icon.png"
        });
 
        //to simulate "no image" - uncomment this line (looks like it leads to no failures)
        //dataRow['image']="";
 
        if ("" != dataRow['image']) {
            var patt = new RegExp(' ', 'g');
            //spaces in image names freak iOS out... (not related to THIS test)
            dataRow['image'] = dataRow['image'].replace(patt, '%20');
            patt = null;
            //giving a bit of info on the image
            image.image = dataRow['image'];
            //commenting this out prevents failures. Setting this to a definite value, like 60 doesn't help
            image.width = "120%";
        } else {
            image.image = "/images/all-ideas-icon.png";
            //interestingly, setting this DOES NOT seem to create a problem
            image.width = "120%";
        }
        row.add(image);
        tableData.push(row);
    }
    rows = null;
    return tableData;
}
 
var iterations = 0;
setInterval(function() {
    console.log("iteration:" + iterations++);
    $.ideaList.data = [];
    setTimeout(function() {
        $.ideaList.data = populateTable();
    }, 1000);
 
}, 3000);
 
$.index.open();
Here's where it gets strange. You need to run an iOS simulator (I'm using iPhone 5, 5s and 6) - uninstall the app, if it is installed, then clean the project, then run the project. If the console output indicates that "iteration 5" has been reached, the failure is not likely to happen in this cycle. Run an uninstall-clean-run cycle again. Repeat until failure.

This is typically the error I get:

[INFO] :   failbags2(95744,0x57fd1a8) malloc: *** error for object 0x7a2ca800: pointer being freed was not allocated
[INFO] :   *** set a breakpoint in malloc_error_break to debug
I could swear this wasn't too much of a problem a while back. I'm running this stack
OS X Mavericks (OS X 10.9.5 (13F34))
Xcode: Version 6.0.1 (6A317)
Titanium Studio, build: 3.4.1.201410281727
Titanium SDK 3.4.1GA
Often, on the simulator, the app will crash, and then, when run again (either by hitting "Run" in Titanium, or clicking on the app icon) - it seems to have healed itself. This happens sometimes, but not always.

Since this tends to "work itself out" - I've just been telling users to relaunch the app. But if you go to the app store and search for "innovationcafecommunity" and install Innovation Cafe Community app, then go to "discover" and use the search bar - by entering, say, "credit" - the app basically becomes unusable.

Any pointers, patches or other communication would really, really be appreciated. We're stumped at the moment.


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>