首页 > 解决方案 > iOS Cordova 应用程序在启动画面后挂起

问题描述

我正在编译我的应用程序的新版本,并且在设备和模拟器上出现启动屏幕后,屏幕只是一片空白。我构建的应用程序的最后一个版本运行良好......当前版本在 Android 设备上运行良好。以下日志与应用程序启动时没有问题时几乎相同,所以我不知道是什么导致了这个 WOD。我该如何解决这个问题?我还能如何获得有关屏幕为何挂起的真实日志?

在 Safari Inspector 中,我可以看到整个应用程序的 html 加载效果很好……看起来一切都在那里。同样,控制台日志中报告的 JS/AngularJS 错误为零。

我添加了一些console.logs,看看我是否可以查明事情至少到达了哪里,但即使它们在Xcode或Safari检查器中打印到控制台也无法确定。

这是我的环境:

离子信息

Ionic:

   Ionic CLI         : 5.4.4 (/usr/local/lib/node_modules/ionic)
   Ionic Framework   : ionic1 1.0.0
   @ionic/v1-toolkit : 1.0.22

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : ios 5.0.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, (and 32 other plugins)

Utility:

   cordova-res : 0.6.0 (update available: 0.9.0)
   native-run  : 0.2.8 (update available: 0.3.0)

System:

   ios-deploy : 1.9.4
   ios-sim    : 8.0.2
   NodeJS     : v10.16.3 (/usr/local/bin/node)
   npm        : 6.11.2
   OS         : macOS High Sierra
   Xcode      : Xcode 10.1 Build version 10B61

并且控制台日志,我认为以下任何错误/警告都不应该导致应用程序挂起或进入白屏 - 我以前见过所有这些,但它们都没有影响应用程序。我研究过的大多数似乎都是良性的。

