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

bug: White flash appearing when switching between tabs on Android

Open wonderdogone opened this issue 11 years ago • 121 comments

Type: bug

Platform: android 4.4 webview

when switching between tabs ONLY on Android platform, the app show a white flash. This is in 1.0.0 stable. Not using crosswalk. Forum post http://forum.ionicframework.com/t/white-flash-appearing-when-switching-between-tabs-on-android-in-1-0-0-stable/24774

wonderdogone avatar Jun 09 '15 08:06 wonderdogone

+1

princefr avatar Feb 04 '16 11:02 princefr

Its seems like issue with timeout

mitiaptest avatar Feb 04 '16 11:02 mitiaptest

the issue just vanished for me! the issue was related to the way i had built my tabs! make sure that you build it in the good way, navigation inside tabs too. take care about controllers parents ==> child

no more white flash

princefr avatar Feb 04 '16 23:02 princefr

@princefr could you plz elaborate?

ilyastam avatar Feb 07 '16 01:02 ilyastam

For iOS, I had to replace css[ionic.CSS.TRANSITION_DURATION] with css.WebkitTransition in ionic.bundle.js line 47715 and 47750

`// iOS Transitions // ----------------------- provider.transitions.views.ios = function(enteringEle, leavingEle, direction, shouldAnimate) {

function setStyles(ele, opacity, x, boxShadowOpacity) {
  var css = {};
  css.WebkitTransition = d.shouldAnimate ? '' : 0;
  css.opacity = opacity;
  if (boxShadowOpacity > -1) {
    css.boxShadow = '0 0 10px rgba(0,0,0,' + (d.shouldAnimate ? boxShadowOpacity * 0.45 : 0.3) + ')';
  }
  css[ionic.CSS.TRANSFORM] = 'translate3d(' + x + '%,0,0)';
  ionic.DomUtil.cachedStyles(ele, css);
}

var d = {
  run: function(step) {
    if (direction == 'forward') {
      setStyles(enteringEle, 1, (1 - step) * 99, 1 - step); // starting at 98% prevents a flicker
      setStyles(leavingEle, (1 - 0.1 * step), step * -33, -1);

    } else if (direction == 'back') {
      setStyles(enteringEle, (1 - 0.1 * (1 - step)), (1 - step) * -33, -1);
      setStyles(leavingEle, 1, step * 100, 1 - step);

    } else {
      // swap, enter, exit
      setStyles(enteringEle, 1, 0, -1);
      setStyles(leavingEle, 0, 0, -1);
    }
  },
  shouldAnimate: shouldAnimate && (direction == 'forward' || direction == 'back')
};

return d;

};

provider.transitions.navBar.ios = function(enteringHeaderBar, leavingHeaderBar, direction, shouldAnimate) {

function setStyles(ctrl, opacity, titleX, backTextX) {
  var css = {};
  css.WebkitTransition = d.shouldAnimate ? '' : '0ms';
  css.opacity = opacity === 1 ? '' : opacity;

  ctrl.setCss('buttons-left', css);
  ctrl.setCss('buttons-right', css);
  ctrl.setCss('back-button', css);

  css[ionic.CSS.TRANSFORM] = 'translate3d(' + backTextX + 'px,0,0)';
  ctrl.setCss('back-text', css);

  css[ionic.CSS.TRANSFORM] = 'translate3d(' + titleX + 'px,0,0)';
  ctrl.setCss('title', css);
}

function enter(ctrlA, ctrlB, step) {
  if (!ctrlA || !ctrlB) return;
  var titleX = (ctrlA.titleTextX() + ctrlA.titleWidth()) * (1 - step);
  var backTextX = (ctrlB && (ctrlB.titleTextX() - ctrlA.backButtonTextLeft()) * (1 - step)) || 0;
  setStyles(ctrlA, step, titleX, backTextX);
}

function leave(ctrlA, ctrlB, step) {
  if (!ctrlA || !ctrlB) return;
  var titleX = (-(ctrlA.titleTextX() - ctrlB.backButtonTextLeft()) - (ctrlA.titleLeftRight())) * step;
  setStyles(ctrlA, 1 - step, titleX, 0);
}

var d = {
  run: function(step) {
    var enteringHeaderCtrl = enteringHeaderBar.controller();
    var leavingHeaderCtrl = leavingHeaderBar && leavingHeaderBar.controller();
    if (d.direction == 'back') {
      leave(enteringHeaderCtrl, leavingHeaderCtrl, 1 - step);
      enter(leavingHeaderCtrl, enteringHeaderCtrl, 1 - step);
    } else {
      enter(enteringHeaderCtrl, leavingHeaderCtrl, step);
      leave(leavingHeaderCtrl, enteringHeaderCtrl, step);
    }
  },
  direction: direction,
  shouldAnimate: shouldAnimate && (direction == 'forward' || direction == 'back')
};

return d;

};`

casper123 avatar Feb 10 '16 11:02 casper123

Seems to be fixed for me when I changed this line https://github.com/driftyco/ionic/blob/master/js/angular/service/viewSwitcher.js#L142 to be:

callback && ionic.requestAnimationFrame(callback);

Not sure if it's a correct way to fix this though.

xibre avatar Feb 10 '16 15:02 xibre

Does this occur on some releases of iOS too (remembering that the report is on Android releases)?

