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

Crash when compiling with Xcode 5 GM and running on iOS 6/7 #1204

Closed
programmingthomas opened this issue Sep 20, 2013 · 2 comments
Closed

Crash when compiling with Xcode 5 GM and running on iOS 6/7 #1204

programmingthomas opened this issue Sep 20, 2013 · 2 comments

Comments

@programmingthomas
Copy link

I've been trying to get GPUImage working in a new project, built in Xcode 5 and compiled with the iOS 7 SDK GM. I've set up my project in the exact same way as instructed in the readme (added GPUImage to project, added library and frameworks, added target dependency) and I'm trying to use the sample in the readme for filtering:

-(void)viewDidLoad {
 GPUImageVideoCamera *videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
 videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;

 GPUImageFilter *customFilter = [[GPUImageFilter alloc] init];
 GPUImageView *filteredVideoView = [[GPUImageView alloc] initWithFrame:self.view.bounds];

 // Add the view somewhere so it's visible
 [self.view addSubview:filteredVideoView];
 [videoCamera addTarget:customFilter];
 [customFilter addTarget:filteredVideoView];

 [videoCamera startCameraCapture];
}    

However, when running on a regular 32-bit device (obviously camera input doesn't work in the simulator) on either iOS 6/7 I receive the following crash:

Incident Identifier: B3DCC8B5-ECE2-47DD-821B-AB1F8636ECCC
CrashReporter Key:   74846c389b90401e09a4701872e72401c3486b79
Hardware Model:      iPod4,1
Process:         Blurred [8120]
Path:            /var/mobile/Applications/9AB7B3D2-AF9D-42CE-81B6-D56E8062A613/Blurred.app/Blurred
Identifier:      Blurred
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2013-09-19 19:42:22.044 +0100
OS Version:      iOS 6.1.3 (10B329)
Report Version:  104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000000000defe
Crashed Thread:  6

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib          0x3b960eb4 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3b961048 mach_msg + 36
2   CoreFoundation                  0x337ca040 __CFRunLoopServiceMachPort + 124
3   CoreFoundation                  0x337c8d5a __CFRunLoopRun + 810
4   CoreFoundation                  0x3373beb8 CFRunLoopRunSpecific + 352
5   CoreFoundation                  0x3373bd44 CFRunLoopRunInMode + 100
6   GraphicsServices                0x372ee2e6 GSEventRunModal + 70
7   UIKit                           0x356512fc UIApplicationMain + 1116
8   Blurred                         0x0003db5c main (main.m:16)
9   libdyld.dylib                   0x3b8aab1c start + 0

Thread 1:
0   libsystem_kernel.dylib          0x3b971d98 __workq_kernreturn + 8
1   libsystem_c.dylib               0x3b8bfcf6 _pthread_workq_return + 14
2   libsystem_c.dylib               0x3b8bfa12 _pthread_wqthread + 362
3   libsystem_c.dylib               0x3b8bf8a0 start_wqthread + 4

Thread 2 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 2:
0   libsystem_kernel.dylib          0x3b961648 kevent64 + 24
1   libdispatch.dylib               0x3b89a4ec _dispatch_mgr_invoke + 792
2   libdispatch.dylib               0x3b88cdf4 _dispatch_mgr_thread$VARIANT$up + 32

Thread 3:
0   libsystem_kernel.dylib          0x3b971d98 __workq_kernreturn + 8
1   libsystem_c.dylib               0x3b8bfcf6 _pthread_workq_return + 14
2   libsystem_c.dylib               0x3b8bfa12 _pthread_wqthread + 362
3   libsystem_c.dylib               0x3b8bf8a0 start_wqthread + 4

Thread 4 name:  WebThread
Thread 4:
0   libsystem_kernel.dylib          0x3b960eb4 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3b961048 mach_msg + 36
2   CoreFoundation                  0x337ca040 __CFRunLoopServiceMachPort + 124
3   CoreFoundation                  0x337c8d9e __CFRunLoopRun + 878
4   CoreFoundation                  0x3373beb8 CFRunLoopRunSpecific + 352
5   CoreFoundation                  0x3373bd44 CFRunLoopRunInMode + 100
6   WebCore                         0x39729500 RunWebThread(void*) + 440
7   libsystem_c.dylib               0x3b8ca30e _pthread_start + 306
8   libsystem_c.dylib               0x3b8ca1d4 thread_start + 4

Thread 5 name:  com.apple.coremedia.player.async
Thread 5:
0   libsystem_kernel.dylib          0x3b97108c __psynch_cvwait + 24
1   libsystem_c.dylib               0x3b8c2d2a _pthread_cond_wait + 642
2   libsystem_c.dylib               0x3b8ccf14 pthread_cond_wait + 36
3   CoreMedia                       0x33d218ac FigSemaphoreWaitRelative + 256
4   MediaToolbox                    0x34813e56 fpa_AsyncMovieControlThread + 22
5   CoreMedia                       0x33d3f890 figThreadMain + 192
6   libsystem_c.dylib               0x3b8ca30e _pthread_start + 306
7   libsystem_c.dylib               0x3b8ca1d4 thread_start + 4

Thread 6 name:  Dispatch queue: com.sunsetlakesoftware.GPUImage.openGLESContextQueue
Thread 6 Crashed:
0   libdispatch.dylib               0x3b88b7b8 _dispatch_semaphore_dispose$VARIANT$up + 12
1   libdispatch.dylib               0x3b88ae64 _dispatch_dispose$VARIANT$up + 32
2   libdispatch.dylib               0x3b88a856 -[OS_dispatch_object _xref_dispose] + 42
3   Blurred                         0x00047ac6 -[GPUImageVideoCamera dealloc] (GPUImageVideoCamera.m:307)
4   Blurred                         0x0004b7a2 __destroy_helper_block_ (GPUImageVideoCamera.m:923)
5   libsystem_blocks.dylib          0x3b8b8ab0 _Block_release + 220
6   libdispatch.dylib               0x3b88a996 _dispatch_queue_drain$VARIANT$up + 142
7   libdispatch.dylib               0x3b88a890 _dispatch_queue_invoke$VARIANT$up + 32
8   libdispatch.dylib               0x3b899212 _dispatch_root_queue_drain + 190
9   libdispatch.dylib               0x3b8993b4 _dispatch_worker_thread2 + 80
10  libsystem_c.dylib               0x3b8bfa0e _pthread_wqthread + 358
11  libsystem_c.dylib               0x3b8bf8a0 start_wqthread + 4

Thread 6 crashed with ARM Thread State (32-bit):
    r0: 0x1c57c070    r1: 0x00000000      r2: 0x00000001      r3: 0x9fe3dd48
    r4: 0x1c57c070    r5: 0x1c57c070      r6: 0x3d413580      r7: 0x04417e6c
    r8: 0x000da444    r9: 0x00259f01     r10: 0x000dc9c8     r11: 0x000dc9c0
    ip: 0x3b88b7ad    sp: 0x04417e6c      lr: 0x3b88ae67      pc: 0x3b88b7b8
  cpsr: 0x80000030

I specifically seem to hit the following line:

dispatch_release(frameRenderingSemaphore);

(line 307, GPUImageVideoCamera.m).

The main problem seems to occur when it hits dispatch_semaphore_dispose on Thread 6.

Are there any obvious reasons why this is occurring?

@BradLarson
Copy link
Owner

Your problem is that you're initializing your GPUImageVideoCamera instance within that method, but not hanging onto it afterward. Under ARC (which I assume is enabled for this project), this will lead to the immediate deallocation of the camera instance, as well as the filter attached to it, once that method has finished executing.

You need to make your camera instance an instance variable with a strong reference for it to last past this method. Otherwise, it won't last and you'll get the above error upon its deallocation while frames are still being processed in the filter pipeline.

@programmingthomas
Copy link
Author

Thanks! I felt like it was something stupid like this but wasn't quite sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants