简体   繁体   English

不推荐使用主线程上的Firebase同步XMLHttpRequest

[英]Firebase Synchronous XMLHttpRequest on the main thread is deprecated

I am working on a phonegap/cordova ionic app. 我正在使用phonegap / cordova离子应用程序。 I am testing on iOS and Android. 我在iOS和Android上测试。

On iOS all works well. 在iOS上运行良好。

However on Android, I get the following message when one of my views loads: 但是在Android上,当我的一个视图加载时,我收到以下消息:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. 主线程上的同步XMLHttpRequest因其对最终用户体验的不利影响而被弃用。 For more help, check http://xhr.spec.whatwg.org/ . 如需更多帮助,请访问http://xhr.spec.whatwg.org/

Each time I get this "warning" - my view does not load. 每次我收到这个“警告” - 我的观点都没有加载。

One of the .lp?dframe=t&id=...&pw=... queries that are to/from firebase has the following: 其中一个.lp?dframe = t&id = ...&pw = ...来自/来自firebase的查询具有以下内容:

<html><body><script>
function EnvSendPing(destURL) {
try{
var xhr=new XMLHttpRequest();
xhr.open("GET", destURL, false);
xhr.send(null);
} catch (e) { }
}
function EnvDisconnect() {
EnvSendPing("/.lp?disconn=t&id=294802&pw=LL8E8eo2Rz");
}
if(window.addEventListener)
window.addEventListener('unload',EnvDisconnect,false);
else if(window.attachEvent)
window.attachEvent('onunload',EnvDisconnect);
</script></body></html>

which clearly has the xhr in as async "false" - causing this "warning". 这显然有xhr in async“false” - 导致这个“警告”。

Is there a way in which I can force ALL Firebase queries to have async true. 有没有办法可以强制所有Firebase查询具有异步true。 If this is just a "warning" why should the page stall? 如果这只是一个“警告”,为什么页面会失速?

Note that on iOS and on Chrome and Safari on the desktop - all works as expected. 请注意,在iOS和桌面上的Chrome和Safari上 - 一切都按预期工作。

In my case the issue was due to commenting out of cordova.js as suggested by ionic-service-deploy documentation. 在我的情况下,问题是由于离子服务部署文档建议的cordova.js注释。

Uncommenting that, ensures smooth WS connectivity to Firebase. 取消注释,确保与Firebase的WS连接顺畅。 Why it should be such is beyond me - but I have tested by repeatedly adding and removing the include in my index.html to have the effect consistently reproduced on Android/4.4.4 device. 为什么它应该是这样的超出我 - 但我已经通过反复添加和删除我的index.html中的包含测试,以在Android / 4.4.4设备上一致地重现效果。

Hope this is of help to others - I spent a large time finding this out! 希望这对其他人有所帮助 - 我花了很长时间才发现这一点!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 不赞成在主线程上使用同步XMLHttpRequest - Synchronous XMLHttpRequest on the main thread is deprecated 不推荐在主线程上使用同步XMLHttpRequest - Synchronous XMLHttpRequest on the main thread is deprecated $.get 不是 function,不推荐使用主线程上的同步 XMLHttpRequest - $.get is not a function, Synchronous XMLHttpRequest on the main thread is deprecated XMLHTTPRequest错误:不建议在主线程上使用同步XMLHttpRequest…(SoundCloud API) - XMLHTTPRequest Error: Synchronous XMLHttpRequest on the main thread is deprecated … (SoundCloud API) 不推荐使用Firebase同步XMLHttpRequest - Firebase Synchronous XMLHttpRequest Deprecated 使用jQuery加载外部javascript并禁止“不建议在主线程上使用同步XMLHttpRequest…” - Loading external javascript with jQuery and suppress “Synchronous XMLHttpRequest on the main thread is deprecated…” jQuery load()错误:不推荐使用主线程上的同步XMLHttpRequest - jQuery load() error : Synchronous XMLHttpRequest on the main thread is deprecated 向后移动会导致错误:““不赞成在主线程上使用同步XMLHttpRequest…” - moving backward causes error: "“Synchronous XMLHttpRequest on the main thread is deprecated…” 主线程上的同步 XMLHttpRequest 在嵌入式 Javascript 代码中已弃用 - Synchronous XMLHttpRequest on the main thread is deprecated within embedded Javascript code Angular指令获取“主线程上的同步XMLHttpRequest已弃用” - Angular directive gets “Synchronous XMLHttpRequest on the main thread is deprecated”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM