Note that there are some explanatory texts on larger screens.

plurals
  1. POUnhiding a view is very slow in CTCallCenter callEventHandler
    text
    copied!<p>Reposting with more concise and focused question after original question went unanswered. Also adding more insight into the problem after another day of research:</p> <p>In my app delegate (<code>didFinishLaunching</code>), I set up a <code>callEventHandler</code> on <code>CTCallCenter</code>. The idea is that when a callState changes, I post a notification with a userInfo dict containing the <code>call.callState</code>. In my view, I observe this notification, and when the <code>userInfo</code> dict contains a value of <code>CTCallDisconnected</code>, I want to unhide a view.</p> <p>The problem I'm having is that the unhiding aspect is taking, almost consistenly, ~ 7 seconds. Everything else is working fine, and I know this because I <code>NSLog</code> before and after the unhiding, and those logs appear immediately, but the darned view still lags for 7 seconds.</p> <p>Here's my code:</p> <p>appDidFinishLaunching:</p> <pre><code>self.callCenter = [[CTCallCenter alloc] init]; self.callCenter.callEventHandler = ^(CTCall* call) { // anounce that we've had a state change in our call center NSDictionary *dict = [NSDictionary dictionaryWithObject:call.callState forKey:@"callState"]; [[NSNotificationCenter defaultCenter] postNotificationName:@"CTCallStateDidChange" object:self userInfo:dict]; }; </code></pre> <p>I then listen for this notification when a user taps a button that dials a phone number:</p> <pre><code>[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ctCallStateDidChange:) name:@"CTCallStateDidChange" object:nil]; </code></pre> <p>Then, in ctCallStateDidChange:</p> <pre><code>- (void)ctCallStateDidChange:(NSNotification *)notification { NSLog(@"121"); NSString *callInfo = [[notification userInfo] objectForKey:@"callState"]; if ([callInfo isEqualToString:CTCallStateDisconnected]) { NSLog(@"before show"); [self.view viewWithTag:kNONEMERGENCYCALLSAVEDTOLOG_TAG].hidden = NO; NSLog(@"after show"); } } </code></pre> <p>I've tracked the problem down to the if condition in the above code sample:</p> <pre><code> if ([[userInfo valueForKey:@"userInfo"] valueForKey:@"callState"] == CTCallStateDisconnected) { </code></pre> <p>If I simply replace that with:</p> <pre><code>if (1 == 1) { </code></pre> <p>Then the view appears immediately!</p> <p>The thing is, those <code>NSLog</code> statements are logging immediately, but the view is lagging in it's unhiding. How could that condition cause only part of it's block to execute immediately, and the rest to wait ~ 7 seconds?</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload