Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On iOS Simulator, try Camera() fails to throw CameraError but crashes in deinit() #52

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions framework/GPUImage-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
BCC49FB81CD6E3D900B63EEB /* MovieInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCC49FB71CD6E3D900B63EEB /* MovieInput.swift */; };
BCD03F0F1CA23D6300271751 /* Camera.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCD03F0E1CA23D6300271751 /* Camera.swift */; };
BCD1B1301C66A262001F2BDC /* GPUImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCD1B1251C66A262001F2BDC /* GPUImage.framework */; };
BCD1B1351C66A262001F2BDC /* GPUImageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCD1B1341C66A262001F2BDC /* GPUImageTests.swift */; };
BCD1B1431C66A695001F2BDC /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = BCD1B1411C66A68E001F2BDC /* Info.plist */; };
BCD985D21CA48CC2001FF01F /* PictureInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCD985D11CA48CC2001FF01F /* PictureInput.swift */; };
BCE316EB1CA0E5CC00323D5B /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCE316EA1CA0E5CC00323D5B /* OpenGLES.framework */; };
BCE316FA1CA0E69800323D5B /* Framebuffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE316F31CA0E69800323D5B /* Framebuffer.swift */; };
Expand Down Expand Up @@ -168,6 +166,7 @@
BCFB074C1CBF2BC1009B2333 /* ZoomBlur.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCFB073E1CBF2BC1009B2333 /* ZoomBlur.swift */; };
BCFB07991CBF4B44009B2333 /* TextureInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCFB07981CBF4B44009B2333 /* TextureInput.swift */; };
BCFB079C1CBF4B92009B2333 /* TextureOutput.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCFB079B1CBF4B92009B2333 /* TextureOutput.swift */; };
F449DE351D5C0CB900BCBC64 /* GPUImageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F449DE341D5C0CB900BCBC64 /* GPUImageTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -227,7 +226,6 @@
BCD03F0E1CA23D6300271751 /* Camera.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Camera.swift; path = Source/iOS/Camera.swift; sourceTree = "<group>"; };
BCD1B1251C66A262001F2BDC /* GPUImage.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GPUImage.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BCD1B12F1C66A262001F2BDC /* GPUImageTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GPUImageTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
BCD1B1341C66A262001F2BDC /* GPUImageTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = GPUImageTests.swift; path = Tests/iOS/GPUImageTests.swift; sourceTree = "<group>"; };
BCD1B13F1C66A676001F2BDC /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Source/iOS/Info.plist; sourceTree = SOURCE_ROOT; };
BCD1B1411C66A68E001F2BDC /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Tests/iOS/Info.plist; sourceTree = SOURCE_ROOT; };
BCD985D11CA48CC2001FF01F /* PictureInput.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PictureInput.swift; path = Source/iOS/PictureInput.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -479,6 +477,7 @@
BCFB079B1CBF4B92009B2333 /* TextureOutput.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TextureOutput.swift; path = Source/TextureOutput.swift; sourceTree = "<group>"; };
BCFB079D1CBF4E39009B2333 /* FiveInput.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = FiveInput.vsh; path = Source/Operations/Shaders/FiveInput.vsh; sourceTree = "<group>"; };
BCFB079E1CBF4E39009B2333 /* FourInput.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = FourInput.vsh; path = Source/Operations/Shaders/FourInput.vsh; sourceTree = "<group>"; };
F449DE341D5C0CB900BCBC64 /* GPUImageTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GPUImageTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -539,10 +538,10 @@
isa = PBXGroup;
children = (
BCD1B1411C66A68E001F2BDC /* Info.plist */,
BCD1B1341C66A262001F2BDC /* GPUImageTests.swift */,
F449DE341D5C0CB900BCBC64 /* GPUImageTests.swift */,
);
name = Tests;
path = GPUImageTests;
path = Tests/iOS;
sourceTree = "<group>";
};
BCE316E81CA0E59B00323D5B /* Base */ = {
Expand Down Expand Up @@ -1007,7 +1006,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BCD1B1431C66A695001F2BDC /* Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1176,7 +1174,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BCD1B1351C66A262001F2BDC /* GPUImageTests.swift in Sources */,
F449DE351D5C0CB900BCBC64 /* GPUImageTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1326,7 +1324,7 @@
BCD1B13D1C66A262001F2BDC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = GPUImageTests/Info.plist;
INFOPLIST_FILE = Tests/iOS/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.sunsetlakesoftware.GPUImageTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1336,7 +1334,7 @@
BCD1B13E1C66A262001F2BDC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = GPUImageTests/Info.plist;
INFOPLIST_FILE = Tests/iOS/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.sunsetlakesoftware.GPUImageTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
8 changes: 3 additions & 5 deletions framework/Source/iOS/Camera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,16 @@ public class Camera: NSObject, ImageSource, AVCaptureVideoDataOutputSampleBuffer
self.captureSession = AVCaptureSession()
self.captureSession.beginConfiguration()

// Add the video frame output
videoOutput = AVCaptureVideoDataOutput()
videoOutput.alwaysDiscardsLateVideoFrames = false
if let cameraDevice = cameraDevice {
self.inputCamera = cameraDevice
} else {
if let device = location.device() {
self.inputCamera = device
} else {
self.videoInput = nil
self.videoOutput = nil
self.yuvConversionShader = nil
self.inputCamera = nil
super.init()
Expand All @@ -113,7 +115,6 @@ public class Camera: NSObject, ImageSource, AVCaptureVideoDataOutputSampleBuffer
self.videoInput = try AVCaptureDeviceInput(device:inputCamera)
} catch {
self.videoInput = nil
self.videoOutput = nil
self.yuvConversionShader = nil
super.init()
throw error
Expand All @@ -122,9 +123,6 @@ public class Camera: NSObject, ImageSource, AVCaptureVideoDataOutputSampleBuffer
captureSession.addInput(videoInput)
}

// Add the video frame output
videoOutput = AVCaptureVideoDataOutput()
videoOutput.alwaysDiscardsLateVideoFrames = false

if captureAsYUV {
supportsFullYUVRange = false
Expand Down
14 changes: 14 additions & 0 deletions framework/Tests/iOS/GPUImageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import XCTest
@testable import GPUImage
import AVFoundation

class GPUImageTests: XCTestCase {

Expand All @@ -33,4 +34,17 @@ class GPUImageTests: XCTestCase {
}
}

func testCameraError() {
if ( PhysicalCameraLocation.BackFacing.device() == nil && PhysicalCameraLocation.FrontFacing.device() == nil) {
do {
let camera = try Camera(sessionPreset:AVCaptureSessionPreset640x480)
XCTFail("Camera():\(camera) should throw error on Simulator")
} catch {
XCTAssert(error is CameraError, "Exception should be CameraError")
}
} else {
XCTAssert(true, "Untestable condition: camera available")
}
}

}