Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Error Message at going back to XHR

Hi again,

that will be my last one for today :-)

I am building a productivity app where I have a Window A which contains a tableview of items which are loaded from our servers via XHR. On click on such a generated row I create Window B which then gets the details of the item’s dataset to display/edit.

All that works perfectly, but if I go back from the Window B to Window A via the navbar the following error occurs:

bool _WebTryThreadLock(bool), 0x522c730: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now…

Here is the (surely standard) XHR code piece on Window A:

var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function()
    Ti.API.info('XHR loading');

and here the call to create Window B on an tableView click event

var winDetail = Ti.UI.createWindow({url:'itemDetail.js'});
winDetail.rowData = e.rowData;

What does that error message mean? Isn’t it allowed to call a XHR twice? But overally I am still a little bit curious about all that window-back-and-forth in modern desktop/mobile apps :)

P.S.: I love the "Crashing now…". It adds some fun to a serious event. It’s like as if Data from Star Trek would say that: "3,2,1 - I’m crashing now…".

— asked May 19th 2010 by Sebastian
  • iphone
  • mobile
  • xhr

2 Answers

  • Accepted Answer


    I think the question will be : what UI objects do you use on your detail window?

    Are there webviews on it?
    Any event listeners? (for window open, focus or blur ?)

    I've seen this error a few times here and there - but not every time.
    Is it happening every time for you?

    I don't know what's causing it, but it could be something to do with some memory management while destroying the window objects which is causing it)

    btw, the error should have nothing to do with the XHR on the first window I think. That can get reused whenever you want it. (for an 'refresh', for example)

    — answered May 19th 2010 by Kosso
  • Hi,

    you were so right! After spending hours of "outsourcing" my HTTPClient into app.js to be in the main thread, I started to follow your advise and deactivate the UI objects in my detail window. And finally I found the reason for the crash: it was a TextArea in a tableview row!

    I played around with the settings of the TextArea but even a completely default TA caused the list window to crash when it was displayed again. Very strange, seems a bug or?

    Anyway, I switched now to a TextField and it works fine now.

    — answered May 20th 2010 by Sebastian
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.