apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

Splash Screen stucks after migrating from 10 to 11 or 12. #1631

Closed Yura13 closed 10 months ago

Yura13 commented 10 months ago

Bug Report

Problem

Splash Screen stucks when running app on device. image

What is expected to happen?

Splash Screen should hide after app is loaded.

What does actually happen?

Splash Screen stucks when app running on a device without any errors or warnings.

Information

I've migrated cordova-android from 10 to 12 and updated a bunch of plugins. I've used this article https://ionic.zendesk.com/hc/en-us/articles/7891143965975-Migrating-to-Cordova-Android-11. The same happens when migrating from 10 to 11.

Environment, Platform, Device

Version information

OS - Windows 10 Android SDK Platform 33 Android SDK Build-Tools 34.0.0 Node.js - v18.16.1 Cordova-CLI - 12.0.0 (cordova-lib@12.0.1) Ionic-CLI - 7.1.1 Device - Galaxy Tab A SM-T510

config.xml

...
    <content src="index.html" />
    <access origin="*" />
    <access launch-external="true" origin="mailto:*" />
    <allow-navigation href="*" />
    <allow-navigation href="http://localhost:8100" sessionid="d6534558" />
    <allow-navigation href="http://localhost:8101" sessionid="7a6613ef" />
    <allow-intent href="mailto:*" launch-external="yes" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="geo:*" />
    <feature name="CDVWKWebViewEngine">
        <param name="ios-package" value="CDVWKWebViewEngine" />
    </feature>
    <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
    <preference name="ScrollEnabled" value="false" />
    <preference name="BackupWebStorage" value="none" />
    <preference name="KeyboardResize" value="false" />
    <preference name="WKWebViewOnly" value="true" />
    <preference name="Orientation" value="landscape" />
    <preference name="GradlePluginGoogleServicesEnabled" value="true" />
    <preference name="GradlePluginGoogleServicesVersion" value="4.3.8" />
    <platform name="android">
        <preference name="android-minSdkVersion" value="24" />
        <preference name="android-targetSdkVersion" value="33" />
        <preference name="AndroidLaunchMode" value="singleTask" />
        <preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources_stage/android/icon/drawable-xxxhdpi-icon.png" />
        <preference name="AndroidWindowSplashScreenBackground" value="#FFFFFF" />
        <config-file parent="./application" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
            <meta-data android:name="com.rollbar.android.ACCESS_TOKEN" android:value="111111111111111" />
        </config-file>
        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
            <application android:networkSecurityConfig="@xml/network_security_config" />
            <application android:requestLegacyExternalStorage="true" />
            <application android:usesCleartextTraffic="true" />
        </edit-config>
        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity" xmlns:android="http://schemas.android.com/apk/res/android">
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
        </edit-config>
        <hook src="plugins/cordova-plugin-ble-central/stripDuplicatePermissions.js" type="after_prepare" />
        <resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
        <resource-file src="google-services.json" target="app/google-services.json" />
        <allow-intent href="market:*" />
        <icon density="ldpi" src="resources_stage/android/icon/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="resources_stage/android/icon/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="resources_stage/android/icon/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="resources_stage/android/icon/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="resources_stage/android/icon/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="resources_stage/android/icon/drawable-xxxhdpi-icon.png" />
    </platform>
...

package.json

