openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.94k stars 2.55k forks source link

ofQTKitPlayer deadlock on delete #1916

Closed kronick closed 10 years ago

kronick commented 11 years ago

The following code causes a deadlock on the "delete" call (calling player->close() causes the same problem) while clearing a large video file (I'm using one that's ~2GB):

ofQTKitPlayer *player new ofQTKitPlayer();
player->loadMovie("a_large_video.mov", OF_QTKIT_DECODE_TEXTURE_ONLY);

delete player;

It seems to work fine when using OF_QTKIT_DECODE_PIXELS_AND_TEXTURE.

Stack trace is below. The last non-assembly bits are in [QTKitMovieRenderer dealloc]. This is on a iMac i7 OSX 10.8.2.

When #0 0x996e091a in __psynch_mutexwait ()

1 0x93b7c13b in pthread_mutex_lock ()

2 0x9a34e9ec in QTMLGrabMutex ()

3 0x9a38f51d in QTVisualGraphGrabConfiguringMutex ()

4 0x9858e31b in ___lldb_unnamed_function22307$$QuickTimeComponents ()

5 0x955c091f in callComponentStorage_444 ()

6 0x955b1abf in CallComponentFunctionCommonWithStorage(char, ComponentParameters, long ()(), unsigned long) ()

7 0x955b1aff in CallComponentFunctionWithStorageProcInfo ()

8 0x9858ddf6 in BaseVC_ComponentDispatch ()

9 0x9552baee in CallComponent ()

10 0x9552bb65 in DelegateComponentCall ()

11 0x9858e592 in OpenGLTVC_ComponentDispatch ()

12 0x9552baee in CallComponent ()

13 0x9552bb48 in CallComponentDispatch ()

14 0x9a38f755 in QTVCSetImageAvailableCallback ()

15 0x9a38f716 in QTVisualContextSetImageAvailableCallback ()

16 0x00262a6b in -[QTKitMovieRenderer dealloc] at /path/to/project/openframeworks/libs/openFrameworksCompiled/project/osx/../../../openFrameworks/video/ofQTKitMovieRenderer.m:201

17 0x99cf28ff in -[NSObject release]()

18 0x00260edc in ofQTKitPlayer::close() at /path/to/project/openframeworks/libs/openFrameworksCompiled/project/osx/../../../openFrameworks/video/ofQTKitPlayer.mm:102

19 0x002604b1 in ofQTKitPlayer::~ofQTKitPlayer() at /path/to/project/openframeworks/libs/openFrameworksCompiled/project/osx/../../../openFrameworks/video/ofQTKitPlayer.mm:22

20 0x00260421 in ofQTKitPlayer::~ofQTKitPlayer() at /path/to/project/openframeworks/libs/openFrameworksCompiled/project/osx/../../../openFrameworks/video/ofQTKitPlayer.mm:21

obviousjim commented 11 years ago

Does this happen when you don't have texture only turned on?

I've seen some stability problems win the texture only mode. I'll investigate this!

On Wed, Mar 6, 2013 at 3:18 PM, kronick notifications@github.com wrote:

The following code causes a deadlock on the "delete" call (calling player->close() causes the same problem) while clearing a large video file (I'm using one that's ~2GB):

ofQTKitPlayer *player new ofQTKitPlayer();player->loadMovie("a_large_video.mov", OF_QTKIT_DECODE_TEXTURE_ONLY); delete player;}

It seems to work fine when using OF_QTKIT_DECODE_PIXELS_AND_TEXTURE.

Stack trace is below. The last non-assembly bits are in [QTKitMovieRenderer dealloc]. This is on a iMac i7 OSX 10.8.2.

When #0 0x996e091a in __psynch_mutexwait ()

1 https://github.com/openframeworks/openFrameworks/issues/1 0x93b7c13b

in pthread_mutex_lock ()

2 https://github.com/openframeworks/openFrameworks/issues/2 0x9a34e9ec

in QTMLGrabMutex ()

