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: ion-spinner has memory leak #3583

Closed
realityfilter opened this issue Apr 22, 2015 · 14 comments
Closed

bug: ion-spinner has memory leak #3583

realityfilter opened this issue Apr 22, 2015 · 14 comments
Assignees
Milestone

Comments

@realityfilter
Copy link

Type: bug

Platform: all

# Problem 1:

The current implementation does not cleanup on the deletion of the scope. This leads to a memory leak. The spinning animation keeps on running even if the spinner is not in the dom anymore. The animation should be stopped when the scope gets destroyed. This degrades scrolling performance too.

Problem 2:

The spinner in combination with the infinite-scroll directive.

ion-infinite-scroll {
  ...

  .icon:before,
  .spinner{
    -webkit-transform: translate3d(0,0,0);
    transform: translate3d(0,0,0);
  }
  &:not(.active){
    .spinner,
    .icon:before{
      -webkit-transform: translate3d(-1000px,0,0);
      transform: translate3d(-1000px,0,0);
    }
  }
}

It is not sufficient to have the spinner translated out of view. (Why this solution was chosen instead of opacity?). The spinner is still getting animated and degrades scrolling performance on iOS devices a lot. Even if out of view.

@realityfilter realityfilter changed the title bug: ion-spinner has memory leak bug: ion-spinner has memory leak Apr 22, 2015
@mhartington mhartington self-assigned this Apr 22, 2015
@mhartington
Copy link
Contributor

Any way you could provide a demo of this?

@berndartmueller
Copy link

I can reproduce this bug with a blank ionic template and a simple ionicLoading statement -> http://forum.ionicframework.com/t/rc0-1-high-idle-cpu-usage-on-ios-7-iphone-4/19705

@krik
Copy link

krik commented May 8, 2015

If you don't rely on the spinner, here's a quick workaround for the memory leak:

$provide.decorator('ionInfiniteScrollDirective', function($delegate) {
    var directive = $delegate[0];
    directive.template = null;
    return $delegate;
});

@perrygovier
Copy link
Contributor

Ok, I've noticed a few issues around this and have tried to consolidate them. This looks like a big deal. Thanks everyone for chiming in and submitting issues about this.

@perrygovier perrygovier added this to the 1.0.1 milestone May 18, 2015
@mica16
Copy link

mica16 commented May 27, 2015

Hi,

Any news about this critical issue ?
Several users have uninstalled my app (in production) because of the CPU keeping running at 30% .... while the app is in background.
They still send me screens showing that Android alerts them about the heaviness of the application.

Thanks

@perrygovier
Copy link
Contributor

Digging in to this a bit more, setting display:none on the inactive spinner instead of moving it off screen significantly improves memory usage. Here's the instruments readout of the infinite scroll test when it starts with just two elements and infinite scrolls in a loop until it reaches the height of the initial page. The first is the current approach followed by display:none.

screen shot 2015-06-11 at 12 32 38 pm

screen shot 2015-06-11 at 12 33 41 pm

This will potentially cause a flicker on some devices. I'm going to re-evaluate across a range of devices bearing this significant memory impact in mind.

Stay tuned.

@mica16
Copy link

mica16 commented Jun 11, 2015

Interesting, I stay tuned :)

@perrygovier
Copy link
Contributor

fixed in 32da5cd
I'm going to take a look at loading too. Note, set the spinner to display:none when not in use. Spinners are cool, but they eat a lot of memory.

@mica16
Copy link

mica16 commented Jun 11, 2015

Will it be integrated in nightly build soon?

Thanks for the fix

@mica16
Copy link

mica16 commented Jun 16, 2015

Tested it and it works great, thanks ;)

@scripterkaran
Copy link

So, I tried this, And I have one question. Un-till I scroll down the list and reach the bottom. There are Layer Paints, which are always increasing even though the I am no where near to the end of my List.
screen shot 2015-06-26 at 4 56 54 pm

the ion-spinner.spinner.spinner-ios Element - is always increasing the Layer Paints

screen shot 2015-06-26 at 4 57 10 pm

Is this a bug? or Its a normal behaviour ?

Platform : iOS
Ionic: 1.0.0v (scss/_scaffolding.scss fix applied)

@mlynch
Copy link
Contributor

mlynch commented Dec 7, 2015

Should be fixed by: 9f341a8

@lazygabe
Copy link

Issue appears to be still present on v1.2.4, the spinner causes infinite amount of layers keeping CPU busy and draining battery, even if it's never shown.
Setting my refresher to spinner=none solves the problem.
image

@vascofernandes
Copy link

Still present in 1.2.4.
CPU. constantly at 40/50%

    <ion-refresher pulling-text="Refresh" on-refresh="vm.doRefresh()">
    </ion-refresher>

works fine if one adds spinner=none

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

10 participants