WRT App crashes when reading phone contacts via wrt.device APIs

  • Hello,
    I have created a simple WRT Application which reads the contacts list from the
    phone via Javascript using the wrt.device APIs. When I use the Nokia Web SDK
    Simulator 1.0.1 everything works fine. But when I run the WebApp on the N900,
    the WRT browser crashes and closes itself. It seems to be a problem with the
    iterator object generated by contacts.getContacts() call. To be more precise,
    when the call returns a list with many contacts (i.e. more than 20, for sure
    when more than 50), the iterator has problems and crashes the whole browser.
    For some reasons, instead, it doesn't crash if there are few results (i.e. less
    than 10).
    Below the code that makes the browser crash and close:

    // Prints out a message on the page
    function ex(e){$('#errorsDiv').append(e);}

    // This function should be called in case there's an error in the
    contacts.getContacts() method
    function errorCB(err){
    ex("ErrorCode: " + err.code + " ErrorMessage: " + err.message);

    // callback function called by contacts.getContacts().
    // To show that it works for a while, I added a timeout which calls the
    function recursively till the iterator is empty
    function result(iterator, count){
    var contactData; // dummy var
    if(count == null){
    // First round
    count = 0;
    for(var i=0; i < 10 && iterator.hasNext(); i++){
    contactData = iterator.next();
    ex(count + " contacts found for match string");
    // After calling 10 elements the function pauses for 5 sec, to show the
    printed results and then it calls itself again.
    setTimeout(function(){result(iterator, count);}, 5000);

    // Main code
    try {
    var so = wrt.device.load("contacts");
    var match = "";
    var transactionId = so.getContacts(result, match, so.SORT_ASCENDING,
    ex("Transaction ID: " + transactionId);
    catch(e) {
    // This code is not even called before the browser crashes

    // Note:
    // This fails
    transactionId = so.getContacts(result, "", so.SORT_ASCENDING, errorCB);
    // This fails as well
    transactionId = so.getContacts(result, "a", so.SORT_ASCENDING, errorCB);
    // This works if there's a Daniel in the phone contacts
    transactionId = so.getContacts(result, "daniel", so.SORT_ASCENDING, errorCB);

    Anyone can try?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.