I'm fairly new to iOS development but I'm starting to grasp some of the more complicated concepts. I currently have an application that implements an AVCam to capture video. The AVCam is created on a separate thread, but uses a view that is in my main xib file. When the camera is done capturing, it calls a complete function in my ViewController class. Within the complete function I call a number of other functions that update the UI as well as a few NSLogs. Everything seems to work fine, I see the logs in the console immediately, but the UI takes another 3 seconds to update. I've tried using instruments to find the offending code, but I can't seem to find it. Is there another way to determine what is blocking by UI?
Here is the code called when the recording is complete;
-(void)movieRecordingCompleted{ [HUD hide:YES]; NSLog(@"movieRecordingCompleted"); [self showModalViewController]; NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie.mov"]; NSLog(@"pathToMovie: %@", pathToMovie); pathToTreatedVid = pathToMovie; NSLog(@"File Save Called"); UISaveVideoAtPathToSavedPhotosAlbum(pathToMovie, nil, NULL, NULL); }
Everything is logged immediately, but the progress HUD and the modal view controller don't trigger for about 2 - 5 seconds, it's very strange.
Here is the before and after state of the threads (when it is frozen vs when it becomes unfrozen).
1 Answer. Show activity on this post. You should never block UI Thread. When you hold UI Thread for too long, this is when the system will show a dialog saying XXX is not responding and ask user to kill your application.
If the mutex is already locked by another thread, the subroutine blocks the calling thread until the mutex is unlocked. If the mutex is already locked by the calling thread, the subroutine might block forever or return an error depending on the type of mutex.
Try to Pause program execution (there is a button for that in bottom panel of Xcode
, the third one)
Navigator panel
), Debug Navigator
main
function, and mb you can figure out by methods in this thread, what takes so long to update your UI. The method that are working right now is the top black one usually(with grey colour listed obj-c
internal methods).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With