Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: bug: $ionicLoading Not Being Removed #3717

Closed
saniyusuf opened this issue May 13, 2015 · 16 comments
Closed

bug: bug: $ionicLoading Not Being Removed #3717

saniyusuf opened this issue May 13, 2015 · 16 comments
Assignees

Comments

@saniyusuf
Copy link
Contributor

Type: bug

Platform: android 4.4 webview

Type: bug

Platform: android 4.4 webview

Hi,
I have a case where in my Resolve for a route, I get some data from the local DB.

resolve: {
    CategoriesList: ['Category', '$ionicLoading', function(Category, $ionicLoading) {
        $ionicLoading.show({
            template: 'Loading Categories',
            noBackdrop: true
        });

        return Category.getAllLocalCategories()
            .then(function(allLocalCategoriesSuccessData) {
                $ionicLoading.hide();
                return {
                    categories: allLocalCategoriesSuccessData,
                    success: true
                };

            }, function() {
                $ionicLoading.hide();
                return {
                    success: false
                };

            });
    }]
}

The code above shows how I handle my flow by showing the $ionicLoading and then hiding it asap I get something. This code has always worked since up until RC3. Updating to RC4 RC5 including Stable 1.0.0 seems to make sure that the $ionicLoading stays open. The funny part is it happens only on Android. On IOS the code works as normal but on Android (Both IONIC Serve & Ionic Device), It breaks. I have a video showing proof.


@saniyusuf saniyusuf changed the title $ionicLoading Not Being Removed bug: $ionicLoading Not Being Removed May 13, 2015
@saniyusuf saniyusuf changed the title bug: $ionicLoading Not Being Removed bug: bug: $ionicLoading Not Being Removed May 13, 2015
@mhartington
Copy link
Contributor

Could you provide a codepen demo? Faking the DB call of course

@mhartington mhartington self-assigned this May 13, 2015
@mhartington mhartington added the needs: reply the issue needs a response from the user label May 13, 2015
@saniyusuf
Copy link
Contributor Author

Hi @mhartington I wont be sure if a codepen will be of help here as there is soo much going on. But I can tell you that in the bare bones its the fact that post RC3 based on the code above the $ionicLoading refuses to hide on android only. On IOS it works fine post RC3

@Ionitron Ionitron removed the needs: reply the issue needs a response from the user label May 14, 2015
@perrygovier
Copy link
Contributor

Hey @saniyusuf, it's difficult to fix what we can't reproduce. Even using $timeout instead of ajax calls, could you give us some way to reproduce it that we can inspect and test against?

Btw, thanks for all you're doing in the UK. We'll be London for AngularConnect in Oct. Let me know if there's any meetups we should swing by.

@perrygovier perrygovier added the needs: reply the issue needs a response from the user label May 20, 2015
@saniyusuf
Copy link
Contributor Author

Hi @perrygovier I have created a code pen similar to my use case here http://codepen.io/saniyusuf/pen/OVboOz . This problem is a very bizarre one on IOS both Chrome, emulator and device no problem but on Android both Chrome And Device, the loading does not go away and worst part is there is no error in console.

And yes I should be in London, i was disappointed you did not come to Amsterdam with the lads it was great meeting you guys.

@Ionitron Ionitron removed the needs: reply the issue needs a response from the user label May 27, 2015
@ffabreti
Copy link

ffabreti commented Jun 9, 2015

I've had similar problem ( $ionicLoading.hide() not working ) when I implemented localStorage cache in my App. I have debugged with lots of console.logs everywhere because I had not a single error on the console. I came the the conclusion that retrieving cached data was so quick that $ionicLoading.hide() finishes execution before $ionicLoading.show().
What solved for me was: $timeout( function(){ $ionicLoading.hide()},100);
I have seen this hack before on Titanium with Android, so I guess it has something to do with the way Android code is processed...

EDIT
If you do $ionicLoading.show({delay:100}) and then $ionicLoading.hide() it works, I mean, if the two calls are done very fast ( less then 100ms ) loading is never show, what is supposed to be expected.
I think that the show call is registered and the hide call cancels it. Obviously! But when you do not use the delay option, the show call spends some time executing itself (async, my guess) while the hide call gets executed (and hides nothing) resulting loading to stay opened forever.

@saniyusuf
Copy link
Contributor Author

Ahh finally someone with my problem and I thought I was going crazy. @ffabreti For me it works well on IOS but once you switch to Android the problem persists.

@TeChn4K
Copy link

TeChn4K commented Aug 12, 2015

Same problem ! Explanations proposed by @ffabreti seem consistent.

$ionicLoading.show({delay:100}) made my day, thank !

@saniyusuf
Copy link
Contributor Author

@mhartington @perrygovier any update on this little bug. For me it is android specific. The little hack seems to work

@mhartington
Copy link
Contributor

Hmm, is that codepen from earlier still a good base to work from @saniyusuf ?

@mhartington mhartington added the needs: reply the issue needs a response from the user label Aug 17, 2015
@saniyusuf
Copy link
Contributor Author

Yup @mhartington I think whats happening is the action being returned as a promise is happening way too fast for the $ionicLoading. Because asap I use a normal promise via a real http request which takes time it works cleanly.

@Ionitron Ionitron removed the needs: reply the issue needs a response from the user label Aug 17, 2015
@cesar-oyarzun-m
Copy link

Hi I have the same problem using cordova calls, if the call fails the $ionicLoading stay opens forever here is my code

$ionicLoading.show({
        templateUrl: 'progress-connecting.html',
        clickOutsideToClose: false,
        delay:100
  });
var promise = beaconService.readBeacon();
promise.then(function (beaconRead){
  $scope.beacon = beaconRead;
  $log.debug('BeaconCtr - got beacon details ' + JSON.stringify(beaconRead));
  $ionicLoading.hide();
}, function(err){
  $log.debug('BeaconCtrl - beacon read failed ' + err);
  $ionicLoading.hide();
  $scope.showAlert('Could not connect to this beacon!');
});

Only when the call fails and go to error the dialog doesn't close otherwise it get close

@lucasmendonca
Copy link

Same problem !
$ionicLoading.show({delay:100}) resolve my problem. Thanks @ffabreti.

@mhartington mhartington added the v1 label Jan 22, 2016
@aneeshatgit
Copy link

{delay: 100} indeed solved my problem too. Thanks.

danbucholtz added a commit that referenced this issue Apr 25, 2016
…deprecated object, update docum

make the loader service return a promise instead of the deprecated object, update documents to show
proper usage

#3717
@danbucholtz
Copy link
Contributor

All,

This issue should be fixed in the commit above. That commit will be merged into the nightly in the next day or so. Please re-open if the issue remains.

Thanks,
Dan

@pawan-mittal
Copy link

@ffabreti Thanks a lot. I was really struggling with this issue, but your solution saved my day.

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 4, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests