Friday, 15 February 2013

iphone - self.layer renderInContext:context in drawRect method gives Bad Access in ipad but not in simulator -



iphone - self.layer renderInContext:context in drawRect method gives Bad Access in ipad but not in simulator -

i working in app , in video recording. capture images , create video code follows

- (void) drawrect:(cgrect)rect { nsdate* start = [nsdate date]; cgcontextref context = [self createbitmapcontextofsize:self.frame.size]; nslog(@"context value %@",context); [self.layer renderincontext:context]; cgimageref cgimage = cgbitmapcontextcreateimage(context); uiimage* background = [uiimage imagewithcgimage: cgimage]; cgimagerelease(cgimage); self.currentscreen = background; if (_recording) { float milliselapsed = [[nsdate date] timeintervalsincedate:startedat] * 1000.0; [self writevideoframeattime:cmtimemake((int)milliselapsed, 1000)]; } float processingseconds = [[nsdate date] timeintervalsincedate:start]; delayremaining = (1.0 / self.framerate) - processingseconds; [self performselectorinbackground:@selector(setneedsdisplay) withobject:nil]; }

now problem method called recursively , when stop recording gives me exc_bad_access.

it works fine in simulatoor bot crash in device, how can solve issue?

you shouldn’t doing in drawrect:, reason override drawrect: custom drawing (which not). shouldn’t phone call setneedsdisplay on background thread, gui method can called main thread. depending on how createbitmapcontextofsize: method , environment might need release bitmap context object.

iphone ios objective-c xcode

No comments:

Post a Comment