简体   繁体   English

Ionic ios 应用程序真的很慢,但在 android 上很快

[英]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).我用 ionic 创建了一个应用程序,它几乎完成了(它是一个购物车应用程序)。 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 .其中XXXXXiosandroid

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.在为 android 构建应用程序时(在签名等之后),应用程序在启动屏幕上需要 3 或 4 秒,这是可以接受的时间,但是当我使用相同的命令为ios构建时,问题就出现了,我试图在 XCode 中测试该应用程序并且它可以工作,唯一的问题是该应用程序需要 30 秒,这使得该应用程序无法使用,我可以弄清楚原因。

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包 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="test@test.com" 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/icon@2x.png" width="114" />
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
        <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
        <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
        <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
        <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
        <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
        <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
        <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
        <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
        <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
        <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
        <icon height="87" src="resources/ios/icon/icon-small@3x.png" 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/icon-20@2x.png" width="40" />
        <icon height="60" src="resources/ios/icon/icon-20@3x.png" width="60" />
        <icon height="29" src="resources/ios/icon/icon-29.png" width="29" />
        <icon height="58" src="resources/ios/icon/icon-29@2x.png" width="58" />
        <icon height="87" src="resources/ios/icon/icon-29@3x.png" width="87" />
        <icon height="48" src="resources/ios/icon/icon-24@2x.png" width="48" />
        <icon height="55" src="resources/ios/icon/icon-27.5@2x.png" width="55" />
        <icon height="88" src="resources/ios/icon/icon-44@2x.png" width="88" />
        <icon height="172" src="resources/ios/icon/icon-86@2x.png" width="172" />
        <icon height="196" src="resources/ios/icon/icon-98@2x.png" width="196" />
        <icon height="216" src="resources/ios/icon/icon-108@2x.png" 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.其中路线是我所有的路线,我有 38 次观看。

also in my App module I loaded all my services but I don't think that matters, because angular should be slow as well.同样在我的 App 模块中,我加载了所有服务,但我认为这并不重要,因为 angular 也应该很慢。

thanks for reading this.感谢您阅读本文。

basically I found the problem, the previous developers of the app left on the config.xml the following lines:基本上我发现了问题,应用程序的以前的开发人员在config.xml上留下了以下几行:

<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:因此,在iOS上,隐藏启动画面的功能不起作用,因此删除这些行并添加:

<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.让它工作,对我来说唯一奇怪的是,在Android上不存在这种行为,但现在一切都按预期工作。

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.如果您使用特定于 ios 的插件,那可能是一个原因。 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无论如何,与您怀疑的实际设备相比,模拟器总是会更慢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM