cocoa - Mind boggling QTMovie export crash -
hey guys... i'm @ wits end here. i've been focusing on issue last 3 days seems, , i'm still no closer solving it. i've got queue of videos i'm converting 1 after other in background thread. of time works expected, every often, weird crash, @ same point. can't life of me figure out why it's happening. i've got garbage collection enabled. here conversion code.
here stack trace.
edit: after bit more debugging, conclusion maybe garbage collector related. if place following line before line converts video, drastic increase in amount of these errors see...
[[nsgarbagecollector defaultcollector] collectexhaustively];
nsinvalidargumentexception -[nspathstore2 objectforkey:]: unrecognized selector sent instance 0x1073570 ( 0 corefoundation 0x92fc16ba __raiseerror + 410 1 libobjc.a.dylib 0x901b4509 objc_exception_throw + 56 2 corefoundation 0x9300e90b -[nsobject(nsobject) doesnotrecognizeselector:] + 187 3 corefoundation 0x92f67c36 ___forwarding___ + 950 4 corefoundation 0x92f67802 _cf_forwarding_prep_0 + 50 5 qtkit 0x903d3280 movieprogressproc + 62 6 quicktime 0x95a66062 convertfileprogress + 212 7 quicktime3gpp 0x1e7bcaa2 spit3gp2_progress + 180 8 quicktime3gpp 0x1e7c01d8 spit3gp2_fromprocedurestodataref + 3438 9 carboncore 0x90b0d054 _zl38callcomponentfunctioncommonwithstorageppcp19componentparameterspflvem + 54 10 quicktime3gpp 0x1e7be33d spit3gp2_componentdispatch + 129 11 carboncore 0x90b057c9 callcomponentdispatch + 29 12 quicktime 0x95befb97 movieexportfromprocedurestodataref + 49 13 quicktime3gpp 0x1e7bdf84 spit3gp2_todataref + 1987 14 carboncore 0x90b1865d callcomponentstorage_4444444 + 63 15 carboncore 0x90b0d054 _zl38callcomponentfunctioncommonwithstorageppcp19componentparameterspflvem + 54 16 quicktime3gpp 0x1e7be33d spit3gp2_componentdispatch + 129 17 carboncore 0x90b057c9 callcomponentdispatch + 29 18 quicktime 0x95befbe2 movieexporttodataref + 73 19 quicktime 0x95a6e9bb convertmovietodataref_priv + 1690 20 quicktime 0x95bdc591 convertmovietodataref + 71 21 qtkit 0x903e0954 -[qtmovie_quicktime writetodatareference:withattributes:error:] + 2692 22 qtkit 0x903c5110 -[qtmovie_quicktime writetofile:withattributes:error:] + 111 23 mevee 0x0005871d -[conversionqueue convertvideo:] + 509 24 mevee 0x00058341 -[conversionqueue startconvertingitems] + 145 25 foundation 0x9520fbf0 -[nsthread main] + 45 26 foundation 0x9520fba0 __nsthread__main__ + 1499 27 libsystem.b.dylib 0x9475a85d _pthread_start + 345 28 libsystem.b.dylib 0x9475a6e2 thread_start + 34 ) - (id) init { if(!(self = [super init])) return self; convertingindex = 0; conversionpaths = [[nsmutablearray alloc] init]; [conversionpaths addobject:@"/users/morgan/desktop/convertable media/movies/2 fast 2 furious/2 fast 2 furious.mp4"]; [conversionpaths addobject:@"/users/morgan/desktop/convertable media/movies/101 dalmations/101 dalmations.mp4"]; [conversionpaths addobject:@"/users/morgan/desktop/convertable media/movies/300/300.mp4"]; [conversionpaths addobject:@"/users/morgan/desktop/convertable media/movies/1408/1408.mp4"]; [conversionpaths addobject:@"/users/morgan/desktop/convertable media/movies/a few men/a few men.mp4"]; [conversionpaths addobject:@"/users/morgan/desktop/convertable media/movies/a goofy movie/a goofy movie.mp4"]; [conversionpaths addobject:@"/users/morgan/desktop/convertable media/movies/a single man/a single man.mp4"]; [conversionpaths addobject:@"/users/morgan/desktop/convertable media/movies/a view kill/a view kill.mp4"]; [conversionpaths addobject:@"/users/morgan/desktop/convertable media/movies/across universe/across universe.mp4"]; backgroundthread = [[nsthread alloc] initwithtarget:self selector:@selector(startconvertingitems) object:nil]; [backgroundthread start]; return self; } - (void) startprocessingqueue { } - (void) startconvertingitems { nsinteger iterations = 0; while(iterations < 100) { nsstring* nextpath = [conversionpaths objectatindex:convertingindex]; nslog(@"iteration %d", iterations); [self convertvideo:nextpath]; convertingindex += 1; if(convertingindex >= [conversionpaths count]) convertingindex = 0; iterations += 1; } } - (void) openmovieonmainthread:(nsstring*)path { nserror* error = nil; movie = [[qtmovie alloc] initwithfile:path error:&error]; if(movie == nil || error != nil || ![movie detachfromcurrentthread]) movie = nil; } - (void) closemovieonmainthread { //[movie attachtocurrentthread]; //[movie release]; } - (bool) convertvideo: (nsstring*)path { [self performselectoronmainthread:@selector(openmovieonmainthread:) withobject:path waituntildone:yes]; if(movie == nil) { nslog(@"error opening movie"); return no; } [qtmovie enterqtkitonthreaddisablingthreadsafetyprotection]; [movie attachtocurrentthread]; [movie setdelegate:self]; nsstring* tempitempath = @"/users/morgan/desktop/test.mp4"; nsdictionary *attrs = [nsdictionary dictionarywithobjectsandkeys: [nsnumber numberwithbool:yes], qtmovieexport, [nsnumber numberwithlong:'3gpp'], qtmovieexporttype, nil]; nserror* error = nil; if(![movie writetofile:tempitempath withattributes:attrs error:&error]) { nslog(@"error converting movie"); return no; } [movie invalidate]; [movie detachfromcurrentthread]; [qtmovie exitqtkitonthread]; [self performselectoronmainthread:@selector(closemovieonmainthread) withobject:nil waituntildone:yes]; return yes; } - (bool)movie:(qtmovie *)amovie shouldcontinueoperation:(nsstring *)op withphase:(qtmovieoperationphase)phase atpercent:(nsnumber *)percent withattributes:(nsdictionary *)attributes { switch (phase) { case qtmovieoperationbeginphase: nslog(@"conversion started"); break; case qtmovieoperationupdatepercentphase: nslog(@"conversion progress: %f", [percent floatvalue]); break; case qtmovieoperationendphase: nslog(@"conversion finished."); break; } return yes; }
ahhh... found out stupid garbage collector. reworked app work reference counting rather garbage collection, , smooth sailing. has else come across similar garbage collection bugs? had strong reference root object movie file, don't think problem.
Comments
Post a Comment