Prince Hernandez
Prince Hernandez

Reputation: 3721

Ionic ios app is really slow but fast on android

I created an app with ionic and it is almost finished (it is a cart shop app). now that I want to build the app I'm using the following command:

ionic cordova build --release --prod --verbose XXXXX

where XXXXX is either ios or android.

when building for android the app (after signing etc etc) the app takes like 3 or 4 seconds on the splash screen, which is an acceptable time, but the issue comes when I use the same command to build for ios, I was trying to test the app in XCode and it works, the only problem is that the app takes 30 SECONDS, which makes the app unusable and I can figure why.

edit: also I was thinking that the problem was the emulator but I also tried running the app in a device, same result.

below I'll left the information:

Ionic Info

Ionic:

   Ionic CLI                     : 6.11.7 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 4.11.10
   @angular-devkit/build-angular : 0.803.29
   @angular-devkit/schematics    : 8.3.29
   @angular/cli                  : 8.3.29
   @ionic/angular-toolkit        : 2.3.2

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : android 9.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 14 other plugins)

Utility:

   cordova-res : 0.15.1
   native-run  : 1.0.0

System:

   ios-deploy : 1.11.1
   ios-sim    : 8.0.2
   NodeJS     : v12.16.1 (/usr/local/bin/node)
   npm        : 6.14.8
   OS         : macOS Catalina
   Xcode      : Xcode 11.7 Build version 11E801a

Package JSON

{
  "name": "store-app",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint --typeCheck",
    "e2e": "ng e2e",
    "clean-project": "rm -rf www && rm -rf platforms && rm -rf node_modules && rm -rf plugins"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "~1.0.0",
    "@angular/common": "^8.2.14",
    "@angular/core": "^8.2.14",
    "@angular/forms": "^8.2.14",
    "@angular/platform-browser": "^8.2.14",
    "@angular/platform-browser-dynamic": "^8.2.14",
    "@angular/router": "^8.2.14",
    "@ionic-native/android-permissions": "^5.27.0",
    "@ionic-native/background-mode": "^5.26.0",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/firebase-analytics": "^5.28.0",
    "@ionic-native/geolocation": "^5.10.0",
    "@ionic-native/header-color": "^5.26.0",
    "@ionic-native/keyboard": "^5.14.0",
    "@ionic-native/location-accuracy": "^5.27.0",
    "@ionic-native/onesignal": "^5.13.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic-native/unique-device-id": "^5.9.0",
    "@ionic/angular": "^4.1.0",
    "@ionic/lab": "^3.1.7",
    "@ngx-translate/core": "^10.0.0",
    "@ngx-translate/http-loader": "^3.0.0",
    "animate.css": "^4.1.0",
    "com.testfairy.cordova-plugin": "^2.25.0",
    "cordova-browser": "6.0.0",
    "cordova-plugin-background-mode": "^0.7.3",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-geolocation": "^4.0.2",
    "cordova-plugin-headercolor": "^1.0.0",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^4.1.3",
    "cordova-plugin-splashscreen": "^6.0.0",
    "cordova-plugin-statusbar": "^2.4.3",
    "cordova-plugin-uniquedeviceid": "^1.3.2",
    "cordova-plugin-whitelist": "^1.3.4",
    "core-js": "^2.5.4",
    "onesignal-cordova-plugin": "^2.5.2",
    "rxjs": "~6.6.2",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/architect": "~0.800.0",
    "@angular-devkit/build-angular": "~0.803.29",
    "@angular-devkit/core": "~8.3.29",
    "@angular-devkit/schematics": "~8.3.29",
    "@angular/cli": "~8.3.29",
    "@angular/compiler": "~8.2.14",
    "@angular/compiler-cli": "~8.2.14",
    "@angular/language-service": "~8.2.14",
    "@ionic/angular-toolkit": "~2.3.2",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~10.14.2",
    "codelyzer": "~5.2.1",
    "cordova-android": "9.0.0",
    "cordova-ios": "^6.1.0",
    "cordova-plugin-advanced-geolocation": "git+https://github.com/esri/cordova-plugin-advanced-geolocation.git",
    "cordova-plugin-android-permissions": "^1.0.2",
    "cordova-plugin-androidx-adapter": "^1.1.1",
    "cordova-plugin-firebase-analytics": "^4.3.1",
    "cordova-plugin-request-location-accuracy": "^2.3.0",
    "cordova-support-android-plugin": "^1.0.2",
    "cordova-support-google-services": "^1.4.1",
    "husky": "~4.2.5",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.4",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "lint-staged": "^10.2.2",
    "node-sass": "^4.13.1",
    "prettier": "^2.0.5",
    "protractor": "~5.4.0",
    "ts-node": "~8.10.2",
    "tslint": "~5.18.0",
    "tslint-config-prettier": "~1.18.0",
    "tslint-etc": "^1.10.1",
    "typescript": "~3.5.3"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-uniquedeviceid": {},
      "cordova-plugin-geolocation": {},
      "onesignal-cordova-plugin": {},
      "cordova-plugin-background-mode": {},
      "com.testfairy.cordova-plugin": {},
      "cordova-plugin-advanced-geolocation": {},
      "cordova-plugin-headercolor": {},
      "cordova-plugin-android-permissions": {},
      "cordova-plugin-request-location-accuracy": {
        "PLAY_SERVICES_LOCATION_VERSION": "16.+"
      },
      "cordova-plugin-firebase-analytics": {
        "FIREBASE_ANALYTICS_COLLECTION_ENABLED": "true"
      },
      "cordova-plugin-androidx-adapter": {}
    },
    "platforms": [
      "android",
      "browser",
      "ios"
    ]
  }
}

