iOS issue when restorting app from background (screen stays white) #7097
Replies: 16 comments 22 replies
-
We are experiencing exactly the same problem (we also migrated from cordova to capacitor). Unfortunately, I haven't found the root cause, yet. |
Beta Was this translation helpful? Give feedback.
-
Same problem here, latest capacitor behaves the same on iOS |
Beta Was this translation helpful? Give feedback.
-
Same problem on iOS with Capacitor 5.0.0 Issues reported on iOS 16 and iOS 17. Difficult to reproduce (after several hours and with dozens of other apps open to make pression on memory), XCode logs :
|
Beta Was this translation helpful? Give feedback.
-
I've been having this same issue on a Ionic Cordova project that hasn't been migrated to capacitor yet, so the issue doesn't seem to be capacitor specific. |
Beta Was this translation helpful? Give feedback.
-
If an application is rewriting the url (e.g. using If manually reloading the page ( Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Same problem here, reported by user but I couldn't reproduce it. Hope someone can look into a standard solution soon. |
Beta Was this translation helpful? Give feedback.
-
Same problem here. Do you have any idea how can I fix it? Many of my users reported this error. |
Beta Was this translation helpful? Give feedback.
-
Could this be related to the app trying to reload the current url but it fails because your SPA is set up to handle routing? |
Beta Was this translation helpful? Give feedback.
-
I am experiencing the same issue, using Ionic Angular. I can recreate the issue consistently using the kill WebContent process trick, but only on specific URLs. It seems to be the URLs that use Angular's positional arguments (
The error on resume is then:
If the URL is |
Beta Was this translation helpful? Give feedback.
-
For anyone using capacitorjs with sveltekit: I was facing this exact same issue. The root page would load fine on location.reload(), but any other page would result in a blank page. In a practical scenario this would lead to a non-responsive app on iOS after a period of inactivity. After some debugging I fixed it by a combination of two things:
The first one is because when the webview is reloaded, it somehow tries to load resources from the path that you're currently on, instead of the root path as indicated by the relative imports. The second one is because even though the loads will work fine, there is still some mismatch between the loaded files and the page that should be loaded on the path you're on. A workaround is to just redirect to the root '/' if the root component is loaded, but the path is not the root path, and things will work fine from there. This all seems to be a bit of a hack, so if anyone has a better solution please let me know :) |
Beta Was this translation helpful? Give feedback.
-
I have a similar problem on Android, stays white for a few seconds after screen unlock. |
Beta Was this translation helpful? Give feedback.
-
We are having the exact issue on IOS and it's breaks the user experience from time to time. A kind follow up from the dev on this would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
-
I'd like to also say that I'm experiencing the same issue. Hoping there is an official resolution to this soon! |
Beta Was this translation helpful? Give feedback.
-
One workaround is to force the app to restart from the "home" route when reloaded from any other route (as it happens after a crash) For example, with Vue router
and test if |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
Hi, In case it helps anyone, I will share my solution. In my ....
import { App } from '@capacitor/app';
....
App.addListener('resume', async () => {
// refresh firebase token
// this is needed because the firebase auth token expires after 1 hour
// and if the app is in the background for more than 1 hour,
// when the app is resumed, the user got a white screen because the token was expired
const newToken = await this.authService.getIdToken({ forceRefresh: true });
await this.storage.set(LOCAL_STORAGE_KEYS.user_token, newToken);
}); Then in my authService public async getIdToken(options?: GetIdTokenOptions): Promise<string> {
return FirebaseAuthentication.getIdToken(options)
.then((result) => result.token)
.catch(() => '');
} |
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
we originally managed our app with cordova. A few months ago we migrated to capacitor. However, we're having a really frustrating problem under iOS:
When you put the app in the background on iOS and then bring it back to the foreground after a while, the screen stays completely white and the app is no longer visible. The only way to fix it is to quit and restart the app. This makes the app very difficult to use for our iOS users. I think the problem is that the app isn't restoring properly from the frozen state.
Has anyone else had a similar problem? Can you give us any helpful tips on how to fix it? We'd really appreciate it if we could get this resolved as soon as possible. It's a very urgent issue.
Thanks for any help!
Beta Was this translation helpful? Give feedback.
All reactions