Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splashscreen leaves semi-transparent white overlay after hiding #188

Closed
3 tasks done
distinctdan opened this issue Mar 28, 2019 · 18 comments · Fixed by #337
Closed
3 tasks done

Splashscreen leaves semi-transparent white overlay after hiding #188

distinctdan opened this issue Mar 28, 2019 · 18 comments · Fixed by #337

Comments

@distinctdan
Copy link
Contributor

Problem

The splashscreen is hiding correctly, but after it hides, it leaves behind a transparent white overlay that is making all my colors look ugly and washed out. Here are some screenshots of no splashscreen and with splashscreen:

No splashscreen plugin:
Screenshot_20190328-165749

With splashscreen plugin:
Screenshot_20190328-165858

Environment, Platform, Device

Here is my splashscreen config lines:

    <preference name="Fullscreen" value="true" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="SplashScreenDelay" value="10000" />
    <preference name="SplashShowOnlyFirstTime" value="false" />
    <preference name="ShowSplashScreenSpinner" value="false" />
    <preference name="AutoHideSplashScreen" value="false" />

I'm hiding it with navigator.splashscreen.hide(); after deviceready fires.

Version information

OS: Android 8.1.0
Cordova-CLI: 9.0.0
Cordova android platform: 8.0.0
Cordova-plugin-splashscreen: 5.0.2

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@janpio
Copy link
Member

janpio commented May 5, 2019

Did you remote inspect your app's webview to debug and understand what is giving your app this semi-transparent white look? https://ionic.zone/debug/remote-debug-your-app#android-remote-debugging-with-chrome should work.

@distinctdan
Copy link
Contributor Author

I haven't, I had assumed the splashscreen plugin only did native stuff and didn't touch the html. Are you saying it does DOM stuff too?

@janpio
Copy link
Member

janpio commented May 7, 2019

Not usually, but excluding any side effects in the web app would be a good first step - just to make sure before we dive deeper into what is going on.
Can you create two debug APKs of your app to look at maybe?

@distinctdan
Copy link
Contributor Author

So I'm not willing to upload APK's because I don't want my app's source getting out yet, but I did look into it a bit more. I remote debugged the html and confirmed the problem isn't on the DOM side. Even after deleting all the html through the chrome html inspector, the grey overlay was still there.

However, I found something interesting: the problem only happens when I build using the cordova command line using cordova run android --device. If I run the app using android studio instead, the problem doesn't happen. I'm not sure why it would be different when building on the command line.

@janpio
Copy link
Member

janpio commented May 9, 2019

Is this reproducible in a new, plain Cordova app? A minimal reproduction repository would really help to debug and later fix this issue. More information on how to create one: https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md

@distinctdan
Copy link
Contributor Author

Gotcha, I'll see if I can repro it in a new repository.

@distinctdan
Copy link
Contributor Author

Alright, here ya go: the problem happens in a vanilla repo; the only changes I made were to make the background black so you can see the issue: https://github.com/distinctdan/cordova-splashscreen-overlay-bug

The problem only happens when running from the command line. Here are screenshots of command line vs android studio:
Screenshot_20190509-132610
Screenshot_20190509-132915

@janpio
Copy link
Member

janpio commented May 9, 2019

Interesting, I can't reproduce this locally with your repo - I see full black background both with CLI and Android Studio build (Nexus 5, Android 6.0.1).

You might try the Android Layout Inspector with both builds of your app (maybe first build one with another package ID, so you can have them both installed at the same time): https://developer.android.com/studio/debug/layout-inspector Looks like this for me:
image

@distinctdan
Copy link
Contributor Author

That's very interesting that it doesn't happen for you. I'm testing on a Nexus 5x running Android 8.1.0. Since you're testing on 6.0.1, it's possible it could only happen for newer versions of android. I was able to open both layouts in the layout inspector, but they were almost completely identical. I check all the properties, and the only difference were the mPrivateFlags properties of the id/content views and the webviews. The property changed between runs also, so I'm not sure what it is or if it's significant.

@janpio
Copy link
Member

janpio commented May 9, 2019

Do you only experience this on one device, or on multiple ones?

@distinctdan
Copy link
Contributor Author

Not sure, my phone is unfortunately my only android device for now. The issue doesn't happen on the simulator.

@distinctdan
Copy link
Contributor Author

This issue appears to have been fixed for me on the latest cordova-android version of 8.1.0. I suspect this focus PR might have been the fix: apache/cordova-android#750.

@distinctdan
Copy link
Contributor Author

Turns out I was wrong, this issue still happens the first time I deploy the app to my device from android studio.

@distinctdan distinctdan reopened this Oct 17, 2019
@evoactivity
Copy link

I'm seeing this on a customers device. I can't replicate the issue myself on any device I've tested, or emulator/simulator.

@distinctdan I understand this is an old issue but I'm hoping you found a way to mitigate this problem?

@evoactivity
Copy link

I've been able to replicate this issue in an emulator.

In android studio create a new device for a Nexus 5x with the Oreo framework API 27 and run the app, you should see it happen the first time the app is run. I can only trigger it again if I close the emulator and compltely wipe the data for it. I see the white overlay breifly, Android shows a dialog explaining the app is fullscreen, which seems to remove it, and then when you click ok the white overlay appears again for the lifetime of the app.

When the issue is visible I see nothing in the layout inspector that I think would cause it, but I'm not a native android developer so I could be missing something.

I thought it may be related to

cordova.getActivity().runOnUiThread(new Runnable() {
    @Override
    public void run() {
        getView().setVisibility(View.INVISIBLE);
    }
});

but commenting this out doesn't seem to have any affect. I actually don't understand how the webView regains it's visibility.

I'm a bit lost of what could possibly be causing this.

@evoactivity
Copy link

So I tried recreating again using the same emulator and the reproduction repo provided by @distinctdan. Running from cordova run android reliably recreates the issue with this emulator setup, I don't need to wipe the device for it to occur.

When I run with this code left as is

cordova.getActivity().runOnUiThread(new Runnable() {
    @Override
    public void run() {
        getView().setVisibility(View.INVISIBLE);
    }
});

The white overlay appears reliably. When I comment it out and run again, the white overlay does not appear and I do not see any side effects of this code not running? @janpio what is the purpose of setting the webview to be invisible and how does the view regain visibility?

@distinctdan any chance you could confirm commenting out that code from SplashScreen.java fixes the issue?

@evoactivity
Copy link

Just had confirmation from my client that the white overlay no longer displays on their devices with that code commented out.

@distinctdan
Copy link
Contributor Author

@evoactivity Unfortunately, I never found a fix. I suspect it could be a bug in Android. I just lived with it because it only happened on the first run. I'm not that familiar at the moment with the splashscreen internals, but I believe that section is to hide the webview while it's loading. Presumably since you're showing a splashscreen, you don't want the webview visible yet. It's possible that the splashscreen might take a small delay to load, and it goes on top of the webview, so I think that line prevents the webview from possibly briefly showing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants