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

[Android] overlaysWebView(true) doesn't work as expected when called in deviceready event #158

Open
3 tasks done
breautek opened this issue Oct 2, 2019 · 7 comments
Open
3 tasks done

Comments

@breautek
Copy link
Contributor

breautek commented Oct 2, 2019

Bug Report

Problem

Statusbar doesn't go into overlaymode when using overlaysWebView(true) when called inside the deviceready callback.

What is expected to happen?

The statusbar should go into overlay mode.

What does actually happen?

The statusbar stays in solid.

Information

I've provided a reproduction app available at https://github.com/breautek/statusbar-overlay-issue

I simply call StatusBar.overlaysWebView(true), however the statusbar remains a solid black colour.

If I open up the dev tools, and call StatusBar.overlaysWebView(true) again via the javascript console, it still doesn't work.

In the console, if I do:

StatusBar.overlaysWebView(false);
StatusBar.overlaysWebView(true);

Then the statusbar finally goes into the overlay state.

Additionally, if I comment out the StatusBar.overlaysWebView(true); line in deviceready and launch the app. Then call StatusBar.overlaysWebView(true); in the console, the statusbar does go into overlay mode the first time. Surrounding StatusBar.overlaysWebView(true); also works the first time in deviceready IF I surround the statement in a setTimeout of 1 second.

Occassionally the code in the reproduction app works as expected as is the first time. This suggests there is a race condition at play here.

Original discovery of this bug was found at #155 (comment)

Command or Code

Environment, Platform, Device

Observed on Android 6 & Android 9, cordova-android 8.1.0
Cordova 9

Version information

Checklist

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

mosabab commented Oct 30, 2019

This problem still not solved !

@breautek
Copy link
Contributor Author

Any help to investigate this issue or PRs would be greatly appreciated.

@breautek
Copy link
Contributor Author

In my testing, if you apply the PR #171 and set the overlay via config.xml preference, it appears to reliability set the statusbar properly.

I still haven't determined the cause of the statusbar not working properly when using the JS api on the deviceready event. Logging out information shows that the view state is all proper, even though visually the statusbar does not update.

@yxk0909

This comment has been minimized.

@SchnWalter
Copy link

SchnWalter commented May 11, 2020

@breautek, related, to your comment #172 (comment); I'm not sure if it's the same issue.

The page is rendered properly, but then immediately, the WebView height is increased by the size of the statusbar and we see the map being resized to fit the new viewport. And this doesn't happen at the application startup, we change the overlaysWebView only when we navigate into the map page, so the layout is already stable before we change the overlay.

@ahmedelatab
Copy link

ahmedelatab commented Oct 15, 2020

Follow this approach to overcome the bug in the StatusBar plugin:

statusBar.overlaysWebView(false);
statusBar.overlaysWebView(true);

setTimeout(() => {
  statusBar.overlaysWebView(false);
  statusBar.overlaysWebView(true);
}, 80);

Reverse the logic to prevent the status bar fro overlaying the web view.

@erophames
Copy link

@breautek, related, to your comment #172 (comment); I'm not sure if it's the same issue.

The page is rendered properly, but then immediately, the WebView height is increased by the size of the statusbar and we see the map being resized to fit the new viewport. And this doesn't happen at the application startup, we change the overlaysWebView only when we navigate into the map page, so the layout is already stable before we change the overlay.

Were you ever able to fix this issue? I am currently seeing this on my app.

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

No branches or pull requests

6 participants