Saturday 15 January 2011

ios - Scrolling UICollectionView blocks main thread -



ios - Scrolling UICollectionView blocks main thread -

i have video decoder playing h264 using avsamplebufferdisplaylayer , works until scroll uicollectionviewcontroller on same view controller. appears block main thread causing app crash. have tried putting code in block on separate queue using dispatch_async still have same blocking problem along farther performance issues on decoder.

dispatch_async(samplequeue, ^{ [samplebufferqueue addobject:(__bridge id)(samplebuffer)]; if ([avlayer isreadyformoremediadata]) { cmsamplebufferref buffer = (__bridge cmsamplebufferref)([samplebufferqueue objectatindex:0]); [samplebufferqueue removeobjectatindex:0]; [avlayer enqueuesamplebuffer:buffer]; buffer = null; nslog(@"i frame"); [avlayer setneedsdisplay]; while ([samplebufferqueue count] > 0 && [avlayer isreadyformoremediadata]) { cmsamplebufferref buffer = (__bridge cmsamplebufferref)([samplebufferqueue objectatindex:0]); [samplebufferqueue removeobjectatindex:0]; [avlayer enqueuesamplebuffer:buffer]; buffer = null; nslog(@"i frame buffer"); [avlayer setneedsdisplay]; } } else { nslog(@"avlayer not accepting info (i)"); } });

is there way give task priority on user interface actions scrolling collection view etc? apologies lack of understanding reasonably new ios.

turns out uicollectionview blocking delegate calls nsurlconnection on main thread. solved problem:

nsurlconnection *connection = [[nsurlconnection alloc] initwithrequest:request delegate:self];

changed to

nsurlconnection *connection = [[nsurlconnection alloc] initwithrequest:request delegate:self startimmediately:no]; [connection scheduleinrunloop:[nsrunloop currentrunloop] formode:nsrunloopcommonmodes]; [connection start];

ios grand-central-dispatch

No comments:

Post a Comment