Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix infinite loops related to endProcess on GPUImageFilter #1295

Merged
merged 1 commit into from

2 participants

@achambers16

When removeTarget is called on a GPUImageFilter that contains a loop in the filter outputs (such as GPUImageLowPassFilter), an infinite loop is created while tearing down the filters. This loop comes from recursive calls to endProcess.

We can avoid this by adding a status flag in the GPUImageFilter and GPUImageFilterGroup to check if the filter has already started the endProcess method and do no work if it has already started.

This resolves issue: #793

@BradLarson BradLarson merged commit 2e8df3d into from
@BradLarson
Owner

Seems to make sense. I seem to recall trying something similar elsewhere, but I can't find it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 8, 2013
  1. @achambers16

    Fixes infinite loops when call endProcess by adding a flag to check i…

    achambers16 authored
    …f the filter has already started the end process
This page is out of date. Refresh to see the latest.
View
1  framework/Source/GPUImageFilter.h
@@ -57,6 +57,7 @@ typedef struct GPUMatrix3x3 GPUMatrix3x3;
GLfloat backgroundColorRed, backgroundColorGreen, backgroundColorBlue, backgroundColorAlpha;
BOOL preparedToCaptureImage;
+ BOOL isEndProcessing;
// Texture caches are an iOS-specific capability
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
View
9 framework/Source/GPUImageFilter.m
@@ -1002,9 +1002,14 @@ - (CGSize)maximumOutputSize;
- (void)endProcessing
{
- for (id<GPUImageInput> currentTarget in targets)
+ if (!isEndProcessing)
{
- [currentTarget endProcessing];
+ isEndProcessing = YES;
+
+ for (id<GPUImageInput> currentTarget in targets)
+ {
+ [currentTarget endProcessing];
+ }
}
}
View
1  framework/Source/GPUImageFilterGroup.h
@@ -4,6 +4,7 @@
@interface GPUImageFilterGroup : GPUImageOutput <GPUImageInput, GPUImageTextureDelegate>
{
NSMutableArray *filters;
+ BOOL isEndProcessing;
}
@property(readwrite, nonatomic, strong) GPUImageOutput<GPUImageInput> *terminalFilter;
View
9 framework/Source/GPUImageFilterGroup.m
@@ -182,9 +182,14 @@ - (CGSize)maximumOutputSize;
- (void)endProcessing;
{
- for (GPUImageOutput<GPUImageInput> *currentFilter in _initialFilters)
+ if (!isEndProcessing)
{
- [currentFilter endProcessing];
+ isEndProcessing = YES;
+
+ for (id<GPUImageInput> currentTarget in targets)
+ {
+ [currentTarget endProcessing];
+ }
}
}
Something went wrong with that request. Please try again.