ionic-framework: bug: iOS white screen after keyboard show (in v1.2.1 and v1.2.0 only)

Type: <span ionic-type>bug</span>

Platform: <span ionic-platform>ios</span> <span ionic-platform-version>8</span> <span ionic-webview>webview</span>

<span ionic-description>

Hi,

The bug is reproducible with latest ionic releases 1.2.1 and 1.2.0, but not with 1.1.1. In 1.1.1 it works fine.

On iOS, when I tap on some html input:

  • The keyboard is shown - OK: photo 22-12-2015 14 23 14
  • I can enter some text and select another inputs (but without closing the keyboard dialog) - OK photo 22-12-2015 14 24 06
  • Once the keyboard is closed (either with Done button or just by tapping to non-input space) - the inputs with their labels become white, but I can still type into inputs with white font - so it looks like white screen which overlays the content. photo 22-12-2015 14 24 51 photo 22-12-2015 14 24 55

Code example:

<ion-view view-title="Log In" can-swipe-back="false" hide-back-button="true">
  <ion-content padding="true" has-bouncing="false">
    <form ng-submit="vm.loginFormAction(vm.loginFormData)" novalidate>
      <div class="list">
        <label class="item item-input item-floating-label">
          <span class="input-label">Username</span>
          <input ng-model="vm.loginFormData.username" type="text" placeholder="Email or Phone number">
        </label>
        <label class="item item-input item-floating-label">
          <span class="input-label">Password</span>
          <input ng-model="vm.loginFormData.password" type="password" placeholder="Password">
        </label>
      </div>
      <div class="padding">
        <button class="button button-block button-positive" type="submit">Log In</button>
      </div>
    </form>
  </ion-content>
</ion-view>

also I’ve tried with the new ion-input directive:

<ion-view view-title="Log In" can-swipe-back="false" hide-back-button="true">
  <ion-content padding="true" has-bouncing="false">
    <form ng-submit="vm.loginFormAction(vm.loginFormData)" novalidate>
      <div class="list">
        <ion-input class="item item-input item-floating-label">
          <ion-label>Username</ion-label>
          <input ng-model="vm.loginFormData.username" type="text" placeholder="Email or Phone number">
        </ion-input>
        <ion-input class="item item-input item-floating-label">
          <ion-label>Password</ion-label>
          <input ng-model="vm.loginFormData.password" type="password" placeholder="Password">
        </ion-input>
      </div>
      <div class="padding">
        <button class="button button-block button-positive" type="submit">Log In</button>
      </div>
    </form>
  </ion-content>
</ion-view>

ionic info

Your system information:

Cordova CLI: 5.4.1
Gulp version:  CLI version 3.9.0
Gulp local:   Local version 3.9.0
Ionic Version: 1.2.1-nightly-1867
Ionic CLI Version: 1.7.12
Ionic App Lib Version: 0.6.5
OS: Distributor ID: Ubuntu Description: Ubuntu 14.04 LTS 
Node Version: v5.0.0

ionic platform ls

Updated the hooks directory to have execute permissions
Installed platforms: android 5.0.0, ios 3.9.2
Available platforms: amazon-fireos, blackberry10, browser, firefoxos, ubuntu, webos

config.xml

  <preference name="HideKeyboardFormAccessoryBar" value="false"/>
  <preference name="KeyboardDisplayRequiresUserAction" value="false"/>
  <preference name="SuppressesLongPressGesture" value="true"/>

  <plugin name="ionic-plugin-keyboard" spec="1.0.8"/>

bower.json

"ionic": "driftyco/ionic-bower#1.2.1"
"ionic-platform-web-client": "0.2.1"
</span>

<span is-issue-template></span>

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 78 (6 by maintainers)

Commits related to this issue

Most upvoted comments

+1 in iOS 9.2 / iPhone 6s Temporary solved by replacing <ion-content> with <ion-scroll>

<ion-scroll direction="y" style="right: 0;bottom: 0;left: 0;position: absolute;" class="has-header has-subheader">

Bug is definitely still in ionic 1.3.

I didn’t want to have to set overflow-scroll false on all my ion-content elements or use the ionicConfigProvider to disable native scroll (since js scrolling has other issues), so I just added back this snippet of css that was removed in 1.3.0 https://github.com/driftyco/ionic/commit/aec6598d:

.overflow-scroll {
  &.keyboard-up:not(.keyboard-up-confirm) {
    overflow: hidden;
  }
}

After long nightmares, in version 1.3.1, adding overflow-scroll="false" to <ion-content> elements fixed almost all my problems.

using ion-scroll instead of ion-content solve the problem

