ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Sluggish performance on Android 4.4 - ion-slide-box with ng-repeat and content heavy slides - new nightly

Open olliekav opened this issue 12 years ago • 38 comments

I was hoping the new nightly would increase the performance of this but it seems no different. I'm generating 4 slides of news entires with ng-repeat. Each slide is quite content heavy in terms of HTML. The sliding and scrolling within each slide is really sluggish and stop/start on Android, to the point it feels horrible to use. Would adding the slides dynamically help this? Any other suggestions?

olliekav avatar Nov 18 '14 22:11 olliekav

I could add you as a collaborator on my app if that helps as not really useful creating a codepen.

olliekav avatar Nov 19 '14 02:11 olliekav

So out of interest I replaced the slide-box with angular-carousel (this has some bugs with position absolute and slide heights being 0, I hacked a height in) but the sliding and scroll on Android was very smooth. Not sure if that helps. That had ion-content still within each slide.

olliekav avatar Nov 19 '14 04:11 olliekav

@olliekav could you make me a collaborator on your app? I could clone it and try to debug.

ajoslin avatar Nov 19 '14 19:11 ajoslin

@ajoslin done! Ignore some of my interesting javascript coding, still getting my head around much of this and reformatting stuff as I go :)

olliekav avatar Nov 19 '14 19:11 olliekav

Actually, wait on cloning for 5min, just need to check this stuff in!

olliekav avatar Nov 19 '14 19:11 olliekav

Okay, all checked in. There is also a branch called 'angular-carousel' if you want to compare for performance.

olliekav avatar Nov 19 '14 19:11 olliekav

Cloning it now. Couldn't get to this yesterday.

ajoslin avatar Nov 20 '14 16:11 ajoslin

What's the organization? You can email me andrewtjoslin[at]gmail[dot].com if you don't want to post it publicly.

ajoslin avatar Nov 20 '14 16:11 ajoslin

https://github.com/thisiscapra Thanks for looking at this! I've added you the team assigned to it, you should have an invitation pending.

olliekav avatar Nov 20 '14 16:11 olliekav

Appreciate you are busy just wondered if you've had a chance to look at this? @ajoslin

olliekav avatar Nov 24 '14 16:11 olliekav

Well I've tried this now without the ng-repeat and reducing the number of angular bindings but it just seems to be the amount of HTML within the slide. I'm moving to angular-carousel for now as the client needs to see some progress. I'm dropping the ion-slide version into a branch called 'ion-slide'.

olliekav avatar Nov 27 '14 14:11 olliekav

I'm seeing sluggish performance with the nightly for Ionic and ngAnimate in general, and it appears that Ionic is the culprit - rolling back Angular did not fix this.

I'm seeing some animation tasks take ~160ms, which causes the animation to never happen as far as the user is concerned.

wesleycho avatar Nov 27 '14 19:11 wesleycho

The latest nightly build had another refactor of slide box .. performance should be much better now.

I've tested on Android 4.2, and will be testing on 4.0 today.

ajoslin avatar Dec 01 '14 17:12 ajoslin

Okay, thanks. I'll try it out! Would prefer to keep this all within Ionic.

olliekav avatar Dec 01 '14 18:12 olliekav

mmmm... not sure if I'm doing something else wrong, but I've changed back to my ion-slide code and now I'm getting '' when I use...

<ion-slide-box selected="activeSlide" on-slide-changed="onSlideChanged(index)" ng-class="$root.cls">
          <ion-slide ng-repeat="post in posts">
            <ng-include src="'post-' + post.name + '.html'"></ng-include>
          </ion-slide>
          <ion-slide-pager></ion-slide-pager>
        </ion-slide-box>

but when I just call just the post.name on its own within a slide to test it is being set...

<ion-slide-box selected="activeSlide" on-slide-changed="onSlideChanged(index)" ng-class="$root.cls">
          <ion-slide ng-repeat="post in posts">
            <p>Test {{post.name}}</p>
          </ion-slide>
          <ion-slide-pager></ion-slide-pager>
        </ion-slide-box>

The slides work fine, I've also tried using ng-include with a blank 'test-template.html' and the slide-box fails. I'll have more of a dig in my code but I'm not sure why it would fail on just an empty ng-include.

I'm not getting any console errors either.

olliekav avatar Dec 01 '14 19:12 olliekav

I'll test out ng include on my end. That sounds weird for sure. On Mon, Dec 1, 2014 at 12:03 Ollie Kavanagh [email protected] wrote:

mmmm... not sure if I'm doing something else wrong, but I've changed back to my ion-slide code and now I'm getting '' when I use...

but when I just call just the post.name on its own within a slide to test it is being set...

Test {{post.name}}

The slides work fine, I've also tried using ng-include with a blank 'test-template.html' and the slide-box fails. I'll have more of a dig in my code but I'm not sure why it would fail on just an empty ng-include.

— Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic/issues/2578#issuecomment-65116371.

ajoslin avatar Dec 01 '14 20:12 ajoslin

Can you try it with 3f33a3cd1ce50a46dadd60aa34724dade97f089f and see what happens?

On Mon Dec 01 2014 at 1:16:40 PM Andrew Joslin [email protected] wrote:

I'll test out ng include on my end. That sounds weird for sure. On Mon, Dec 1, 2014 at 12:03 Ollie Kavanagh [email protected] wrote:

mmmm... not sure if I'm doing something else wrong, but I've changed back to my ion-slide code and now I'm getting '' when I use...

but when I just call just the post.name on its own within a slide to test it is being set...

Test {{post.name}}

The slides work fine, I've also tried using ng-include with a blank 'test-template.html' and the slide-box fails. I'll have more of a dig in my code but I'm not sure why it would fail on just an empty ng-include.

— Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic/issues/2578#issuecomment-65116371.

ajoslin avatar Dec 01 '14 20:12 ajoslin

Yep, that worked. Although then the slides came back as 20px high and I had to add...

.slider-slides {
  height: 100%;
}

not sure if that is due to my variable height slides or not?

Just tested on Android and the performance is much improved. Noticed one bug...

  • The slide change finished event seems to fire about 1s after the slide has finished, so the slide-pager and for example my on-slide-changed function have a delay in updating the content. So if you try and swipe quickly (i.e. within that 1s hang) you get caught on a slide and it won't change.

EDIT:

Found another one as well, there used to be a really smooth animation from my index page through to the slides on the first initial click, now the page goes white, then then the slides load. Is that related to other code changes around the caching? As after the first load it works as expected.

olliekav avatar Dec 01 '14 20:12 olliekav

The slide changed event currently fires after the animation is completely done.

What's your use case exactly? I never downloaded your app.

Are you using the slide-changed event to generate more slides?

ajoslin avatar Dec 01 '14 21:12 ajoslin

On slide change I just update an image at the top of the slide to reflect the new title for the news item. e.g.

view-title="<img src='img/{{$root.cls}}.png' height='25' width='25'>"

Just feels like a noticeable delay now, I can find a way around that. I'll try playing with the animation speed.

I'm still struggling with swiping quickly though, it's definitely due to the amount of HTML in my slides as when I drop it down to an almost empty slide I can swipe back and forth instantly. Maybe I need to refactor my angular bindings. I'll let you know how I get on.

Still getting the first time load issue above. I can't create a copepen as it only happens on Android. I'm testing on 4.4 right now. It's a very noticeable white screen before the content loads. I'll try playing with my templates and cache and see if I can fix that my end.

Thanks for bearing with me on this, the animations are massively improved now on Android, just trying to get the same performance out of these last bits as I do with Angular Carousel.

olliekav avatar Dec 01 '14 21:12 olliekav