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

@didbarbosa - Actually I just noticed that my version of Ionic isn't the latest release; thus I changed my "bower.json" to read:

{ "name": "HelloIonic", "private": "true", "devDependencies": { "ionic": "driftyco/ionic-bower#~1", "platform.js": "platform#~1.3.0"

...and would you believe it theres no flickering even without the $timeout solution...

Maybe if you tried the same with the CSS transition solution it might just "fix" itself - although I hate problems that magically fix themselves like that.

lloy0076 avatar Sep 25 '15 12:09 lloy0076

Yes it seems to be disapeared with the nightly release. Good news :)

didbarbosa avatar Sep 25 '15 13:09 didbarbosa

Actually it is not fixed for me.

didbarbosa avatar Sep 25 '15 13:09 didbarbosa

not fixed for me 2 :\

hadarge avatar Sep 26 '15 11:09 hadarge

Any news about this issue?

rollback91 avatar Oct 06 '15 13:10 rollback91

I have this issue on iOS as well.

harryzun avatar Oct 07 '15 06:10 harryzun

@harryzun regarding iOS please see https://github.com/driftyco/ionic/issues/4395

simplesmiler avatar Oct 07 '15 17:10 simplesmiler

On iOS it's not the same issue

Zorgatone avatar Oct 09 '15 07:10 Zorgatone

I just started noticing this on Android too sometime after I upgraded to v1.1. Not sure when it started though.

gentlemanjohn avatar Oct 13 '15 15:10 gentlemanjohn

it started around v1

wonderdogone avatar Oct 14 '15 10:10 wonderdogone

If anyone has a (temporary) fix, I would love to hear it.

arenddeboer avatar Oct 25 '15 17:10 arenddeboer

I'm the same bug... anybody have more info?? :octopus:

capellmarcos avatar Oct 29 '15 22:10 capellmarcos

Probably not related, but I had a similar issue earlier, and for some bizarre reason deleting cache: false from my state definition for the offending sibling tab state cleared the issue. I have zero idea why, as we're using this same pattern, with the same controller+template combo, in 3 other places in our tab setup with out any issue.

update

So I just spent a little bit of time trying to get down to the bottom of the issue we saw, kinda interesting and a little bit of naivety on my part lead to the flicker of black prior to stateChangeSuccess.

So as mentioned above, we use the same pattern all over our application, but with one key difference: this state actually had a API backed resolve in its state definition to get around a shortcoming we currently have on our back end that we didn't need to be accounted for with the other x3 states that use this pattern.

The "chat" state was a sibling of main the state for the tab. To reach this state you'd simply click on a member in the main view and you'd end up in the sibling chat state. When navigating into it from the sibling, no black flash was observed, the main state would be visible until the resolve had finished, and then normal navigation would finish. When navigating back to the tab (from another tab) with the chat view as the current state in history, ui-router + ionic would execute the swap to the new tab immediately, but the black screen would be visible until the resolve had been completed.

This also makes sense as to why removing cache: false and defaulting to true fixed the issue.

Makes perfect sense when you think about it I guess. Hopefully this might be able to save someone a headache if they stumble upon this via google (same way I did).

EnSabanNur avatar Nov 03 '15 01:11 EnSabanNur

I tracked this down to this line: https://github.com/driftyco/ionic/blob/af1bfef327e685585244c6051c4d38b98aa6c62a/js/angular/service/viewSwitcher.js#L194

          if (renderStart && renderEnd) {
            // CSS "auto" transitioned, not manually transitioned
            // wait a frame so the styles apply before auto transitioning
            //$timeout(onReflow, 16); <- original
            onReflow(); // removes flicker
          } else if (!renderEnd) {

It's the cause for the one frame flicker when tabs are switched, because the new tab is not set to visible until 16 ms later.

I'm not sure what the point of that line is when tabs are involved, but if you replace the $timeout call with a simple method call of onReflow(), perceived performance is greatly improved and there is no more flicker. Not even in the nav bar.

@mhartington any thoughts regarding this? Perhaps it should be made configurable at the very least.

Seems to be introduced by https://github.com/driftyco/ionic/commit/8ebde73d0b8afac1bf1c1787c90a72a28a88bc3a from @adamdbradley

Edit: a better fix seems to be to just change the if condition to:

if (direction !== 'swap' && renderStart && renderEnd) {

Edit2: An even better fix that gets rid of any potential side effects is to replace the $timeout call with: ionic.requestAnimationFrame(onReflow); I will send a PR with it.

andreialecu avatar Nov 21 '15 15:11 andreialecu

Opened PR https://github.com/driftyco/ionic/pull/4654

andreialecu avatar Nov 21 '15 17:11 andreialecu

Very well done! Fixes the issue to me.

Thanks a lot mate.

didbarbosa avatar Nov 21 '15 17:11 didbarbosa

Didn't work for me... I've updated my ionic-angular.js file but I see no change even if I'm increasing the initial timeout value. Am I missing something? For the nav bar flickering I used this fix https://forum.ionicframework.com/t/flickering-when-navigating-via-tabs-on-android/27281 but now content is it flickering.

AdrienDC avatar Dec 01 '15 03:12 AdrienDC

Finally it's working but it's still flickering once the first time for each tab, any idea why?

AdrienDC avatar Dec 01 '15 09:12 AdrienDC

Is there any release plan on this issue? 1.2 or 1.3 ?

fdu-axiometrics avatar Dec 10 '15 16:12 fdu-axiometrics

It's included in the recent 1.2 release.

ghost avatar Dec 10 '15 20:12 ghost