I did a workaround that worked for me:

CSS:

.platform-ios div.scroll {
    height: 101%;
}

View: <ion-content scrollbar-y="false">

Seems like <ion-content> needs his content to overflow. I inserted a lot of <p>Lorem Ipsum</p>, then I cleared the CSS rule and everything works fine, because the <p> sequence causes the content overflow.

Bug still exists in Ionic 1.3.2 for iOS 9 and 10, Android is working good.

Does this work?

<ion-content has-bouncing="false" scroll="false">

Glad to hear that, @lucasarts321 😃

Still having this issue using ion-content and ionic 1.3, iOs 9.2 on an iPhone 6

I had this issue with native scrolling and found that it was limiting the height of the ion-content whenever the keyboard was up. This caused my view to appear truncated (half blank) unless you close the keyboard. I solved it by force setting the height to auto. Hope this helps.

.keyboard-up{
  height: auto !important;
}

From my research it looks that all of this related with the keyboard transition. When elements have absolute positioning and -webkit-transform: translate3d(0,0,0); set while keyboard is animated the z-index gets messed up. Transform is used to kick the GPU for transitions. For more info look here: here. By removing transform everything works as expected.

I’ve figured out that in the case of our app, what was triggering this behaviour was a swipe gesture, so adding $ionicConfigProvider.views.swipeBackEnabled(false); solved for us.

This bug still exists on iOS 10.2+ and ionic 1.3.2, when using Native scrolling (overflow-scroll set to true, or JS Scrolling globally disabled).

Here’s my almost-workaround, inspired by @nstokoe 's suggestion:

.overflow-scroll {
  &.keyboard-up:not(.keyboard-up-confirm) {
    -webkit-overflow-scrolling: auto;
  }
}

It solves the issue, the same way, but does not “block” scrolling (overflow: hidden does prevent from scrolling). To be more specific, the user can scroll if he does not touch a keyboard inputs when he starts the gesture.

In scrollViewNative.js (ionic v1), you can see this at two different places (keyboard opening and keyboard closing):

              /*
              if (ionic.Platform.isIOS()) {
                // Force redraw to avoid disappearing content
                var disp = container.style.display;
                container.style.display = 'none';
                var trick = container.offsetHeight;
                container.style.display = disp;
              }
              */

I assume it has been left commented/unused because this bug can still cause Crashes, even if forced-redrawing almost “hides” it (yet it does not avoid flickering 😄). I didn’t have a look at the keyboard plugin code, but I guess that something is wrong inside, if it can lead the app to crash.

The white screen comes from a css redraw issue apparently.

We have found a quick workaround: we have created a directive that forces the browser to redraw the ion-content element every 30ms.

Here is the directive:

var app = angular.module('myapp');
app.directive('keyboardCssRedraw', function($interval){
    return {
        restrict: 'A',
        link: link
    };

    function link(scope, element, attrs) {
        var interval = setInterval(function(){
            redraw(element[0]);
        }, 30);
        scope.$on('$destroy', function(){
            clearInterval(interval);
        });
    }

    // force redraw
    function redraw(element) {
        element.style.zIndex = 1;
        element.offsetHeight;
        element.style.zIndex = '';
    }
});

Apply directive:

<ion-content keyboard-css-redraw>

This solution is a bit dirty as we constantly redraw the element. As it seems we have tackle the issue, it would be great if some ionic expert could help rewriting this code in a proper “ionic/angular” way 😃

Is there a fix for the white screen issue? I still see it with this configuration:

ionic —version: 1.7.14 ionic.version: 1.2.4-nightly-1917 iOS: 9.2.1 I am using the ionic keyboard plugin

View Hierarchy ion-nav-view ion-view ion-content (overflow-scroll=“true”) ion-scroll

When the keyboard is up, and the user does any scrolling, then dismisses the keyboard, the whole ion-view goes white until the user taps again.

If I use this view structure:

ion-nav-view ion-view ion-content (no overflow-scroll) ion-scroll

Then when an input gains focus the entire nav view jumps down and then back up. The screen going white, on the other hand, no longer happens.

Had this issue as well. Converted ion-content to an ion-scroll and it fixed the issue. Thank you @Lsozke.

I’ve also noticed that the content pops back if you toggle any CSS property within the developer tools. It seems to be some kind of repaint issue.

@mohanchalla I had the same problem. If you add

height: 100% to scroll-view.scroll-y classes

The white part at the bottom should go away.

I had the same. Reproducible in IOS Simulator iPhone 5s with IOS 9.2, but not with iPhone 6. Temporary workaround is to set overflow-scroll to false on ion-content.