Initial work on the new fast splash screen
Fixes #87
Usage:
public FastSplashScreen Splash { get; }
public App()
{
Splash = FastSplashScreen.ShowDefaultSplashScreen(); // Shows splashscreen with closest matching scale from app manifest.
this.InitializeComponent();
}
In MainWindow when your window has loaded, call
MyApp.Splash.Hide(); (with optional timespan parameter to fade out)
There's also an option to just specify an image path and not rely on app manifest (unpackaged apps would need that):
FastSplashScreen.ShowSplashScreenImage(full_path_to_image);
Small tip: granted, this will never be as fast as the UWP splash screen, but should be able to at least improve this a tiny bit more if you disable the XAML generated splash screen, and show your custom splash screen before anything else. That is, before even loading any WinAppSDK/WinUI bit of code, creating the App instance, anything. Might help a tiny bit 🙂
@Sergio0694 it does make a little difference. Not a whole lot though. But for completeness sake, I updated the functional test app to show both ways
Yeah, that's the best we can do from here. The ideal way would be to just do what UWP does, where the OS shows the splash screen and the window before any of the app even runs, but of course that requires OS support and isn't an option 😅
It's still pretty responsive with a sub-second launch time on my machine. Well before you start thinking "did I click it"?
Yup, I mean I haven't seen this in action but I believe it looks completely acceptable. Was just saying that sadly there's only so much you can do without OS support. The UWP splash screen has a bunch of advantages like:
- It's even faster
- It reuses the same window frame as the app, meaning it'll always exact match the size and position
- Will smoothly fade out
- The OS can automatically suppress it if the app activates in less than ~400ms after launch, meaning if your app is fast enough (or when it's running on a fast machine), you'll skip the splash screen entirely to get an even smoother experience, with no flickering, and dynamically adjusting at every launch
That said, that was just me thinking out loud, and I'm sure this custom splash screen will already be useful to folks looking for something like this. Great job! 🙂