Firebase Synchronous XMLHttpRequest on main thread is deprecated

I am working on an ionic phonegap / cordova application. I am testing on iOS and Android.

In iOS, everything works well.

However, on Android, I get the following message when one of my views loads:

The synchronous XMLHttpRequest in the main thread is deprecated due to its detrimental effects on the end user. For more help, check out http://xhr.spec.whatwg.org/ .

Every time I get this "warning" - my view does not load.

One of the .lp? dframe = t & id = ... & pw = ... of requests that relate to / from firebase has the following:

<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 explicitly has xhr as async "false" - triggers this "warning".

Is there a way in which I can force ALL Firebase requests to have async true. If this is just a β€œwarning”, why should the page stop?

Please note that on iOS and Chrome and Safari on the desktop, everything works as expected.

+6
source share
1 answer

In my case, the problem was caused by commenting from cordova.js, as suggested in the deployment documentation using the ionic service.

Uncommenting this provides a seamless WS connection to Firebase. Why it should be outside of me, but I tested by repeatedly adding and removing include in my index.html so that the effect is played back sequentially on an Android / 4.4.4 device.

Hope this helps others - I spent a lot of time on this!

0
source

Source: https://habr.com/ru/post/989971/


All Articles