3 https://github.com/openframeworks/openFrameworks/issues/3 0x9a38f51d

in QTVisualGraphGrabConfiguringMutex ()

4 https://github.com/openframeworks/openFrameworks/issues/4 0x9858e31b

in ___lldb_unnamed_function22307$$QuickTimeComponents ()

5 https://github.com/openframeworks/openFrameworks/issues/5 0x955c091f

in callComponentStorage_444 ()

6 https://github.com/openframeworks/openFrameworks/issues/6 0x955b1abf

in CallComponentFunctionCommonWithStorage(char, ComponentParameters, long ()(), unsigned long) ()

7 https://github.com/openframeworks/openFrameworks/issues/7 0x955b1aff

in CallComponentFunctionWithStorageProcInfo ()

8 https://github.com/openframeworks/openFrameworks/issues/8 0x9858ddf6

in BaseVC_ComponentDispatch ()

9 https://github.com/openframeworks/openFrameworks/issues/9 0x9552baee

in CallComponent ()

10 https://github.com/openframeworks/openFrameworks/issues/100x9552bb65 in DelegateComponentCall ()

11 https://github.com/openframeworks/openFrameworks/issues/110x9858e592 in OpenGLTVC_ComponentDispatch ()

12 https://github.com/openframeworks/openFrameworks/issues/120x9552baee in CallComponent ()

13 https://github.com/openframeworks/openFrameworks/issues/130x9552bb48 in CallComponentDispatch ()

14 https://github.com/openframeworks/openFrameworks/issues/140x9a38f755 in QTVCSetImageAvailableCallback ()

15 https://github.com/openframeworks/openFrameworks/issues/150x9a38f716 in QTVisualContextSetImageAvailableCallback ()

16 https://github.com/openframeworks/openFrameworks/issues/160x00262a6b in -[QTKitMovieRenderer dealloc] at

/path/to/project/openframeworks/libs/openFrameworksCompiled/project/osx/../../../openFrameworks/video/ofQTKitMovieRenderer.m:201

17 https://github.com/openframeworks/openFrameworks/issues/170x99cf28ff in -NSObject

release

18 https://github.com/openframeworks/openFrameworks/issues/180x00260edc in ofQTKitPlayer::close() at

/path/to/project/openframeworks/libs/openFrameworksCompiled/project/osx/../../../openFrameworks/video/ofQTKitPlayer.mm:102

19 https://github.com/openframeworks/openFrameworks/issues/190x002604b1 in ofQTKitPlayer::~ofQTKitPlayer() at

/path/to/project/openframeworks/libs/openFrameworksCompiled/project/osx/../../../openFrameworks/video/ofQTKitPlayer.mm:22

20 https://github.com/openframeworks/openFrameworks/issues/200x00260421 in ofQTKitPlayer::~ofQTKitPlayer() at

/path/to/project/openframeworks/libs/openFrameworksCompiled/project/osx/../../../openFrameworks/video/ofQTKitPlayer.mm:21

— Reply to this email directly or view it on GitHubhttps://github.com/openframeworks/openFrameworks/issues/1916 .

kronick commented 11 years ago

No, as I noted:

player->loadMovie("a_large_video.mov", OF_QTKIT_DECODE_PIXELS_AND_TEXTURE);
delete player;

Seems to work fine.

ascorbin commented 11 years ago

yes

this works:

//-------------------------------------------------------------- void testApp::update(){

player.close();
player.loadMovie("film.mov", OF_QTKIT_DECODE_PIXELS_AND_TEXTURE);
player.play();
player.update();
counter++;

}

and this gives you a beach ball (after prox count 30 on my powerbook, depends on memory?)

//-------------------------------------------------------------- void testApp::update(){

player.close();
player.loadMovie("film.mov", OF_QTKIT_DECODE_TEXTURE_ONLY);
player.play();
player.update();
counter++;

}

greetings ascorbin

obviousjim commented 11 years ago