2020-02-24 16:33:28.729280-0500 myApp[14811:15566848] Apache Cordova native platform version 5.0.1 is starting.
2020-02-24 16:33:28.729542-0500 myApp[14811:15566848] Multi-tasking -> Device: YES, App: YES
2020-02-24 16:33:28.790743-0500 myApp[14811:15566848] Using UIWebView
2020-02-24 16:33:28.793978-0500 myApp[14811:15566848] [CDVTimer][console] 0.138044ms
2020-02-24 16:33:28.794282-0500 myApp[14811:15566848] [CDVTimer][handleopenurl] 0.170946ms
2020-02-24 16:33:28.797984-0500 myApp[14811:15566848] Unlimited access to network resources
2020-02-24 16:33:28.798184-0500 myApp[14811:15566848] [CDVTimer][intentandnavigationfilter] 3.751993ms
2020-02-24 16:33:28.798528-0500 myApp[14811:15566848] [CDVTimer][gesturehandler] 0.252962ms
2020-02-24 16:33:28.799284-0500 myApp[14811:15566848] [CDVTimer][admob] 0.651956ms
2020-02-24 16:33:28.799605-0500 myApp[14811:15566848] Starting Facebook Connect plugin
2020-02-24 16:33:28.799703-0500 myApp[14811:15566848] [CDVTimer][facebookconnectplugin] 0.335932ms
2020-02-24 16:33:28.803213-0500 myApp[14811:15566848] [CDVTimer][file] 3.353000ms
2020-02-24 16:33:28.803581-0500 myApp[14811:15566848] Starting Firebase plugin
2020-02-24 16:33:28.810921-0500 myApp[14811:15566848] [CDVTimer][firebaseplugin] 7.617950ms
2020-02-24 16:33:28.811294-0500 myApp[14811:15566848] [CDVTimer][inappbrowser] 0.249028ms
2020-02-24 16:33:28.811595-0500 myApp[14811:15566848] [CDVTimer][uiinappbrowser] 0.189900ms
2020-02-24 16:33:28.811863-0500 myApp[14811:15566848] [CDVTimer][wkinappbrowser] 0.159979ms
2020-02-24 16:33:28.812128-0500 myApp[14811:15566848] CDVIonicKeyboard: resize mode 1
2020-02-24 16:33:28.814081-0500 myApp[14811:15566848] CDVIonicKeyboard: WARNING!!: Keyboard plugin works better with WK
2020-02-24 16:33:28.814370-0500 myApp[14811:15566848] [CDVTimer][keyboard] 2.269983ms
2020-02-24 16:33:28.821986-0500 myApp[14811:15567042] registerForRemoteNotifications
2020-02-24 16:33:28.830875-0500 myApp[14811:15566848] [CDVTimer][splashscreen] 16.288996ms
2020-02-24 16:33:28.842044-0500 myApp[14811:15566848] [CDVTimer][statusbar] 11.017084ms
2020-02-24 16:33:28.842496-0500 myApp[14811:15566848] [CDVTimer][diagnostic] 0.326037ms
2020-02-24 16:33:28.844525-0500 myApp[14811:15566848] [CDVTimer][diagnostic_location] 1.947999ms
2020-02-24 16:33:28.844721-0500 myApp[14811:15566848] [CDVTimer][diagnostic_notifications] 0.103951ms
2020-02-24 16:33:28.844770-0500 myApp[14811:15566848] [CDVTimer][TotalPluginStartup] 51.038027ms
2020-02-24 16:33:28.857988-0500 myApp[14811:15566848] GoogleService-Info.plist found, setup: [FIRApp configureWithOptions]
2020-02-24 16:33:28.889418-0500 myApp[14811:15566848] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2020-02-24 16:33:28.890284-0500 myApp[14811:15566848] [MC] Reading from public effective user settings.
2020-02-24 16:33:28.961518-0500 myApp[14811:15567038] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x280e2fda0, domain=1, instance=1>
2020-02-24 16:33:29.071782-0500 myApp[14811:15567057] Metal GPU Frame Capture Enabled
2020-02-24 16:33:29.079541-0500 myApp[14811:15567057] Metal API Validation Enabled
2020-02-24 16:33:29.249063-0500 myApp[14811:15567059] 6.3.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
2020-02-24 16:33:29.251884-0500 myApp[14811:15567059] 6.3.0 - [Firebase/Analytics][I-ACS025028] AdMob and Firebase are in use in this app, but are not linked. For analytics data consistency and integrity, it is highly recommended that you link your AdMob app to the corresponding Firebase app and re-download the GoogleServices-Info.plist file. See https://support.google.com/admob/answer/6383165 for more information.
2020-02-24 16:33:29.255383-0500 myApp[14811:15567059] 6.3.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60002000 started
2020-02-24 16:33:29.255771-0500 myApp[14811:15567059] 6.3.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2020-02-24 16:33:29.270990-0500 myApp[14811:15567042] _hasPermission: YES
2020-02-24 16:33:29.283845-0500 myApp[14811:15566848] didReceiveRegistrationToken: fOrgQHaXCTQ:APA91bFfK-xz7DpwU8AvnoXQybZY6xDawTkVwj6GtJGCbRDRz9E7IIyEvf0wycPIWffthW1J1p8JmafLu32WGWhvCJ8aoUT_cKMNERQ6fQ_7xjL-veEK5F7sPMc7BUEjee3cEbkKThSY
2020-02-24 16:33:29.293043-0500 myApp[14811:15566848] FCM direct channel = true
2020-02-24 16:33:29.303036-0500 myApp[14811:15566848] FB Hybrid app events cannot be enabled, this feature requires WKWebView
2020-02-24 16:33:29.309203-0500 myApp[14811:15567057] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x280e3b9c0, domain=1, instance=1>
2020-02-24 16:33:29.392367-0500 myApp[14811:15567038] 6.3.0 - [Firebase/Analytics][I-ACS025026] Deferring to Firebase for event data collection
2020-02-24 16:33:29.403092-0500 myApp[14811:15566848] didRegisterForRemoteNotificationsWithDeviceToken: <70ad34cb 9dac7233 966cd8b7 d1612273 03bad35a f08c430a bf1ed4c7 a257bac9>
2020-02-24 16:33:29.433757-0500 myApp[14811:15566848] Resetting plugins due to page load.
2020-02-24 16:33:29.434371-0500 myApp[14811:15566848] IAB.close() called but it was already closed.
2020-02-24 16:33:29.434464-0500 myApp[14811:15566848] IAB.close() called but it was already closed.
2020-02-24 16:33:29.457026-0500 myApp[14811:15566848] Failed to load webpage with error: The operation couldn’t be completed. (NSURLErrorDomain error -999.)
2020-02-24 16:33:29.470218-0500 myApp[14811:15566848] Resetting plugins due to page load.
2020-02-24 16:33:29.470385-0500 myApp[14811:15566848] IAB.close() called but it was already closed.
2020-02-24 16:33:29.470421-0500 myApp[14811:15566848] IAB.close() called but it was already closed.
2020-02-24 16:33:29.507982-0500 myApp[14811:15567061] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x102936400] get output frames failed, state 8196
2020-02-24 16:33:29.508234-0500 myApp[14811:15567061] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x102936400] get output frames failed, state 8196
2020-02-24 16:33:29.508700-0500 myApp[14811:15567061] TIC Read Status [1:0x0]: 1:57
2020-02-24 16:33:29.508743-0500 myApp[14811:15567061] TIC Read Status [1:0x0]: 1:57
2020-02-24 16:33:29.701653-0500 myApp[14811:15566848] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x280e572c0, domain=1, instance=1>
2020-02-24 16:33:29.713627-0500 myApp[14811:15567056] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C2.1:2][0x1028093c0] get output frames failed, state 8196
2020-02-24 16:33:29.717303-0500 myApp[14811:15567056] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C2.1:2][0x1028093c0] get output frames failed, state 8196
2020-02-24 16:33:29.718170-0500 myApp[14811:15567056] TIC Read Status [2:0x0]: 1:57
2020-02-24 16:33:29.718216-0500 myApp[14811:15567056] TIC Read Status [2:0x0]: 1:57
2020-02-24 16:33:29.719928-0500 myApp[14811:15567056] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C3.1:2][0x1028270e0] get output frames failed, state 8196
2020-02-24 16:33:29.720165-0500 myApp[14811:15567056] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C3.1:2][0x1028270e0] get output frames failed, state 8196
2020-02-24 16:33:29.720718-0500 myApp[14811:15567056] TIC Read Status [3:0x0]: 1:57
2020-02-24 16:33:29.720805-0500 myApp[14811:15567056] TIC Read Status [3:0x0]: 1:57
2020-02-24 16:33:29.787548-0500 myApp[14811:15567056] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C5.1:2][0x102832530] get output frames failed, state 8196
2020-02-24 16:33:29.788231-0500 myApp[14811:15567056] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C5.1:2][0x102832530] get output frames failed, state 8196
2020-02-24 16:33:29.788608-0500 myApp[14811:15567056] TIC Read Status [5:0x0]: 1:57
2020-02-24 16:33:29.788642-0500 myApp[14811:15567056] TIC Read Status [5:0x0]: 1:57
2020-02-24 16:33:29.914614-0500 myApp[14811:15567109] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C6.1:2][0x102833ed0] get output frames failed, state 8196
2020-02-24 16:33:29.914982-0500 myApp[14811:15567109] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C6.1:2][0x102833ed0] get output frames failed, state 8196
2020-02-24 16:33:29.918861-0500 myApp[14811:15567109] TIC Read Status [6:0x0]: 1:57
2020-02-24 16:33:29.918976-0500 myApp[14811:15567109] TIC Read Status [6:0x0]: 1:57
2020-02-24 16:33:30.569146-0500 myApp[14811:15566848] Finished load of: file:///var/containers/Bundle/Application/1613C55A-6D2F-4B41-A73F-A24DB76501E4/myApp.app/www/index.html

标签: iosxcodecordovaionic-framework

解决方案


我曾经在 Cordova 的应用程序中遇到过类似的问题(使用 ExtJS 框架编写,而不是 Ionic),该应用程序会在启动屏幕之后挂起,主要是在 iOS 上。

问题

Cordova 加载良好,但框架却没有。(出于未知原因)因此,index.html已加载并deviceready触发了事件,但框架为空且无法启动。

解决方法

我从来没有找到问题的根源(我怀疑它与你的问题无关),但由于deviceready被解雇,我在运行时检查框架是否已加载,如果没有则重新加载整个应用程序。对于用户点一个视图,闪屏只出现一次,然后淡出,屏幕保持白色(当应用程序在后台重新加载时)并且应用程序出现。

在我的index.html,类似的东西

function onDeviceReady() {
    //...

    try {
        var isFrameworkLoaded = ....

        if (isFrameworkLoaded !== true) {
            console.log("onDeviceReady() : FORCE RELOAD");
            location.reload();  // Reloads the index.html page, and doesn't reload the splashscreen
            return;
        }
    } catch (e) {
        console.warn("onDeviceReady : Error : " + e);
    }
}

推荐阅读