Config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="1" id="com.btd.buggy" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Buggy</name>
    <description>Store App</description>
    <author email="[email protected]" href="https://test-app.com/">Buggy</author>
    <content src="index.html" />
    <access origin="*" />
    <access origin="about:*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <allow-navigation href="*" />
    <allow-navigation href="about:*" />
    <preference name="ScrollEnabled" value="false" />
    <preference name="android-minSdkVersion" value="22" />
    <preference name="BackupWebStorage" value="none" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="FadeSplashScreenDuration" value="300" />
    <preference name="SplashShowOnlyFirstTime" value="false" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="30000" />
    <preference name="ShowSplashScreenSpinner" value="false" />
    <preference name="AutoHideSplashScreen" value="false" />
    <preference name="Orientation" value="portrait" />
    <preference name="AndroidXEnabled" value="true" />
    <preference name="GradlePluginGoogleServicesEnabled" value="true" />
    <preference name="GradlePluginGoogleServicesVersion" value="4.2.0" />
    <engine name="android" spec="9.0.0" />
    <platform name="android">
        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
            <application android:usesCleartextTraffic="true" />
        </edit-config>
        <resource-file src="google-services.json" target="app/google-services.json" />
        <allow-intent href="market:*" />
        <preference name="android-targetSdkVersion" value="28" />
        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
        <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
        <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
        <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
        <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
        <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
        <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
        <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
        <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
        <resource-file src="resources/android/notification/drawable-mdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-mdpi/ic_stat_onesignal_default.png" />
        <resource-file src="resources/android/notification/drawable-hdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-hdpi/ic_stat_onesignal_default.png" />
        <resource-file src="resources/android/notification/drawable-xhdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-xhdpi/ic_stat_onesignal_default.png" />
        <resource-file src="resources/android/notification/drawable-xxhdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-xxhdpi/ic_stat_onesignal_default.png" />
        <resource-file src="resources/android/notification/drawable-xxxhdpi/ic_stat_onesignal_default.png" target="app/src/main/res/drawable-xxxhdpi/ic_stat_onesignal_default.png" />
    </platform>
    <platform name="ios">
        <resource-file src="GoogleService-Info.plist" target="app/GoogleService-Info.plist" />
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
        <icon height="114" src="resources/ios/icon/[email protected]" width="114" />
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
        <icon height="80" src="resources/ios/icon/[email protected]" width="80" />
        <icon height="120" src="resources/ios/icon/[email protected]" width="120" />
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
        <icon height="100" src="resources/ios/icon/[email protected]" width="100" />
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
        <icon height="120" src="resources/ios/icon/[email protected]" width="120" />
        <icon height="180" src="resources/ios/icon/[email protected]" width="180" />
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
        <icon height="144" src="resources/ios/icon/[email protected]" width="144" />
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
        <icon height="152" src="resources/ios/icon/[email protected]" width="152" />
        <icon height="167" src="resources/ios/icon/[email protected]" width="167" />
        <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
        <icon height="58" src="resources/ios/icon/[email protected]" width="58" />
        <icon height="87" src="resources/ios/icon/[email protected]" width="87" />
        <icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
        <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
        <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
        <splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
        <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
        <splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
        <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
        <icon height="20" src="resources/ios/icon/icon-20.png" width="20" />
        <icon height="40" src="resources/ios/icon/[email protected]" width="40" />
        <icon height="60" src="resources/ios/icon/[email protected]" width="60" />
        <icon height="29" src="resources/ios/icon/icon-29.png" width="29" />
        <icon height="58" src="resources/ios/icon/[email protected]" width="58" />
        <icon height="87" src="resources/ios/icon/[email protected]" width="87" />
        <icon height="48" src="resources/ios/icon/[email protected]" width="48" />
        <icon height="55" src="resources/ios/icon/[email protected]" width="55" />
        <icon height="88" src="resources/ios/icon/[email protected]" width="88" />
        <icon height="172" src="resources/ios/icon/[email protected]" width="172" />
        <icon height="196" src="resources/ios/icon/[email protected]" width="196" />
        <icon height="216" src="resources/ios/icon/[email protected]" width="216" />
        <splash height="2688" src="resources/ios/splash/Default-2688h~iphone.png" width="1242" />
        <splash height="1792" src="resources/ios/splash/Default-1792h~iphone.png" width="828" />
        <splash height="2436" src="resources/ios/splash/Default-2436h.png" width="1125" />
    </platform>
    <platform name="ios">
        <config-file parent="NSLocationAlwaysUsageDescription" platform="ios" target="*-Info.plist">
            <string>Buggy necesita acceder a tu ubicación para poder brindarte un mejor servicio.</string>
        </config-file>
        <config-file parent="NSLocationWhenInUseUsageDescription" platform="ios" target="*-Info.plist">
            <string>Buggy necesita acceder a tu ubicación para poder brindarte un mejor servicio.</string>
        </config-file>
    </platform>
    <plugin name="cordova-plugin-whitelist" spec="1.3.3" />
    <plugin name="cordova-plugin-statusbar" spec="2.4.2" />
    <plugin name="cordova-plugin-device" spec="2.0.2" />
    <plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
    <plugin name="cordova-plugin-ionic-webview" spec="^4.0.0" />
    <plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
    <plugin name="cordova-plugin-advanced-geolocation" spec="https://github.com/esri/cordova-plugin-advanced-geolocation.git" />
    <plugin name="cordova-plugin-uniquedeviceid" spec="1.3.2" />
    <plugin name="onesignal-cordova-plugin" spec="2.5.2" />