From: Abdul Wahab [mailto:[email protected]] Sent: Wednesday, 10 February 2016 9:59 PM To: driftyco/ionic [email protected] Cc: David Lloyd [email protected] Subject: Re: [ionic] bug: White flash appearing when switching between tabs on Android (#3907)

For iOS, I had to replace css[ionic.CSS.TRANSITION_DURATION] with css.WebkitTransition in ionic.bundle.js line 47715 and 47750

`// iOS Transitions // ----------------------- provider.transitions.views.ios = function(enteringEle, leavingEle, direction, shouldAnimate) {

function setStyles(ele, opacity, x, boxShadowOpacity) { var css = {}; css.WebkitTransition = d.shouldAnimate ? '' : 0; css.opacity = opacity; if (boxShadowOpacity > -1) { css.boxShadow = '0 0 10px rgba(0,0,0,' + (d.shouldAnimate ? boxShadowOpacity * 0.45 : 0.3) + ')'; } css[ionic.CSS.TRANSFORM] = 'translate3d(' + x + '%,0,0)'; ionic.DomUtil.cachedStyles(ele, css); }

var d = { run: function(step) { if (direction == 'forward') { setStyles(enteringEle, 1, (1 - step) * 99, 1 - step); // starting at 98% prevents a flicker setStyles(leavingEle, (1 - 0.1 * step), step * -33, -1);

} else if (direction == 'back') {
  setStyles(enteringEle, (1 - 0.1 * (1 - step)), (1 - step) * -33, -1);
  setStyles(leavingEle, 1, step * 100, 1 - step);

} else {
  // swap, enter, exit
  setStyles(enteringEle, 1, 0, -1);
  setStyles(leavingEle, 0, 0, -1);
}

}, shouldAnimate: shouldAnimate && (direction == 'forward' || direction == 'back') };

return d;

};

provider.transitions.navBar.ios = function(enteringHeaderBar, leavingHeaderBar, direction, shouldAnimate) {

function setStyles(ctrl, opacity, titleX, backTextX) { var css = {}; css.WebkitTransition = d.shouldAnimate ? '' : '0ms'; css.opacity = opacity === 1 ? '' : opacity;

ctrl.setCss('buttons-left', css); ctrl.setCss('buttons-right', css); ctrl.setCss('back-button', css);

css[ionic.CSS.TRANSFORM] = 'translate3d(' + backTextX + 'px,0,0)'; ctrl.setCss('back-text', css);

css[ionic.CSS.TRANSFORM] = 'translate3d(' + titleX + 'px,0,0)'; ctrl.setCss('title', css); }

function enter(ctrlA, ctrlB, step) { if (!ctrlA || !ctrlB) return; var titleX = (ctrlA.titleTextX() + ctrlA.titleWidth()) * (1 - step); var backTextX = (ctrlB && (ctrlB.titleTextX() - ctrlA.backButtonTextLeft()) * (1 - step)) || 0; setStyles(ctrlA, step, titleX, backTextX); }

function leave(ctrlA, ctrlB, step) { if (!ctrlA || !ctrlB) return; var titleX = (-(ctrlA.titleTextX() - ctrlB.backButtonTextLeft()) - (ctrlA.titleLeftRight())) * step; setStyles(ctrlA, 1 - step, titleX, 0); }

var d = { run: function(step) { var enteringHeaderCtrl = enteringHeaderBar.controller(); var leavingHeaderCtrl = leavingHeaderBar && leavingHeaderBar.controller(); if (d.direction == 'back') { leave(enteringHeaderCtrl, leavingHeaderCtrl, 1 - step); enter(leavingHeaderCtrl, enteringHeaderCtrl, 1 - step); } else { enter(enteringHeaderCtrl, leavingHeaderCtrl, step); leave(leavingHeaderCtrl, enteringHeaderCtrl, step); } }, direction: direction, shouldAnimate: shouldAnimate && (direction == 'forward' || direction == 'back') };

return d;

};`

— Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic/issues/3907#issuecomment-182324500 . https://github.com/notifications/beacon/ABHsBD1Sp3tXsq8707UTfdVHgqSlxI0zks5pixaSgaJpZM4E82pl.gif

lloy0076 avatar Feb 10 '16 21:02 lloy0076

+1 flashes on android..

AhsanAyaz avatar Feb 11 '16 19:02 AhsanAyaz

1+

pavei avatar Feb 12 '16 23:02 pavei

+1

brentoneill avatar Feb 13 '16 15:02 brentoneill

guys just "cache : true" in your "state" so that your page been cached before extract and rendering goes smoothly

Harish-here avatar Feb 15 '16 06:02 Harish-here

@Harish-here What about first time ?

mitiaptest avatar Feb 15 '16 07:02 mitiaptest

Yeah, it is really not a good idea to use cache: true only for these purpose

tgensol avatar Feb 15 '16 09:02 tgensol

@Harish-here . . I have an app that uses the same state for different pages. I.e. it is a detail view which takes some $state params. Since its the same view with different content, I can't use cache:false :) And it doesn't seem to be a good idea for this particular problem either

AhsanAyaz avatar Feb 15 '16 09:02 AhsanAyaz

Still the same problem here running 1.2.4-nightly-1917

robroy07 avatar Feb 25 '16 12:02 robroy07

+1

alexissusset avatar Feb 27 '16 22:02 alexissusset

@princefr - yes, please elaborate on what the proper markup would be for the tabs to alleviate this issue

brentoneill avatar Mar 03 '16 21:03 brentoneill

@princefr please if you can elaborate on the tab structure

saqueib avatar Mar 16 '16 14:03 saqueib

This is still an issue for me and quite frustrating. Is there any movement, or any understood resolution?

joelbowen avatar Mar 22 '16 20:03 joelbowen

+1

alysdal avatar Mar 22 '16 20:03 alysdal