【问题标题】:Ionic 2 : What happens during splash screen?Ionic 2:启动画面期间会发生什么?
【发布时间】:2017-06-29 12:16:55
【问题描述】:

我构建了一个 Ionic 2 应用程序,我想知道在应用程序启动屏幕期间究竟发生了什么?

您能否建议我使用高效的分析工具来分析我的应用程序的所有性能,即使是在这个初始屏幕期间也是如此?

我的应用在生产模式下会在 6 秒内初始化(Honor 6x pro)。我觉得太过分了,你觉得呢?

感谢您的帮助!

我的 config.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.myapp722890" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  <name>MyApp</name>
  <description>Mobile version of MyApp</description>
  <author email="my mail" href="https://toto/">toto</author>
  <content src="index.html"/>
  <access origin="*"/>
  <allow-navigation href="http://ionic.local/*"/>
  <allow-navigation href="http://my-ip:8100"/>
  <allow-navigation href="*"/>
  <allow-intent href="http://*/*"/>
  <allow-intent href="https://*/*"/>
  <allow-intent href="tel:*"/>
  <allow-intent href="sms:*"/>
  <allow-intent href="mailto:*"/>
  <allow-intent href="geo:*"/>
  <platform name="android">
    <allow-intent href="market:*"/>
    <icon src="resources\android\icon\drawable-ldpi-icon.png" density="ldpi"/>
    <icon src="resources\android\icon\drawable-mdpi-icon.png" density="mdpi"/>
    <icon src="resources\android\icon\drawable-hdpi-icon.png" density="hdpi"/>
    <icon src="resources\android\icon\drawable-xhdpi-icon.png" density="xhdpi"/>
    <icon src="resources\android\icon\drawable-xxhdpi-icon.png" density="xxhdpi"/>
    <icon src="resources\android\icon\drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
    <splash src="resources\android\splash\drawable-land-ldpi-screen.png" density="land-ldpi"/>
    <splash src="resources\android\splash\drawable-land-mdpi-screen.png" density="land-mdpi"/>
    <splash src="resources\android\splash\drawable-land-hdpi-screen.png" density="land-hdpi"/>
    <splash src="resources\android\splash\drawable-land-xhdpi-screen.png" density="land-xhdpi"/>
    <splash src="resources\android\splash\drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/>
    <splash src="resources\android\splash\drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/>
    <splash src="resources\android\splash\drawable-port-ldpi-screen.png" density="port-ldpi"/>
    <splash src="resources\android\splash\drawable-port-mdpi-screen.png" density="port-mdpi"/>
    <splash src="resources\android\splash\drawable-port-hdpi-screen.png" density="port-hdpi"/>
    <splash src="resources\android\splash\drawable-port-xhdpi-screen.png" density="port-xhdpi"/>
    <splash src="resources\android\splash\drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>
    <splash src="resources\android\splash\drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>
  </platform>
  <platform name="ios">
    <allow-intent href="itms:*"/>
    <allow-intent href="itms-apps:*"/>
  </platform>
  <preference name="webviewbounce" value="false"/>
  <preference name="UIWebViewBounce" value="false"/>
  <preference name="DisallowOverscroll" value="true"/>
  <preference name="android-minSdkVersion" value="16"/>
  <preference name="BackupWebStorage" value="none"/>
  <preference name="loadUrlTimeoutValue" value="60000" />
  <preference name="SplashMaintainAspectRatio" value="true"/>
  <preference name="FadeSplashScreenDuration" value="300"/>
  <preference name="SplashShowOnlyFirstTime" value="true"/>
  <preference name="SplashScreen" value="screen"/>
  <preference name="SplashScreenDelay" value="500"/>
  <preference name="AutoHideSplashScreen" value="false"/>
  <preference name="FadeSplashScreen" value="false"/>
  <feature name="StatusBar">
    <param name="ios-package" onload="true" value="CDVStatusBar"/>
  </feature>
  <plugin name="ionic-plugin-keyboard" spec="~2.2.1"/>
  <plugin name="cordova-plugin-whitelist" spec="1.3.1"/>
  <plugin name="cordova-plugin-console" spec="1.0.5"/>
  <plugin name="cordova-plugin-statusbar" spec="2.2.1"/>
  <plugin name="cordova-plugin-device" spec="1.1.4"/>
  <plugin name="cordova-plugin-splashscreen" spec="~4.0.1"/>
  <plugin name="cordova-sqlite-storage" spec="~2.0.2"/>
  <plugin name="cordova-base64-to-gallery" spec="~4.1.2"/>
  <plugin name="mx.ferreyra.callnumber" spec="~0.0.2"/>
  <icon src="resources\android\icon\drawable-xhdpi-icon.png"/>
</widget>

我的 platform.ready 函数:

platform.ready().then(() => {
      StatusBar.styleDefault();
      Splashscreen.hide(); 
    });

【问题讨论】:

  • 我不知道 ionic,但在 ionic 中为闪屏期间发生的事情编写代码的不是你吗?
  • 不,不是我。我认为初始化插件和组件,但我不确定。
  • 许多人通常会在启动画面中保持延迟以使其出现一段时间。检查您是否写了任何延迟
  • 当然。在配置文件中,我有 3000 毫秒的延迟。但我的启动画面停留在超过 6000 毫秒。我会尝试删除默认延迟。

标签: android ios performance ionic2 profiling


【解决方案1】:

使用ionic build android --prod 构建可以解决问题。大大减少了应用的初始化时间。

【讨论】:

  • 我已经这样做了。事实上,它在我的安卓设备上大大减少了时间:14 秒到 6 秒。但我想知道为什么我要保留这 6 秒。
  • 我认为这取决于您的 platform.ready 代码。也许你可以把它贴在这里,让我看看。
  • 你能把你的 config.xml 文件贴在这里吗?
  • 我的 platform.ready : StatusBar.styleDefault();闪屏.hide();
猜你喜欢
  • 1970-01-01
  • 2018-02-18
  • 1970-01-01
  • 1970-01-01
  • 2017-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多