There is a thread safety issue around texture only it seems

On Wed, Mar 6, 2013 at 4:20 PM, Owi Mahn notifications@github.com wrote:

yes

this works:

//-------------------------------------------------------------- void testApp::update(){

player.close(); player.loadMovie("film.mov", OF_QTKIT_DECODE_PIXELS_AND_TEXTURE); player.play(); player.update(); counter++;

}

and this gives you a beach ball (after prox count 30 on my powerbook, depends on memory?)

//-------------------------------------------------------------- void testApp::update(){

player.close(); player.loadMovie("film.mov", OF_QTKIT_DECODE_TEXTURE_ONLY); player.play(); player.update(); counter++;

}

greetings ascorbin

— Reply to this email directly or view it on GitHubhttps://github.com/openframeworks/openFrameworks/issues/1916#issuecomment-14526831 .

cindyloo commented 10 years ago

ah, I think I am seeing related behavior - I've seen that CallComponent method in quite a few thread crashes. While I am not closing nor deleting the ofVideoPlayer, I am resetting and looping many times over. It randomly hangs on a frame - it doesn't advance and I can't tell why. If I drill down in the debugger into ofQTKitPlayer, I hit QTMovieRenderer.m's update and it doesn't think the frame is new.

Is there a workaround? I am by default using OF_QTKIT_DECODE_PIXELS_ONLY - looks like I should try using both pixels/texture?

thanks! Cindy

openframeworks 7.4, osx10.8.5

obviousjim commented 10 years ago

Hey Cindy,

There is definitely a bug with getting frames in loops with the current video player. It can sometimes be due to certain codecs, and larger videos often have problems --

Are you doing frame by frame processing in a loop to get direct pixel access? or are you playing the video back? If you're just looking for playback the AVFoundation alternative is shaping up nicely: https://github.com/obviousjim/ofxAVFVideoPlayer but is not yet ready to do any type of synchronous operations.

Otherwise with 10.6 SDK http://forum.openframeworks.cc/t/xcode-4-5-not-supporting-10-6-sdk/10343you can revert to the older Quicktime based video which is pretty solid.

Hope this helps!

On Mon, Jan 13, 2014 at 11:10 PM, cindy b notifications@github.com wrote:

ah, I think I am seeing related behavior - I've seen that CallComponent method in quite a few thread crashes. While I am not closing nor deleting the ofVideoPlayer, I am resetting and looping many times over. It randomly hangs on a frame - it doesn't advance and I can't tell why. If I drill down in the debugger into ofQTKitPlayer, I hit QTMovieRenderer.m's update and it doesn't think the frame is new.

Is there a workaround? I am by default using OF_QTKIT_DECODE_PIXELS_ONLY - looks like I should try using both pixels/texture?

thanks! Cindy

openframeworks 7.4, osx10.8.5

— Reply to this email directly or view it on GitHubhttps://github.com/openframeworks/openFrameworks/issues/1916#issuecomment-32237402 .

cindyloo commented 10 years ago

hi Jim-

I am using xcode 4.6.3 and oF 7.4 on osx 10.8.5

I am not doing pixel operations - just playback..  Using OpenNI to watch my hand move back and forth across the screen.

I have two videos - an attract loop that loops and the symphony video that I increase/descrease speed of playback.  My hand "conduct" the movie- to go faster or slower.  also using ofMaxim for the sound.

do you think I should try using the AVFoundation, or just point my Base SDK at 10.6?

thank you for the quick reply! - this is in production at the Boston Children's Museum so I need it to be fairly stable.

thanks!!! CIndy


