Application failed to resume in time

前端 未结 2 1736
滥情空心
滥情空心 2021-02-04 21:57

I encounter a \"failed to resume in time\" crash (which I assume to be watchdog related) on a very specific scenario: Only when resuming from background, and only when doing it

相关标签:
2条回答
  • 2021-02-04 22:37

    Yes, this is watchdog related.

    Is it possible that your writing process takes too much time on the main thread and is blocking that one? That would explain why no log data is shown when coming back from background and that this only happens when resuming very shortly after going to background.

    I would recommend doing the following:

    1. Writing your data when going into background not in the main thread, but using a background task via:

      [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{...

    2. If the app resumes while that background task is still running, act correspondingly, e.g. don't read until it finished writing, or don't write again if it is still writing. So you need to be aware of your own state

    Biggest rule: never block the main thread with anything might take longer than a fraction of a second. Move that all into background threads or in this scenario into a background task.

    0 讨论(0)
  • 2021-02-04 22:48

    find in which thread you app is crashing put that thread in dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(dispatch_get_main_queue(), ^{ // run that crashing thread here. }); });

    0 讨论(0)
提交回复
热议问题