White screen when launch TWA with splash

355 Views Asked by At

I am showing a splash screen(TWA splash) when launching TWA, but I see a white screen for 4-5 seconds after the splash screen when launch the app after a delay, as my web code needs to load a lot more data before launch, I know my web code should not take too much time to load, but I want to handle this white screen with a loader on native end only due to some limitation. I have not extended LauncherActivity(from android browser helper SDK) neither used it as a launcher in Manifest, I had copied code(whatever required) from this activity to my native activity Abc due to some conditional launch. I am not able to figure out which activity is hosting web content now after the TWA launch. As my activity, Abc seems to be in an onPause state. so I can not use this activity to show loader. If I used a new activity to show a loader my web content does not load in the background, it starts loading only when web content is in the foreground. I want to show loader when there is time to load web content, is there any way to do it?

Note: I have few redirects in my web URLs for launch.

1

There are 1 best solutions below

0
andreban On

The problem in this case is that the web application is taking too long to load.

The Splash Screen from the Trusted Web Activity will be started while Chrome is loading the page and will be automatically removed by the time the initial URL fires the pageload event.

There are several techniques you can use to improve the performance from your web application. A good place to get started is https://web.dev/fast/. One tip from your description is that the Trusted Web Activity should open the final URL and not have any redirects.