"dependencies": {
    "@almothafar/angular-signature-pad": "^5.0.1",
    "@angular/animations": "^15.2.9",
    "@angular/common": "^15.2.9",
    "@angular/compiler": "^15.2.9",
    "@angular/core": "^15.2.9",
    "@angular/forms": "^15.2.9",
    "@angular/platform-browser": "^15.2.9",
    "@angular/platform-browser-dynamic": "^15.2.9",
    "@angular/pwa": "^15.2.8",
    "@angular/router": "^15.2.9",
    "@angular/service-worker": "^15.2.9",
    "@apollo/client": "^3.7.15",
    "@awesome-cordova-plugins/app-version": "^6.4.0",
    "@awesome-cordova-plugins/ble": "^6.4.0",
    "@awesome-cordova-plugins/call-number": "^6.4.0",
    "@awesome-cordova-plugins/camera": "^6.4.0",
    "@awesome-cordova-plugins/core": "^6.4.0",
    "@awesome-cordova-plugins/deeplinks": "^6.4.0",
    "@awesome-cordova-plugins/device": "^6.4.0",
    "@awesome-cordova-plugins/diagnostic": "^6.4.0",
    "@awesome-cordova-plugins/document-viewer": "^6.4.0",
    "@awesome-cordova-plugins/file": "^6.4.0",
    "@awesome-cordova-plugins/file-opener": "^6.4.0",
    "@awesome-cordova-plugins/file-transfer": "^6.4.0",
    "@awesome-cordova-plugins/fingerprint-aio": "^6.4.0",
    "@awesome-cordova-plugins/firebase-analytics": "^6.4.0",
    "@awesome-cordova-plugins/geolocation": "^6.4.0",
    "@awesome-cordova-plugins/http": "^6.4.0",
    "@awesome-cordova-plugins/in-app-browser": "^6.4.0",
    "@awesome-cordova-plugins/ionic-webview": "^6.4.0",
    "@awesome-cordova-plugins/keyboard": "^6.4.0",
    "@awesome-cordova-plugins/launch-navigator": "^6.4.0",
    "@awesome-cordova-plugins/network": "^6.4.0",
    "@awesome-cordova-plugins/screen-orientation": "^6.4.0",
    "@awesome-cordova-plugins/splash-screen": "^6.4.0",
    "@awesome-cordova-plugins/sqlite": "^6.4.0",
    "@awesome-cordova-plugins/status-bar": "^6.4.0",
    "@dustfoundation/ngx-sortablejs": "^15.0.0",
    "@ionic-native/app-launcher": "^5.36.0",
    "@ionic-native/httpd": "^5.36.0",
    "@ionic/angular": "^6.7.3",
    "@ionic/cordova-builders": "^9.0.0",
    "@ionic/storage": "^2.3.1",
    "@mapbox/mapbox-gl-draw": "^1.4.1",
    "@turf/turf": "^6.5.0",
    "apollo-angular": "^4.2.1",
    "call-number": "^1.0.1",
    "cordova-browser": "^7.0.0",
    "cordova-ios-plugin-no-export-compliance": "0.0.6",
    "cordova-js": "^6.1.0",
    "cordova-plugin-actionsheet": "^2.3.3",
    "cordova-plugin-app-launcher": "^0.4.0",
    "cordova-plugin-device": "^2.1.0",
    "cordova-plugin-dialogs": "^2.0.2",
    "cordova-plugin-document-viewer": "^1.0.0",
    "cordova-plugin-fingerprint-aio": "^5.0.1",
    "cordova-plugin-geolocation": "^4.1.0",
    "cordova-plugin-httpd": "^0.9.3",
    "cordova-plugin-inappbrowser": "^5.0.0",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^5.0.0",
    "cordova-plugin-ios-camera-permissions": "^1.2.0",
    "cordova-plugin-network-information": "^3.0.0",
    "cordova-plugin-screen-orientation": "^3.0.3",
    "cordova-plugin-statusbar": "^3.0.0",
    "cordova-plugin-webserver": "1.0.3",
    "cordova-sqlite-ext": "^6.0.0",
    "core-js": "^3.31.0",
    "dom-to-image-chrome-fix": "^2.6.0",
    "es6-promise-plugin": "^4.2.2",
    "extract-files": "^11.0.0",
    "file-saver": "^2.0.5",
    "graphql": "^16.6.0",
    "graphql-ws": "^5.13.1",
    "hammerjs": "^2.0.8",
    "interactjs": "^1.10.17",
    "ionic-native": "^2.9.0",
    "ionic-plugin-deeplinks": "^1.0.24",
    "lodash-decorators": "^6.0.1",
    "mapbox-gl": "^2.15.0",
    "moment": "^2.29.4",
    "moment-timezone": "^0.5.43",
    "mx.ferreyra.callnumber": "0.0.2",
    "ng-multiselect-dropdown": "0.2.4",
    "ngx-chips": "^2.2.2",
    "ngx-color-picker": "^14.0.0",
    "ngx-cookie-service": "^15.0.0",
    "ngx-doc-viewer": "^15.0.1",
    "node-html-parser": "^6.1.5",
    "panzoom": "^9.4.3",
    "pluralize": "^8.0.0",
    "print-js": "^1.6.0",
    "remove": "^0.1.5",
    "rollbar": "^2.25.1",
    "rxjs": "~6.6.7",
    "sortablejs": "^1.15.0",
    "swiper": "^9.2.0",
    "tslib": "^2.5.3",
    "uk.co.workingedge.phonegap.plugin.launchnavigator": "^5.0.6",
    "xml2js": "^0.6.0",
    "zone.js": "~0.11.8"
},
  "devDependencies": {
    "@angular-devkit/architect": "^0.1502.8",
    "@angular-devkit/build-angular": "^15.2.8",
    "@angular-devkit/core": "^15.2.8",
    "@angular-devkit/schematics": "^15.2.8",
    "@angular-eslint/eslint-plugin": "^15.2.1",
    "@angular/cli": "^15.2.8",
    "@angular/compiler-cli": "^15.2.9",
    "@angular/language-service": "^15.2.9",
    "@ionic/angular-toolkit": "^9.0.0",
    "@types/extract-files": "^8.1.1",
    "@types/file-saver": "^2.0.5",
    "@types/jasmine": "~4.3.1",
    "@types/jasminewd2": "~2.0.10",
    "@types/node": "~16.18.35",
    "@types/sortablejs": "^1.15.0",
    "@typescript-eslint/eslint-plugin": "^5.59.9",
    "@typescript-eslint/parser": "^5.59.9",
    "axios": "^1.4.0",
    "cordova-android": "^12.0.0",
    "cordova-ios": "^6.2.0",
    "cordova-plugin-add-swift-support": "^2.0.2",
    "cordova-plugin-app-version": "^0.1.14",
    "cordova-plugin-ble-central": "^1.7.0",
    "cordova-plugin-camera": "github:apache/cordova-plugin-camera",
    "cordova-plugin-file": "^8.0.0",
    "cordova-plugin-file-opener2": "^4.0.0",
    "cordova-plugin-file-transfer": "github:apache/cordova-plugin-file-transfer",
    "cordova-plugin-firebase-analytics": "^7.0.5",
    "cordova-plugin-ionic": "^5.5.3",
    "cordova-plugin-ios-base64": "github:sarahgoldman/cordova-plugin-ios-base64",
    "cordova-plugin-print-pdf": "^4.0.2",
    "cordova-support-android-plugin": "~2.0.4",
    "cordova.plugins.diagnostic": "^7.1.2",
    "eslint": "^8.42.0",
    "eslint-config-prettier": "^8.8.0",
    "eslint-config-standard": "^17.1.0",
    "eslint-plugin-import": "^2.27.5",
    "eslint-plugin-prettier": "^4.2.1",
    "form-data": "^4.0.0",
    "jasmine-core": "~4.6.0",
    "jasmine-reporters": "^2.5.2",
    "jasmine-spec-reporter": "~5.0.2",
    "karma": "~6.4.1",
    "karma-chrome-launcher": "~3.1.1",
    "karma-coverage-istanbul-reporter": "~3.0.3",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "^2.0.0",
    "prettier": "^2.8.8",
    "prettier-eslint": "^15.0.1",
    "prettier-plugin-css-order": "^1.3.1",
    "ts-node": "~8.10.2",
    "typescript": "~4.8.4"
  }
