【问题标题】:"Unable to monitor event loop" crash“无法监控事件循环”崩溃
【发布时间】:2020-03-27 22:55:52
【问题描述】:

我添加断点,发现它阻塞在方法中

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
// init local data
    [[PDKeychainBindings sharedKeychainBindings] setObject:@"0" forKey:kNEED_GESTURE_LOGIN];

    // register notification to notice switching RootVC
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(switchRootControllerWithType:)
                                                 name:kNoti_SwitchRootView
                                               object:nil];

    // init the third part SDK
    [self setupShareSDK];
    [self setupBugly];
    [self setupUMeng];
    [self setupIQKeyBoard];
    [self setupZhugeIOWithOptions:launchOptions];
    [self setupTrusfort];   
    // register push service
    [self setupJPushWithOptions:launchOptions];
    [self dealWithRemoteNotification:launchOptions];

    // set local flag
    [KXUserIntroManager setupFlag];

    if (self.remoteNotification) {
        if ([AccountStateManager isLogin])
            [self.loginNavigationController showGesturePDViewController];
        self.window.rootViewController = self.loginNavigationController;

    } else { 
        self.window.rootViewController = self.launchController;
    }
    return YES;
}

我也尝试了stackOverFlow中的方式,在上面的方法中加入如下代码

    NSArray *args = [NSProcessInfo processInfo].arguments;
    for(NSString *arg in args){
        if ([arg isEqualToString:@"NoAnimations"]) {
            [UIView setAnimationsEnabled:false];
        }
    }

Image link

是 didFinishLaunching 方法的细节。它只是初始化一些数据并创建一个通知

【问题讨论】:

  • 这个问题有点复杂。我无法清楚地描述它。您可以提出可能导致此问题的原因,然后我们一起讨论。
  • 您需要提供更多代码。告诉人们它崩溃的系统回调是不够的信息。贴出你写的测试,贴出didFinishLaunchingWithOptions方法的内容。也尝试这样的事情,看看它是否有帮助:stackoverflow.com/questions/40156203/…
  • 感谢您的建议,我只是使用 xcode 提供的 ui-test 包并运行测试示例而无需任何更改。它说“未收到应用程序事件循环空闲通知”。
  • 请勿发布代码图片。
  • 对不起,我正在更新

标签: ios objective-c xctest uitest


【解决方案1】:

虽然这不是对您问题的直接回答,但您的问题很可能表明您在didFinishLaunchingWithOptions 的主线程上做了太多工作。您在此方法中的主要工作是让路并让运行时启动应用程序。你正在做的恰恰相反。

【讨论】:

  • 我知道了,但是当我调试应用程序时,它可以正常运行。当我运行测试示例时,它只崩溃并报告“未收到应用程序事件循环空闲通知”。我真的很难过 :( .
  • 当您调试应用程序时,WatchDog 进程会关闭,并且在启动时间过长时不会终止您的应用程序。也许 UI 测试并非如此。不管怎样,就像我说的,这是一个你需要处理的问题,所以你不妨开始处理它。
  • 非常感谢,我会尽力解决的。如果您有其他想法,我们可以在这里讨论。 :)
猜你喜欢
  • 1970-01-01
  • 2017-03-02
  • 2014-01-31
  • 2012-05-18
  • 1970-01-01
  • 2016-06-19
  • 1970-01-01
  • 2016-01-01
  • 1970-01-01
相关资源
最近更新 更多