-
Notifications
You must be signed in to change notification settings - Fork 991
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
bug: SplashScreen.hide() doesn't work from remote server on Android #3485
Comments
Edit: After thinking that I couldn't reproduce this anymore, I found out what it is: it depends on whether I do a prod or dev build of our Stencil + Ionic app. In dev builds (non-minified) it does not happen, but in prod builds (minified) it does. By "it" I mean that Capacitor thinks the platform is I'll try to create a reproducible example using the ionic-stencil-conference-app tomorrow. |
Just a quick update: after debugging this further, the difference is that the prod build comes with a service worker and if I disable the service worker for the prod build, then the splash screen works as expected. When bundling the web app into the app, the service worker fails to register which is why this doesn't happen when not using a remote server.
Seems like the service worker isn't registered at all on iOS which is why the error only occurs on Android. I'll do some more debugging later this week to narrow it down on what specifically is causing this in the service worker (but also wondering about general support of service workers in Capacitor). |
Capacitor code is not injected in service workers, if you want to inject it see #1655 (comment), but it only works on Android 7+ (SDK level 24+) |
Thanks for that link, that's exactly the problem 👍 @jcesarmobile do you have an idea for a way to block registration of the service worker in api levels 21-23? Or maybe you have any insight why this is only available since level 24? Is it because service workers aren't supported anyway? (which would be ideal 🤓) |
The ServiceWorkerController was introduced in API 24 and I don't think there is a support library for it to support older versions. |
Ok thanks for the hints! I've added the custom I've checked the
so I've moved the block before the
(first line is my custom log) Is there maybe a repository of an app that uses this successfully? BTW it does work the first time the app is launched but not anymore when restarting the app later, after the service worker is already registered. |
After a lot of debugging I think I finally figured out why |
@simonhaenisch I'm having the same issue (I guess). The web implementation is called. Is this what the error scenario looks like (debugger running on Android sim)? |
Ok, forget it. During a refactor the import of |
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. |
Bug Report
Capacitor Version
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
: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 haveThe
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 isbut 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 runawait 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:(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.5node --version
output: v14.5.0Additional 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
(andisNative
is set):The text was updated successfully, but these errors were encountered: