bug: SplashScreen.hide() doesn't work from remote server on Android
See original GitHub issueBug 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:
- Created 3 years ago
- Reactions:1
- Comments:10 (7 by maintainers)
Top GitHub Comments
Ok, forget it. During a refactor the import of
Splashscreen
was changed to import directly from@capacitor/core
instead ofPlugins
.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.