openhab-android icon indicating copy to clipboard operation
openhab-android copied to clipboard

White flash before UI loads

Open PMunch opened this issue 2 years ago • 5 comments

Probably related to https://github.com/openhab/openhab-android/issues/2583.

Actual behaviour

When opening the app it briefly flashes white before showing the dark mode UI of my dashboard. This is particularly frustrating when trying to turn of the lights around the house when going to bed on an OLED device. The entire device screen is dark, then flashes eye-searingly white for half a second, and then back to the dark UI of my dashboard.

Expected behaviour

Keep with the dark mode theme everywhere. Related: could the UI be cached? Waiting for the UI to load every time I open the app is a bit tedious (probably a side effect of using a slow device for the server). Caching the UI would probably also allow it to circumvent this issue (I'm guessing it's just the background of the WebView before the page is loaded).

Steps to reproduce

  1. Open App
  2. About two thirds through the loading watch the screen flash white
  3. Enjoy your dashboard

Can you reproduce the issue in demo mode?

Yes

Environment data

Client

  • Android version: 11
  • Device model: Realme X2
  • App version : 2.19.0
  • Build flavor : Full
  • Device language: English

Server

  • Server version: 3.1.0
  • Reverse Proxy: N/A
  • Authentication method : None

openHAB Cloud

  • Self hosted cloud or myopenhab.org: N/A
  • openHAB Cloud version : N/A
  • Authentication method : N/A

PMunch avatar Jan 06 '22 13:01 PMunch

Initially the webview has a dark background. Then the main UI loads, shows a white background. Shortly after it asks the app on which theme the app runs and in case of the dark theme, main UI switches to a dark background.

@ghys Is it possible that main UI calls the js interface earlier? Or use a transparent background before it calls the js interface to determine the theme?

mueller-ma avatar Jan 24 '22 19:01 mueller-ma

"calling the js interface earlier", not really. However the dark theme is set by applying the theme-dark CSS class on the root <html> element. It could be set earlier either by the app (https://stackoverflow.com/questions/30018540/inject-css-to-a-site-with-webview-in-android) or a script that would get loaded before the whole app and would use either the localStorage and/or prefers-dark-scheme (https://stackoverflow.com/questions/67876614/why-my-dark-mode-is-not-working-fullywhile-some-area-is-working).

ghys avatar Jan 27 '22 19:01 ghys

Or use a transparent background before it calls the js interface to determine the theme?

@ghys The above is not an option?

maniac103 avatar Jan 28 '22 06:01 maniac103

I suppose it loads the Framework7 CSS which is light theme by default and then - after it has loaded so a few seconds later - figures out that it has to apply the dark theme. If the theme-dark class is applied in advance then you won't have a light theme applied for a few seconds before the app changes it.

ghys avatar Jan 28 '22 09:01 ghys

I wasn't able to change the background to black by applying theme-dark very early. I'd still prefer a server side fix for this as the same issue is present on a (desktop) browser.

mueller-ma avatar Mar 13 '22 16:03 mueller-ma

Have there been any further thoughts/progress on this issue?

MichScha avatar Aug 14 '22 21:08 MichScha

Not on the Android side. I still prefer a server side fix for this.

mueller-ma avatar Aug 30 '22 17:08 mueller-ma