jrg*_*jrg 5 javascript sleep web-applications ios
当运行Web应用程序的iOS 8设备(即从主屏幕上的快捷方式启动)从其睡眠状态返回时,所有异步Web请求都无法触发OnUpdateReady回调.
问题很容易重现 - 只需将下面的两个代码文件放在任何Web服务器上并尝试一下即可.
还有其他人遇到过这个问题吗?如果有,有任何解决方法吗?
我发布此内容是为了吸引人们对iOS 8中的这个错误的关注,这个错误实际上毁了我所有的Web应用程序 - 我们不得不建议不要升级到iOS 7之外.是的,我已经在Apple上发布了这个问题Bug Reporter但我认为没有人看这些,因为它已经很长时间了.
app.manifest
CACHE MANIFEST
# 2014-09-24 - Test
CACHE:
default.html
Run Code Online (Sandbox Code Playgroud)
default.html中
<!DOCTYPE html>
<html manifest="app.manifest">
<head>
<title>Test Harness</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<meta name="HandheldFriendly" content="true" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<script language="javascript" type="text/javascript">
var Test = new function () {
var _GetEnd = function (oResult) {
var sResult = ': ' +
((oResult.Value === true)
? 'Success'
: 'Failure<br>' + oResult.Reason) +
'<br>';
var oLog = document.getElementById('idLog');
oLog.innerHTML = (new Date()) + sResult + oLog.innerHTML
setTimeout(_GetBegin, 1000);
};
var _GetBegin = function () {
var sURL = 'app.manifest';
var hAsyncCallback = _GetEnd;
try {
var oRequest = new XMLHttpRequest();
oRequest.onreadystatechange =
function () {
if (oRequest.readyState != 4) return;
if (oRequest.status != 200) {
hAsyncCallback({ Value: false, Reason: oRequest.responseText });
} else {
hAsyncCallback({ Value: true, Reason: null });
}
};
oRequest.open('GET', sURL, true);
oRequest.send(null);
} catch (e) {
alert('Critical Error: ' + e.message );
}
};
this.Start = function () { _GetBegin(); }
};
</script>
</head>
<body onload="Test.Start();">
<ol>
<li>Put both app.manifest and default.html on a web server.</li>
<li>Make sure this page is being launched from the Home screen as a web application.</li>
<li>Press the sleep button while it is running.</li>
<li>Press the wake button and unlock the phone to get back to this screen.</li>
<li>Under iOS7x the page continues, under iOS8 the onreadystatechange never gets called again.</li>
</ol>
<div id="idLog"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我也看到了同样的问题,尽管我的例子要简单得多。只需拥有一个 webclip 应用程序即可
<script>
window.setInterval(function(){
console.log("Johnny Five Alive! : " + new Date());
},1000);
</script>
在页面上。检查控制台,睡眠唤醒后,不再有控制台输出。这在 iOS7 上工作得很好(我的实际应用程序是一个复杂的 angularJS 的东西,我只是将问题归结为这一点)。您对错误报告有任何回应吗?
| 归档时间: |
|
| 查看次数: |
1945 次 |
| 最近记录: |