Added an autorelease pool to frame tick calls; InputSources were staying allocated too long, likely due to a thread without an autorelease pool

This commit is contained in:
Zakk 2016-12-18 06:15:56 -05:00
parent d2a84e24f1
commit 50b55035f3
6 changed files with 41 additions and 32 deletions

View file

@ -1799,7 +1799,6 @@
-(void)setStagingLayout:(SourceLayout *)stagingLayout
{
[stagingLayout restoreSourceList:nil];
[stagingLayout setupMIDI];
@ -1850,7 +1849,6 @@
-(void)setSelectedLayout:(SourceLayout *)selectedLayout
{
[selectedLayout setAddLayoutBlock:^(SourceLayout *layout) {
layout.in_live = YES;
@ -2618,8 +2616,7 @@
return;
}
@autoreleasepool {
@ -2635,6 +2632,7 @@
_frame_time = startTime;
@autoreleasepool {
[self newFrame];
}
@ -2672,12 +2670,10 @@
CVPixelBufferRef newFrame;
double nfstart = [self mach_time_seconds];
newFrame = [self.previewCtx.layoutRenderer currentImg];
double nfdone = [self mach_time_seconds];
double nftime = nfdone - nfstart;
_renderedFrames++;

View file

@ -1300,8 +1300,7 @@ static NSArray *_sourceTypes = nil;
-(void)dealloc
{
NSLog(@"DEALLOC INPUT");
[self deregisterVideoInput:self.videoInput];
for(id vInput in self.videoSources)
{

View file

@ -227,6 +227,7 @@
CVPixelBufferRef destFrame = NULL;
CGFloat frameWidth, frameHeight;
[self.layout frameTick];
if (_transitionLayout)
{

View file

@ -1438,6 +1438,7 @@
if (toDelete)
{
self.selectedSource = nil;
self.mousedSource = nil;
@ -1718,6 +1719,7 @@
-(void)sourceWasDeleted:(NSNotification *)notification
{
InputSource *toDel = notification.object;
[self purgeConfigForInput:toDel];
}

View file

@ -484,6 +484,7 @@
mylist = self.sourceList;
}
NSArray *listCopy = [mylist sortedArrayUsingDescriptors:@[_sourceDepthSorter, _sourceUUIDSorter]];
return listCopy;
}
@ -1506,7 +1507,9 @@
[delSource willDelete];
[self willChangeValueForKey:@"topLevelSourceList"];
[[self mutableArrayValueForKey:@"sourceList" ] removeObject:delSource];
@synchronized (self) {
[[self mutableArrayValueForKey:@"sourceList" ] removeObject:delSource];
}
[self generateTopLevelSourceList];
[self didChangeValueForKey:@"topLevelSourceList"];
@ -1529,6 +1532,8 @@
[[NSNotificationCenter defaultCenter] postNotificationName:CSNotificationInputDeleted object:delSource userInfo:nil];
delSource.sourceLayout = nil;
}
@ -1727,35 +1732,41 @@
-(void)frameTick
{
bool needsResize = NO;
NSSize curSize = NSMakeSize(self.canvas_width, self.canvas_height);
if (!NSEqualSizes(curSize, _rootSize))
{
@autoreleasepool {
self.rootLayer.bounds = CGRectMake(0, 0, self.canvas_width, self.canvas_height);
bool needsResize = NO;
NSSize curSize = NSMakeSize(self.canvas_width, self.canvas_height);
_rootSize = curSize;
needsResize = YES;
}
NSArray *listCopy = [self sourceListOrdered];
for (InputSource *isource in listCopy)
{
if (needsResize)
if (!NSEqualSizes(curSize, _rootSize))
{
isource.needsAdjustPosition = YES;
isource.needsAdjustment = YES;
self.rootLayer.bounds = CGRectMake(0, 0, self.canvas_width, self.canvas_height);
_rootSize = curSize;
needsResize = YES;
}
if (isource.active)
{
[isource frameTick];
}
NSArray *listCopy;
listCopy = [self sourceListOrdered];
for (InputSource *isource in listCopy)
{
if (needsResize)
{
isource.needsAdjustPosition = YES;
isource.needsAdjustment = YES;
}
if (isource.active)
{
[isource frameTick];
}
}
}
}