apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 986 forks source link

App stuck on splash screen on ios 16+ #1395

Closed gustavohpaula closed 2 months ago

gustavohpaula commented 3 months ago

I have an application that uses cordova-ios@5.1.1. When running the app on iOS 16 or 17, the app crashes on the splash screen without any log on xcode and the safari don't recognize it to see the js log. During the test I find that the problem is because of the dependency of the WKWebViewEngine. I've tried to upgrade the cordova-ios to version 6 but the WKWebViewEngine is integrated on the core, so the problem persist

breautek commented 3 months ago

Crashes or gets stuck?

If it's crashing, you should see a backtrace in XCode, if you're running with the XCode debugger attached.

If it's getting stuck, it may be because of a JS error. The Safari Web Inspector can be used to observe JS errors but it won't collect any error events that occurred before the web inspector was attached. However, you should be able to refresh the webview (even if the splashscreen is still shown) by pressing cmd + R while the inspector is focused. Reloading the webview while the inspector is opened may allow you catch JS issues happening in the webview.

During the test I find that the problem is because of the dependency of the WKWebViewEngine.

Can you expand what you mean by this? cordova-ios@5 has no dependency on the WKWebView, but there is a cordova-plugin-wkwebview-engine to use the wkwebview. cordova-ios@6 integrates the WKWebView making that plugin obsolete, because the old UIWebView API deprecated and now forbidden.

gustavohpaula commented 3 months ago

The app remains stuck on the splash screen, but the safari doesn't recognize it to use the debugger. About the cordova-plugin-wkwebview-engine, we had it in our project as a dependency in order to use cordova-plugin-wkwebview-file-xhr. This plugin is vital for our business logic. We think something changed on iOS 16+, because the app runs just fine on lower versions of the OS, even with cordova-plugin-wkwebview-engine installed in our project. We've tried to upgradecordova-ios to 6.x and remove cordova-plugin-wkwebview-engine, but the situation remains the same, the app gets stuck on the splash screen with no errors.

breautek commented 3 months ago

... but the situation remains the same, the app gets stuck on the splash screen with no errors.

Including if you try:

you should be able to refresh the webview (even if the splashscreen is still shown) by pressing cmd + R while the inspector is focused. Reloading the webview while the inspector is opened may allow you catch JS issues happening in the webview.

If there is truly no log output either from the native xcode side, or when refreshing the webview view the web inspector for the JS side, then the only other explanation that I can think of is a plugin is misbehaving and potentially hanging. A brute force way of determining this is start uninstalling plugins one by one until it gets passed the splashscreen (even if it then results in an error because of a missing plugin, at least you found the likely culprit for the splashscreen hang).

I would recommend doing this on cordova-ios@5 with the cordova-plugin-wkwebview-engine installed because that's kind of your baseline/last known working state. Once the project is stabilised again, I'd consider upgrading to cordova-ios@6, noting the breaking changes mentioned in the release blog, and assuming that no further, consider upgrading to cordova-ios@7 (release notes). At this point you'll be completely up to date and on a supported version.

taxman007 commented 2 months ago

Try this in your config.xml file

<preference name="AutoHideSplashScreen" value="true" />

gustavohpaula commented 2 months ago

I used the and then can see the error log on safari. The problem was in the cordova-plugin-screen-orientation version 3.0.2. I removed this plugin and updated my app to cordova-ios version 7.0.1and all works well