</widget>

App Routing Module


@NgModule({
  imports: [
    RouterModule.forRoot(routes, {
      preloadingStrategy: PreloadAllModules,
    }),
  ],
  exports: [RouterModule],
})
export class AppRoutingModule {}

where routes are all my routes, I have 38 views.

also in my App module I loaded all my services but I don't think that matters, because angular should be slow as well.

thanks for reading this.

Upvotes: 1

Views: 2446

Answers (2)

Prince Hernandez
Prince Hernandez

Reputation: 3721

basically I found the problem, the previous developers of the app left on the config.xml the following lines:

<preference name="SplashScreenDelay" value="30000" />
<preference name="ShowSplashScreenSpinner" value="false" />
<preference name="AutoHideSplashScreen" value="false" />

therefore on iOS it was not working the function to hide the splash screen, so removing those lines and adding:

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

make it work, the only thing that is weird for me is that on Android this behaviour is not present but now everything works as expected.

Upvotes: 2

Doug
Doug

Reputation: 197

I have several apps on both platforms and I can confirm that there is no such difference between platforms; the performance should be similar.

I think you need to check your code and see what takes place before you hide the splash screen. Then narrow it down by removing/adding functionality to see where the problem is.

If you use ios specific plugin that might be a reason. Also, some plugins may require different configurations depending on the platform.

Without debugging your code, it is difficult to say where the problem may be. I would encourage creating an empty project and keep adding your functionality to see where the bottleneck is. If we can identify the specific issue, we may help out to address it but without knowing the bottleneck, it is difficult to say anything...

Regardless, the simulator will always be slower compared to an actual device as you suspected

Upvotes: 0

Related Questions