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.
2 Answers
-
Please paste a link to reproducible example and we can look at it. Thanks.
-
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();