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

How many slides are you initially loading at once? It may just be the initial DOM compile time that's lagging you down.

The reason we can't virtualize the DOM like in collection repeat is because slides could be arranged in any of a million ways... For example:

<ion-slide-box>
  <ion-slide ng-if="something">Hello</ion-slide>
  <ion-slide ng-repeat="abc in items"></ion-slide>
  <ion-slide>Always here</ion-slide>
  <div ng-if="bananas">
    <ion-slide ng-if="monkeys">Monkeys?</ion-slide>
    <ion-slide>Whatever.</ion-slide>
  </div>
</ion-slide-box>

Also, I'm going to add an on-slide event which will fire when an animation starts.

ajoslin avatar Dec 01 '14 22:12 ajoslin

I'm loading 4, it must be that compile time. I'll need to try and refactor I guess. That on-slide event sounds handy.

olliekav avatar Dec 01 '14 22:12 olliekav

Only four slides should be fine. How long of a delay are you talking about?

On Mon Dec 01 2014 at 3:07:21 PM Ollie Kavanagh [email protected] wrote:

I'm loading 4, it must be that compile time. I'll need to try and refactor I guess. That on-slide event sounds handy.

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

ajoslin avatar Dec 01 '14 22:12 ajoslin

At least a second, coupled with the white screen. I get the same delay with Angular Carousel, but a smoother page load and no white flash so it doesn't feel as odd. I'm trying to debug it but I can't work out why it's happening. Even if I remove the setting of the active slide for both it still happens so must be the initial compile of the respective carousels. I'll see if I can get you some more information.

olliekav avatar Dec 01 '14 22:12 olliekav

How complicated are your carousels? Is there something else huge being loaded?

ajoslin avatar Dec 01 '14 22:12 ajoslin

The new slidebox introduces breaking changes for me - I have a simple set of ion-slide elements that get generated dynamically according to how many images I get back from the server, and use an image per slide. I had the ion-slide elements set to display: flex and did some vertical and horizontal alignment via flexbox attributes - the change to display: inline-block caused a lot of havoc, and it is looking quite difficult to get this fixed.

I can either work with the inline-block elements and hack together a fix that does not have vertical alignment, or I can use flexbox and have weird behavior where every slide after the second one flashes into the first slide displayed even though the correct slide is seen. :(

wesleycho avatar Dec 01 '14 22:12 wesleycho

It's mostly text HTML content, one image. It's all JSON which I load through a service. We do run through a fair amount of conditions to show the content, mainly ng-if on blocks just to check if the value exists. I'll try some refactoring and see if I get any improvements.

olliekav avatar Dec 01 '14 22:12 olliekav

@wesleycho I made the selector for display less specific and used display: block.

Try setting your selectors to this:

.slider-slide[slide-display='selected'] {
  display: flex;
  align-items: center;
  justify-content: center;
}

ajoslin avatar Dec 01 '14 23:12 ajoslin

OK, nevermind. @wesleycho Try the nightly build with your current CSS and it should work now.

It now sets display: none !important if the slide is hidden. Otherwise it will default to block, but it's a very easily overridable selector (tag-level, not class-level).

I added the !important flag because it lets the end-developer specify displays for slides as specifically as he wants, but still not show the slides that should be hidden.

ajoslin avatar Dec 01 '14 23:12 ajoslin

@olliekav on-slide-start is up. http://ionicframework.com/docs/nightly/api/directive/ionSlideBox/

ajoslin avatar Dec 01 '14 23:12 ajoslin

I ended up coming up with a similar fix, although I also set next and previous to display: flex as well.

      ion-slide {
        display: none;
        &[slide-display="selected"], &[slide-display="next"], &[slide-display="previous"] {
          display: flex;
        }
      }

wesleycho avatar Dec 01 '14 23:12 wesleycho

If you get rid of that, you should just be able to do:

ion-slide {
  display: flex;
}

Because internally, we now do:

ion-slide {
  &:not([slide-display]) {
    display: none !important;
  }
}

ajoslin avatar Dec 01 '14 23:12 ajoslin

Hi,

I also ran into this performance issue. I can confirm that the latest (nightly) build solved it. Great work guys!!

--dre

mobilabgit avatar Dec 03 '14 11:12 mobilabgit

btw I tested my app on a iphone 3

mobilabgit avatar Dec 03 '14 11:12 mobilabgit

Awesome! Closing this.

ajoslin avatar Dec 04 '14 20:12 ajoslin

I'm not sure if I should open a new ticket, but it seems to be related. With around 200 slides (using ng-repeat) of simple text content, the compile time is unbearable. I also have to trigger $ionicSlideBoxDelegate.update(); after another 1 or 2 seconds otherwise my content won't render properly (it is in a very narrow block to the very left, before it jumps into place after $ionicSlideBoxDelegate.update(); is called).

johannesjo avatar Dec 27 '14 04:12 johannesjo

@ajoslin Just curious why the latest versions dropped this method...

ion-slide {
  &:not([slide-display]) {
    display: none !important;
  }
}

Seems its been left behind in favor of using translates. I think it was faster before. when you were hiding all but the 3 (prev, curr, next). [slide-display] is gone.

travisdahl avatar Mar 10 '15 05:03 travisdahl

Same issue with the rc-0 for me. (cc @johannesjo)

I'm wondering if we could have a callback on $ionicSlideBoxDelegate.update();?

florentsuc avatar Mar 13 '15 12:03 florentsuc

Florent

http://nmr.co.ke/schet_roboforex

13.03.2015, 15:17, "Florent Suc" [email protected]:Same issue with the rc-0 for me. (cc )

I'm wondering if we could have a callback on $ionicSlideBoxDelegate.update();?

—Reply to this email directly or .

Fayozjon avatar Mar 25 '15 07:03 Fayozjon