Application got stuck with CPU usage up to 100%

1.2k Views Asked by At

My application stuck with CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION. In my application, I called an C function which is async. I show an waiting msg during the execution.
When this function is terminated, it calls a delegate to close that waiting msg and show in same time an AlertView.

I use gcd to show the alertview

dispatch_async(dispatch_queue_create("com.myapp.service.waitingmessage", nil), ^{
            dispatch_async(dispatch_get_main_queue(), ^{
            UIAlertView *anAlert = ...
            [anAlert show];
             });
        });

Here is the screenshot of the Debugger XCode when application got stuck. I see also that the CPU usage of my application is up to 100%, maybe that why the application is suspended by the system.

enter image description here

1

There are 1 best solutions below

2
David Ansermot On

Use dispatch_sync() in place of dispatch_async(dispatch_get_main_queue(), ^{...

You can't update the UI from a background thread.