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

[Cap 3 beta] Splash Screen: Splash no longer automatically appears on app launch #270

Closed
dotNetkow opened this issue Feb 24, 2021 · 7 comments · Fixed by #319
Closed

[Cap 3 beta] Splash Screen: Splash no longer automatically appears on app launch #270

dotNetkow opened this issue Feb 24, 2021 · 7 comments · Fixed by #319

Comments

@dotNetkow
Copy link

dotNetkow commented Feb 24, 2021

Bug Report

Plugin(s)

Splash Screen v0.3.3

Capacitor Version

Core: v3.0.0-beta.2
CLI: same

Platform(s)

iOS, Android

Current Behavior

In Cap 3's Splash Screen plugin, launchShowDuration value now defaults to 0 (in Cap 2, it was 3000 which caused apps to potentially be “slower” to load if they in fact loaded faster than 3 seconds). The consequence is that the Splash Screen no longer automatically appears on app launch.

Why? In the code (see here), if 0 is found, the showOnLaunch() method exits without doing anything. in SplashScreenConfig (iOS), launchShowDuration defaults to 0.

If that's intentional, we should document this change in the upgrade guide because if you’re like me, you never called the Show method, just Hide. According to Dan, this could be a bug though.

To see the splash screen, I added this to the Cap config:
"launchShowDuration": 1000,
"launchAutoHide": false

Expected Behavior

If the Splash screen plugin is installed, on ios/android app launch the screen should display, and no configuration (in capacitor.config.json) is required.

Code Reproduction

Pull Cap 3 branch: https://github.com/ionic-team/ionifits/tree/cap-3

Currently, the splash will show since I've set launchShowDuration to 1000 (aka anything but 0). So, delete launchShowDuration entry from Cap config, or set it to zero.

Open question: What is the best configuration for fast loading apps?

From this in the Cap 3 docs, we mention hiding the splash to manually provide the fastest experience to users. With this new launch duration change in mind, what is the best practice for fast loading apps?What recommendation can we make to users?

I think we want to recommend showing the splash screen for as long as it takes until the app is ready. That would mean in Cap config, setting launchAutoHide to false, then calling Hide() on app startup. In Angular, this would be:

export class AppComponent {
constructor() {
  if (Capacitor.isNativePlatform()) {
    SplashScreen.hide();
  }
}
@jcesarmobile
Copy link
Member

It was documented on ionic-team/capacitor#3320 (check last edit), but looks like it wasn't added when the information was moved to the official doc page.

But since Capacitor 2.1.0, all new projects included launchShowDuration: 0 in the capacitor.config.json, so it's really only breaking if it was created before that or if the entry was removed.

@dotNetkow
Copy link
Author

Updated my description with more detail. It's not about whether it's a breaking change or not, just pointing out that the Splash doesn't appear on launch anymore because that launch duration value now defaults to 0.

If that's intentional (aka not a bug), I'd like to know what values to set then, as part of my "open question" thing. thanks.

@eric-horodyski
Copy link
Member

Using Capacitor 3.0.0-beta.6, this appears to prevent the ability for a splash screen to be shown for an indeterminate amount of time in cases where developers want to "set the stage" of their application "before pulling back the curtain".

Given two branches of the same application, both containing the same SplashScreen plugin configuration:

  plugins: {
    SplashScreen: {
      launchAutoHide: false,
    },
  },

@dennisameling
Copy link

@eric-horodyski could you try if this works for you? Explicitly setting a launchShowDuration seems to do the trick if launchAutoHide is false, which looks like a bug to me though

@dennisameling
Copy link

dennisameling commented Mar 8, 2021

Looks like this is the culprit:

Just did a quick check and I think it should be this instead:

if (config.getLaunchShowDuration() == 0 && config.isLaunchAutoHide()) {
  return;
}

Will check on both Android and iOS and provide a PR later today 👍🏼

@EinfachHans
Copy link

EinfachHans commented Mar 16, 2021

Additional (iOS): launchAutoHide seems to do nothing currently?

settings.fadeInDuration = config.launchFadeInDuration
showSplash(settings: settings, completion: {}, isLaunchSplash: true)

I think here the settings.autoHide should be set to config.launchAutoHide

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 30, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants