Problem description
Webview local storage it's broken on iOS 5.1. Performing an App update, local storage for webview it's no longer persistant.
Steps to reproduce and sample code
1. Run the sample code, run the app and click "add" a few times
Result: The data is shown and being stored in local storage
2. Close completely the app and restart app
Result: stored data is correctly shown
3. Install over the app from Xcode
Result: contents it's no longer available. Also, subsequently added data (like in step 1 and 2) it's no longer kept in the local storage.
Attaching also log file
// app.js
var win1 = Titanium.UI.createWindow({
backgroundColor:'#fff'
});
var webview = Ti.UI.createWebView({
url: '/localstorage.html'
});
win1.add(webview);
win1.open();
// localstorage.html
<html>
<head>
<meta name="viewport" content="width=device-width, maximum-scale=1.0, initial-scale=1.0">
<script type="text/javascript">
if(!localStorage["offline_submissions"]) {
localStorage["offline_submissions"] = JSON.stringify([]);
}
var submissions = JSON.parse(localStorage["offline_submissions"]);
var show = function(){
var al = document.getElementById('alertbox');
al.innerHTML = submissions.map(function(x){return x.a;});
}
var addItem = function(){
submissions.push({a: (new Date()).toString()});
localStorage["offline_submissions"] = JSON.stringify(submissions);
show();
}
show();
</script>
</head>
<body>
<div id='alertbox'></div>
<input type="button" onClick='addItem();' value="add"/>
<br/>
<br/>
<input type="button" onClick='localStorage["offline_submissions"] = JSON.stringify([]);' value="clear"/>
</body>
<script type="text/javascript">
show();
</script>
</html>
Additional notes
Customer ticket:
http://support-admin.appcelerator.com/display/APP-523422
Unable to reproduce following the provided steps.
It seems to be related to this: http://forrst.com/posts/Security_err_dom_exception_18_and_how_to_avoid-1Ge http://www.iphonewarroom.com/2012/07/how-to-fix-iphone-securityerr-dom.html
Unable to reproduce when update app via iTunes, or iPhone Configuration Utility or Xcode Run/Debug. Could reproduce via XCode Organizer, Devices tab, Add button. This problem is somehow related to the way application is updated. Probably installing via Xcode Organizer does not update the app properly.
Closing as not our bug