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 "Web lock from a thread other than main"

Getting this error

"0x5085ca0: Tried to obtain the web lock from a thread other than the main thread or web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now…"

All code is in app.js , I open a popup style window from app.js and display the result from a xhr web call in the popup.

This was stable in beta builds prior to GA release.

Anyone have any ideas?

I am not aware that I have tried to instantiate a call on any other threads by code.

— asked March 10th 2010 by David Snell
  • Web request
  • xhr
0 Comments

2 Answers

  • Please paste a link to reproducible example and we can look at it. Thanks.

    — answered March 10th 2010 by Jeff Haynie
    permalink
    0 Comments
  • I had the same issue but not using popups. It was a webview on a new window.

    What I did to get around this issue is to create the webview everytime there is new data to display

    var win = Ti.UI.currentWindow;
    
    var prevView = null;
    
    function generateReport() {
        if (prevView != null) {
            win.remove(prevView);
        }
    
        var http = Ti.Network.createHTTPClient();
        http.setTimeout = 20000;
    
        http.onload = function() {
            var wvReport = Ti.UI.createWebView({
                html: this.responseText
            });
    
            prevView = wvReport;
            win.add(wvReport);
        };
    
        http.onerror = function(e) {
            alert('Error: '+e.error);
        };
    
        http.open('POST', 'somewhere.php');
        http.send();    
    }
    
    var btnRefresh = Ti.UI.createButton({
        systemButton: Ti.UI.iPhone.SystemButton.REFRESH
    });
    
    btnRefresh.addEventListener('click', function() {
        generateReport();
    });
    
    win.rightNavButton = btnRefresh;
    
    generateReport();
    
    — answered April 19th 2011 by Rhendy Barcebal
    permalink
    0 Comments
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.