Bug 11732 - AVCaptureVideoDataOutputSampleBufferDelegate eventually stops working with SGEN enabled
Summary: AVCaptureVideoDataOutputSampleBufferDelegate eventually stops working with SG...
Status: RESOLVED DUPLICATE of bug 11836
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.3.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
Depends on:
Reported: 2013-04-11 09:25 UTC by Redth
Modified: 2013-04-25 11:00 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Repro Project (9.57 KB, application/zip)
2013-04-11 09:25 UTC, Redth

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Redth 2013-04-11 09:25:47 UTC
Created attachment 3799 [details]
Repro Project

When SGEN is enabled, the AVCaptureVideoDataOutputSampleBufferDelegate's DidOutputSampleBuffer, for an AVCaptureSession does not get called in a session.  It works the first time (or first couple times), but subsequent sessions do not work.  It almost seems like something is being GC'd, but I can't figure out what I might be not holding a reference to that would be causing this issue.

I've included a pretty simplified repro project with the problem as isolated and minimal as possible!

Here are the steps to reproduce the behaviour:

1. Build and run the repro on an iOS device
2. Tap the 'Play' bar button item
3. Notice the "SAMPLE" lines in the application output, this is happening inside OutputRecorder's 'DidOutputSampleBuffer' method.
4. Tap 'Stop'
5. Repeat Steps 2 and 3.  You may need to try this a few times, but eventually, notice that "SAMPLE" no longer appears in the output, as DidOutputSampleBuffer is no longer called.
6. Change the project to not use SGEN and repeat Steps 1-5, notice that it works every time now.
Comment 1 Miguel de Icaza [MSFT] 2013-04-11 20:26:26 UTC
Did you release the resources passed on the DidOutputSampelBuffer?

I think that is a FAQ at this point.
Comment 2 Redth 2013-04-11 20:35:38 UTC
Yeah I've been pretty careful to release resources, but that still wouldn't explain why the DidOutputSampleBuffer is never called on a new AVCaptureSession, with a new AVCaptureVideoDataOutputSampleBufferDelegate instance... Basically after everything is created again, the delegate stops getting called (that includes the dropped frame called).  I could see if I was getting an out of memory exception, but that's not the case.
Comment 3 Miguel de Icaza [MSFT] 2013-04-11 20:49:13 UTC
So the smaple is correct, it is disposing the buffer.

It works on 6.2 so far.

So it is possible a 6.3 issue
Comment 4 Rolf Bjarne Kvinge [MSFT] 2013-04-25 10:28:12 UTC
I can reproduce it with 6.3 (from master-3.0).

The issue seems to be our internal usage of NSAutoreleasePool - we call [pool release] when threads exists, but something bad happens and [pool release] ends up exiting the thread immediately, preventing any subsequent code to be executed. Since we use locks in our implementation, the lock will never be released (and when more threads want to create/destroy NSAutoreleasePools they end up deadlocking).
Comment 5 Sebastien Pouliot 2013-04-25 11:00:05 UTC
sounds identical to #11836 and another test case to confirm it works

*** This bug has been marked as a duplicate of bug 11836 ***