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

Custom Splash Screen for PWAs #218

Open
sidrao2006 opened this issue Jul 1, 2020 · 16 comments
Open

Custom Splash Screen for PWAs #218

sidrao2006 opened this issue Jul 1, 2020 · 16 comments
Labels
depends-external Depends on changes on an external project, android-browser-helper or the underlying browsers enhancement New feature or request

Comments

@sidrao2006
Copy link

Currently in Chrome version 83, the splash screen has no controls. This is especially important when we need to fetch huge amounts of data from the server and the user has to stare at an icon and app name.

Splash screen design can be improved.....for example, json can be used to completely customise the splash screen with progress bar or loaders

If customisation would be a tough job, then the splash screen could just be made better by Chrome itself for all PWAs

@andreban andreban added the enhancement New feature or request label Jul 1, 2020
@andreban
Copy link
Member

andreban commented Jul 1, 2020

Thanks for filing this. I filed an issue on the Chrome bug tracker for this, as we'd need the browser to support this first: http://crbug.com/1101362

@andreban
Copy link
Member

andreban commented Jul 1, 2020

On a separate note, have you checked how the application is performing against the Web Vitals metrics and the Quality Criteria for Trusted Web Activity? Even with a progress bar / loader / spinner on the splash screen, taking a long time to load the application will lead to bad user experience, which will likely be reflected on Play Store ratings, reviews, etc. There are many strategies that can be used to deliver an useable screen to the user ASAP then load the remainder of the content in the background.

@PEConn
Copy link
Collaborator

PEConn commented Jul 1, 2020

The splash screen covers two things - the browser launching and the page loading. We can't really get away from there being a delay when the browser launches (especially when it wasn't already running, browsers are pretty big and talk some time to load).

Ideally though for your website, there shouldn't be a massive delay between the navigation and content appearing on the screen. In the future we may punish websites that take too long to load, so the best strategy would be to have some parts of the page load quickly (the surrounding template part, which could be served by a ServiceWorker) and then have the content load take longer. With this approach you have more control over the experience your users get when the content is loading (and it will also improve your site on desktop and when visited from the browser).

@sidrao2006
Copy link
Author

sidrao2006 commented Jul 2, 2020 via email

@sidrao2006
Copy link
Author

sidrao2006 commented Jul 2, 2020

Current splash screen behaviour

Current splash screen behaviour

Expected splash screen behaviours

Expected splash screen behaviour

Expected splash screen behaviour

@nitzanashi
Copy link

on another context, is there an option to remove the splash screen from within the twa-manifest config?

@andreban
Copy link
Member

andreban commented Jul 6, 2020

@nitzanashi the splash screen prevents a flash of white content which leads to bad user experience. See #218 (comment) and #218 (comment). From my perspective, providing a way to remove it in Bubblewrap is a footgun, as it will invariably lead to worse apps.

@andreban
Copy link
Member

andreban commented Jul 6, 2020

It sounds like you'd need a few things:

  1. Use an image for the splash screen that is different from the image used for launcher icons (Allow using a different image from iconUrl for the Splash Screen #226)
  2. Set the splash screen to use the whole screen (customize getSplashScreenScaleType and allow setting it to FIT_XY)
  3. Use an AnimationDrawable as the splash screen image.

Number 1. only requires changes in Bubblewrap. 2. requires changing android-browser-helper (shouldn't be a problem). 3 requires changes in Chromium. No clue how feasible this is. @PEConn may have a better idea.

@nitzanashi
Copy link

@andreban thanks for clarification!
I wasn't aware of these effects, then I shall keep splash option 👍🏻

@sidrao2006
Copy link
Author

Can other image formats like .gif be used for splash screen?
If so then a short video clip can be cached a displayed and upon page load, the rendered page can interrupt the video and close it, however formats like mp4 may cause android to implement it as a video and prepare the screen and activating other video features which we don't want

@PEConn
Copy link
Collaborator

PEConn commented Jul 6, 2020

The splash screen hides the following:

  1. The TWA shell starts up.
  2. The TWA shell launches Chrome.
  3. Chrome loads the page.

During step 1, the TWA shell is visible on screen and during steps 2 and 3 Chrome is on screen. We essentially use slight of hand to make the user not notice that we're switching apps. The TWA shows an image then essentially takes a screenshot of itself and passes it to Chrome. Chrome then starts up with that image and once the web page has something to display, it dismisses it.

(We did try quite a few other options such as passing around Android RemoteViews or having Chrome try to load the page in the background and only launching Chrome when there's something to display on the page - all of them ran into technical limitations in either Chrome or Android.)

So, if you wanted to display an animation, what you could do is have the TWA shell display an animation, then switch over to Chrome which would show a screenshot of the end-state of the animation, but that would just mean that the user has to sit through the whole animation before the page starts loading.

@andreban
Copy link
Member

andreban commented Jul 6, 2020

@sidrao2006 The goal is to minimize the time spent on the splash screen. So, another alternative is for the web app to do load the first render ASAP and replace the splash screen with its own web-based splash, if they need to load additional resources, where they'll have full control.

@sidrao2006
Copy link
Author

sidrao2006 commented Jul 6, 2020

@andreban good idea, but as @PEConn mentioned, this is not possible as the splash screen is displayed right after the user opens the app and till chrome is launched and the render occurs
So the entire spash screen has to be managed by the TWA
Since the TWA is written and run in android, I think an android configuration used to display a splash screen can be used in foreground, while the TWA shell starts up and launches Chrome in background. After the loading, once again Chrome can work with a screenshot or directly render its first page as the android splash screen fades away

If transition is smooth enough, then the animation can be continued to Chrome until it completely renders the page
I hope this java splash screen can work with TWAs.

@sidrao2006
Copy link
Author

@andreban any updates on this?

@dseeker
Copy link

dseeker commented Feb 18, 2021

Animated SVGs are working pretty well in Chrome, are they supported in the TWA context?

@andreban
Copy link
Member

No. The splash screen is generated on Android code, which doesn't support SVGs.

@andreban andreban added the depends-external Depends on changes on an external project, android-browser-helper or the underlying browsers label May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
depends-external Depends on changes on an external project, android-browser-helper or the underlying browsers enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants