Ionic / firebase stuck loading forever

Hi all :smile:

My android version is >4.4

Actually, I no longer have that problem.

The problem came from my code, in my login controller where I use authentication, I had two “firebase ref”.

I noticed one of them wasn’t even used, maybe a leftover from previous attempt of facebook login.

Anyway, once I got rid of the extra " new Firebase " ref, I never encountered that problem again… Hopefully it can help.

Well, that’s good to know, because I do have a couple instances of multiple new Firebase…

Ok, so this seems to be the problem. Definitively -

It’s fixed if you uncomment cordova.js in index.html.

Now I wonder what are the consequences of uncommenting cordova.js?



That fixed it for me! Thanks so much you definitely helped me find the root cause of this problem faster than I would have otherwise. I will keep an eye out for any adverse effects.

Thanks ! I was stuck with the same problem, now everything work fine.
I think there no big conscequence about uncomment cordova, I see a line in the console about that :
Ionic Core: cordova.js has already been loaded

EDIT: Nope, the problem is still there :frowning:

I had more or less the same problem but in my case the issue was intermittent and not reproducible. See:

I also saw the warning about “cordova already loaded” (logged by the libraries).

For now I just took out the libraries (analytics etc, at the moment these are in “alpha” stage so probably it wouldn’t be wise to use them for production apps anyway). I’ll monitor closely if I see the issue again.

You help me a lot, thanks for posting the answer, I wonder if anyone from the Ionic team will post an official answer because right now I’m using ionic servers and I’ve uncommented cordova.js

Did you decide that this is the best solution to fixing the issue?

Do Not Remove Cordova, You may face some serious problem in future when you want to use some native library.

I made some tricks which solved this issue for me.

Create firebase instance just after app module like this -
var appMain = angular.module(‘starter’, [‘ngCordova’,‘ngStorage’,‘ionic’,‘starter.controllers’,‘’,‘firebase’]);
var firebaseInst = new Firebase(“”);

& this instance you can directly call in controller

var objMatches = $firebaseObject(firebaseInst.child(“methods”));

— Do Not Create Services for firebase instance.


Hey everyone!

I was facing a similar problem on my android phone. Ironically my app ran smoothly on my development laptop and most of the time it ran smoothly on my android phone, but once this problem occurred my android, it kept loading without doing anything anymore, it never ran on my android again. Only when I did ‘ionic run android’ and reinstalled the app did it work again.

I had a look at my app resources via remote debugging and I noticed the key value: “firebase:previous_websocket_failure” had “true” to its value. So I deleted this key-value pair and simply restarted my app, then my app finally began working again. I plan on getting around this solution by checking for this key-value pair and removing it programatically, and hopefully the next time a user opens the app it will work…if the user hasn’t uninstalled it by then.

I dont know what happens to my app that this bug seems to crop up, so I cant replicate the conditions for the bug and know whether my code works. Normally that particular key value pair would get deleted once loading starts, but on some occasions it doesnt and thats why my app fails.

I dont know if this post helps. Just check your resources via remote debugging. Maybe its is something there. Let me know what you guys think.

I’ve also noticed this websocket failure in the localstorage, but usually disappears automatically… Next time our app keeps stuck during loading (it happens sometimes) I’ll check if it’s still there and remove it…

Exactly my point. In my case when app got stuck loading that key-value pair never dissappered as it should have so I’ve put it on $watch to delete it immediately if it turns up. Lets see if I run into this problem again. For the time being the app seems to work fine. Fingers crossed.

This issue has bugged me the most. I have found a potential solution for this problem now which fixed it for me.
1- Do not uncomment cordova.js
2 - wrap every firebase init with ionic paltform ready.
Firebase stays connected as long as the app is open in device.

Hi timmy, could you provide some sample code. How are you wrapping the initialization? We have a factory and we’re not sure how to init firebase properly… would something like this work?

(function() {
	'use strict';

		.factory('Auth', Auth);

	/* @ngInject */
	function Auth(FIREBASE_URL, $firebaseAuth) {
		return $q(function(resolve, reject) {
			$ionicPlatform.ready(function() {
		           var ref = new Firebase(FIREBASE_URL);
                           resolve( $firebaseAuth(ref) );

You can use this solution - I asked this on stackoverflow . received an answer from firebase team - Interesting use of $q(Constructor)

Also you can monitor your connection by listening on firebase at .info/connected - like this$ionicPlatform, $ionicPush, FIREBASE_URL) {

var ref = new Firebase(FIREBASE_URL);
ref.child(".info/connected").on("value", function(snap){
  if(snap.val() === true){"Firebase connected")
  }else{"Firebase disconnected");


1 Like

Aaah ok, just like we were doing… cool


I’m experiencing the same issue on Ionic 2

Cordova CLI: 5.4.1
Ionic Version: 2.0.0-alpha.57
Ionic CLI Version: 2.0.0-beta.17
Ionic App Lib Version: 2.0.0-beta.8
ios-deploy version: 1.8.3
ios-sim version: 5.0.1
OS: Mac OS X El Capitan
Node Version: v5.1.1
Xcode version: Xcode 7.2 Build version 7C68

any ideas to resolve this issue? I can’t believe that I’m alone with issue. I’ve added an issue ticket for this:

1 Like

THANK YOU!!! After upgrading to Cordova 6 and the latest cordova-ios, I started seeing this strange behavior. Wrapping my firebase calls up like this works great – I should have been doing that to begin with, I am guessing.

Had the same problem (firebase stuck on loading and released on pressing back button) and it was resolved by putting the following meta on my

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline' *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *">

To notice, if you use ionic platform web client, you shouldn’t uncomment cordova.js on your index

1 Like

Hello Parvezd Where you able to programatically set the “firebase:previous_websocket_failure” if yes please drop a sample code thanks Because this Firebase issue with Ionic is annoying.