EYALIN commented 10 months ago

can you see what is the exception in logcat?

Yura13 commented 10 months ago

I saw a lot of next message: cancelDraw androidx.core.splashscreen.SplashScreen$Impl$setKeepOnScreenCondition$1@b516b93 isViewVisible: true

breautek commented 10 months ago

A stuck splash screen generally indicates an error that prevented something from initialising properly. The error could be in JS (webview) land or on the native side.

Splash Screen stucks when app running on a device without any errors or warnings.

I'm not sure where you checked for errors, so I'll describe how to check both the native side and JS land.

For the Webview/JS, use the Chrome inspector to see any console output.

To check for native logs, open the android project in android studio. The project can be found at <cordova-project>/platforms/android. Do NOT accept any updates that Android Studio may prompt when you open the project, as it will likely break the project. You can launch the app from Android Studio which has the native debugger attached and a filtered logcat.

cancelDraw androidx.core.splashscreen.SplashScreen$Impl$setKeepOnScreenCondition$1@b516b93  isViewVisible: true

This looks like a log message stating that android is still waiting on the condition to return false. Any actual insight on what the app is actually doing is probably further up in the log.

If you can provide a logcat dump for your application from applcation start to when it "hangs" at the splashscreen, someone can probably help you dissect it.

Yura13 commented 10 months ago

Thanks a lot! I found the problem. When I got stuck splash screent when running ionic cordova run android --consolelogs --debug --device --livereload. The app successfully runs on the device after removing --livereload or using ionic cordova run android --consolelogs --debug --device --livereload --host=YOUR_IP_ADDRESS.