question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: SplashScreen.hide() doesn't work from remote server on Android

See original GitHub issue

Bug Report

Capacitor Version

Latest Dependencies:

  @capacitor/cli: 2.4.0
  @capacitor/core: 2.4.0
  @capacitor/android: 2.4.0
  @capacitor/electron: 2.4.0
  @capacitor/ios: 2.4.0

Installed Dependencies:

  @capacitor/cli 2.4.0
  @capacitor/core 2.4.0
  @capacitor/android 2.4.0
  @capacitor/ios 2.4.0
  @capacitor/electron not installed

[success] Android looking great! 👌
  Found 0 Capacitor plugins for ios:
[success] iOS looking great! 👌

Platform(s)

Only Android, not iOS.

(Device is a Xiaomi Mi A2 Lite with Android 10)

Current Behavior

I have the following two things in capacitor.config.json:

{
  "plugins": {
    "SplashScreen": {
      "launchAutoHide": false
    }
  },
  "server": {
    "url": "https://caribbean-radio-tent-lol.trycloudflare.com"
  }
}

That (temporary) URL is created by cloudflared tunnel --url http://localhost:3333, i. e. that domain tunnels to a Stencil.js dev server that runs on my local machine (along with the tunnel). But the same thing happens with a deployed version of our app.

In our app-root.tsx we have

import { Plugins } from '@capacitor/core';

export class AppRoot {
  componentWillLoad() {
    await Plugins.SplashScreen.hide();
  }

  // ...
}

The hide call does not work after cold-booting the app… not sure whether it fails or just isn’t called, the only log that might be relevant is

E/Capacitor/Console: File: https://caribbean-radio-tent-lol.trycloudflare.com/ - Line 1 - Msg: Uncaught TypeError: window.Capacitor.triggerEvent is not a function

but that one does not always come up in the logs.

When I’m in the stuck state, I can chrome://inspect the webapp just fine and it shows no errors. If I run await window.Capacitor.Plugins.SplashScreen.hide() in the dev-tools console, nothing happens. Here’s a screenshot of some console outputs:

When going to the phone’s home screen, then re-opening the app (from background, not cold-boot), the splash screen is gone.

When removing launchAutoHide from the capacitor config, I get this log:

SplashScreen was automatically hidden after the launch timeout. You should call `SplashScreen.hide()` as soon as your web app is loaded (or increase the timeout).Read more at https://capacitorjs.com/docs/apis/splash-screen#hiding-the-splash-screen

(and of course the splash screen disappears but it’s definitely not a timeout issue because the app loads within less than a second)

Expected Behavior

Obviously, the splash screen should hide as soon as the SplashScreen.hide() call is made.

Other Technical Details

npm --version output: 6.14.5

node --version output: v14.5.0

Additional Context

Update: I just noticed that at least from what I can see in the console, Capacitor seems to think that it’s running on web, not natively:

When I check the same thing on an iPhone, the platform is correctly determined as ios (and isNative is set):

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
bitflowercommented, Feb 2, 2021

Ok, forget it. During a refactor the import of Splashscreen was changed to import directly from @capacitor/core instead of Plugins.

0reactions
ionitron-bot[bot]commented, Nov 11, 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 Capacitor, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

navigator.splashscreen.hide() not working on cordova-android ...
I use AutoHideSplashScreen = false so that I can hide the splash screen after the UI is rendered. This works fine on iOS...
Read more >
Migrate your existing splash screen implementation to Android ...
If you have previously implemented a custom splash screen in Android 11 or lower, you'll need to migrate your app to the SplashScreen...
Read more >
Debugging - Expo Documentation
These are way more common, and we won't delve too much into how to ... Open the project in Android Studio: open -a...
Read more >
Black screen showing after splash screen Android 2.2 ...
Some code would help people (want to) answer: Make sure the interval in your super.loadURL is sufficiently long. Make sure your call to...
Read more >
Building a splash screen in React Native - LogRocket Blog
Hiding the splash screen after the app loads ... Node.js and Watchman installed on your development machine; iOS Simulator or Android ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found