From: James George notifications@github.com To: openframeworks/openFrameworks openFrameworks@noreply.github.com Cc: cindy b cindyloo_home@yahoo.com Sent: Tuesday, January 14, 2014 12:02 AM Subject: Re: [openFrameworks] ofQTKitPlayer deadlock on delete (#1916)

Hey Cindy,

There is definitely a bug with getting frames in loops with the current video player. It can sometimes be due to certain codecs, and larger videos often have problems --

Are you doing frame by frame processing in a loop to get direct pixel access? or are you playing the video back? If you're just looking for playback the AVFoundation alternative is shaping up nicely: https://github.com/obviousjim/ofxAVFVideoPlayer but is not yet ready to do any type of synchronous operations.

Otherwise with 10.6 SDK http://forum.openframeworks.cc/t/xcode-4-5-not-supporting-10-6-sdk/10343you can revert to the older Quicktime based video which is pretty solid.

Hope this helps!

On Mon, Jan 13, 2014 at 11:10 PM, cindy b notifications@github.com wrote:

ah, I think I am seeing related behavior - I've seen that CallComponent method in quite a few thread crashes. While I am not closing nor deleting the ofVideoPlayer, I am resetting and looping many times over. It randomly hangs on a frame - it doesn't advance and I can't tell why. If I drill down in the debugger into ofQTKitPlayer, I hit QTMovieRenderer.m's update and it doesn't think the frame is new.

Is there a workaround? I am by default using OF_QTKIT_DECODE_PIXELS_ONLY - looks like I should try using both pixels/texture?

thanks! Cindy

openframeworks 7.4, osx10.8.5

— Reply to this email directly or view it on GitHubhttps://github.com/openframeworks/openFrameworks/issues/1916#issuecomment-32237402 .

sheridanis commented 10 years ago

I also get this problem a lot (using xcode 0.74 and xcode 5.02)

As we use a lot of synchronous operations I'm unable to use the AV Foundation code and as I'm using the HAP addon (which is based on ofQTKitPlayer I can't use the old 10.6 method. Does anyone know of a way to avoid to crash on exit with an appropriately placed try/catch statement or the like?

Cheers James

On 14/01/2014 2:35 pm, cindy b wrote:

hi Jim-

I am using xcode 4.6.3 and oF 7.4 on osx 10.8.5

I am not doing pixel operations - just playback.. Using OpenNI to watch my hand move back and forth across the screen.

I have two videos - an attract loop that loops and the symphony video that I increase/descrease speed of playback. My hand "conduct" the movie- to go faster or slower. also using ofMaxim for the sound.

do you think I should try using the AVFoundation, or just point my Base SDK at 10.6?

thank you for the quick reply! - this is in production at the Boston Children's Museum so I need it to be fairly stable.

thanks!!! CIndy


From: James George notifications@github.com To: openframeworks/openFrameworks openFrameworks@noreply.github.com Cc: cindy b cindyloo_home@yahoo.com Sent: Tuesday, January 14, 2014 12:02 AM Subject: Re: [openFrameworks] ofQTKitPlayer deadlock on delete (#1916)

Hey Cindy,

There is definitely a bug with getting frames in loops with the current video player. It can sometimes be due to certain codecs, and larger videos often have problems --

Are you doing frame by frame processing in a loop to get direct pixel access? or are you playing the video back? If you're just looking for playback the AVFoundation alternative is shaping up nicely: https://github.com/obviousjim/ofxAVFVideoPlayer but is not yet ready to do any type of synchronous operations.

Otherwise with 10.6 SDK http://forum.openframeworks.cc/t/xcode-4-5-not-supporting-10-6-sdk/10343you

can revert to the older Quicktime based video which is pretty solid.

Hope this helps!

On Mon, Jan 13, 2014 at 11:10 PM, cindy b notifications@github.com wrote:

ah, I think I am seeing related behavior - I've seen that CallComponent method in quite a few thread crashes. While I am not closing nor deleting the ofVideoPlayer, I am resetting and looping many times over. It randomly hangs on a frame - it doesn't advance and I can't tell why. If I drill down in the debugger into ofQTKitPlayer, I hit QTMovieRenderer.m's update and it doesn't think the frame is new.

Is there a workaround? I am by default using OF_QTKIT_DECODE_PIXELS_ONLY - looks like I should try using both pixels/texture?

thanks! Cindy

openframeworks 7.4, osx10.8.5

— Reply to this email directly or view it on GitHubhttps://github.com/openframeworks/openFrameworks/issues/1916#issuecomment-32237402

.

  • James — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/openframeworks/openFrameworks/issues/1916#issuecomment-32268979.

bilderbuchi commented 10 years ago

One thing you folks could try out would be using the current version of OF and see if this issue persists.

sheridanis commented 10 years ago

I can't as I'm using ofx fenster which doesn't work under 0.8 on osx (and windows).....just waiting for multi windows to be added into the core and I'll move away from ofxFenster. I thought multi windowing was going to be added in to 0.8.1 but I havn't seen anything about this lately - is this still the case?

Guess I should be able to use just the ofQTKitPlayer class from 0.8 under 0.74 though and see if that fixes things - is there any easy way with git to check the last commit/tag a file was changed?

On 14/01/2014 3:44 pm, Christoph Buchner wrote:

One thing you folks could try out would be using the current version of OF and see if this issue persists.

— Reply to this email directly or view it on GitHub https://github.com/openframeworks/openFrameworks/issues/1916#issuecomment-32275515.

bilderbuchi commented 10 years ago

No idea if that will work correctly, but you can browse the "history" view of any file on github by clicking the appropriate button. in this case: https://github.com/openframeworks/openFrameworks/commits/4e25bc677ae05b303497929cb1aa66adc7010a5b/libs/openFrameworks/video/ofQTKitPlayer.mm

sheridanis commented 10 years ago

Couldn't find any changes that look like they fixed this but I converted my code to use OF 0.8 (on windows with codeblocks) anyway and the issue still occurs.....same with current github repo

I'll try and get a test case happening

On 14/01/2014 7:00 pm, Christoph Buchner wrote:

No idea if that will work correctly, but you can browse the "history" view of any file on github by clicking the appropriate buttron. in this case: https://github.com/openframeworks/openFrameworks/commits/4e25bc677ae05b303497929cb1aa66adc7010a5b/libs/openFrameworks/video/ofQTKitPlayer.mm

— Reply to this email directly or view it on GitHub https://github.com/openframeworks/openFrameworks/issues/1916#issuecomment-32295348.

cindyloo commented 10 years ago

I updated to 0.8 also and it still hangs over time with large videos FYI.

Sent from my iPhone

On Jan 15, 2014, at 9:29 AM, sheridanis notifications@github.com wrote:

Couldn't find any changes that look like they fixed this but I converted my code to use OF 0.8 (on windows with codeblocks) anyway and the issue still occurs.....same with current github repo

I'll try and get a test case happening

On 14/01/2014 7:00 pm, Christoph Buchner wrote:

No idea if that will work correctly, but you can browse the "history" view of any file on github by clicking the appropriate buttron. in this case: https://github.com/openframeworks/openFrameworks/commits/4e25bc677ae05b303497929cb1aa66adc7010a5b/libs/openFrameworks/video/ofQTKitPlayer.mm

— Reply to this email directly or view it on GitHub https://github.com/openframeworks/openFrameworks/issues/1916#issuecomment-32295348.

— Reply to this email directly or view it on GitHub.

minikomi commented 10 years ago

I'm seeing this simply by trying to play, stop, close and play different videos with ofVideoPlayer. It seems this line is deadlocking:

https://github.com/openframeworks/openFrameworks/blob/4e25bc677ae05b303497929cb1aa66adc7010a5b/libs/openFrameworks/video/ofQTKitMovieRenderer.m#L201

Edit: Switching open frameworks to build under OSX SDK 10.6 & the problem seems to have gone away...

kylemcdonald commented 10 years ago

Because QTKit and QuickTime are deprecated by Apple as of 10.9, we are focusing on AVF. Follow #2283 for developments. Remaining QTKit and QuickTime-specific issues will be closed with wont-fix, but bugfix PRs will be accepted.