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

general stability of AVFoundationPlayer #3719

Closed
urshofer opened this issue Mar 18, 2015 · 6 comments
Closed

general stability of AVFoundationPlayer #3719

urshofer opened this issue Mar 18, 2015 · 6 comments

Comments

@urshofer
Copy link

Hello all

I'm using AVFoundationPlayer on very short clips (1 to 3 seconds) in heavy rotation in a permanent installation. It runs for hours, but crashes after a while with a dispatch_barrier_async_f_slow exception. I cannot reproduce the error, waiting is all I can do.

I made a quick fix and it seems to run more stable now. I added to loadWithURL() a check if the queue really exists.

- (BOOL)loadWithURL:(NSURL*)url async:(BOOL)bAsync {
  [self unloadVideo];     // unload video if one is already loaded.
  self.asset = [AVURLAsset URLAssetWithURL:url options:nil];
  if(self.asset == nil) {
        NSLog(@"error loading asset: %@", [url description]);
        return NO;
  }
  dispatch_semaphore_t sema = dispatch_semaphore_create(0);
  dispatch_queue_t queue;
  if(bAsync == YES){
        queue = dispatch_get_main_queue();  // com.apple.main-thread
  } else {
        queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 
  }

Here I've added:

if (!queue || 
    !(strstr(dispatch_queue_get_label(queue), "root") || 
      strstr(dispatch_queue_get_label(queue), "main-thread"))
   ) {
  NSLog(@"***** error getting a dispatch queue*****");
  return NO;
}

The fix is also referenced here #3704 and downloadable here:

@admsyn
Copy link
Member

admsyn commented Mar 18, 2015

Thanks for the report @urshofer. Sounds like you have a good stress test in place for the new player :) To bring your "general stability" notes over from another issue:

  • Memory leaking in 10.9
  • Backwards playback issues ofAVFoundationPlayer can't dance backwards #3629
  • No playback after repeated load() calls without close() (on 10.8 and 10.9) Make loadAsync() in AVFoundationPlayer run without close() before. #3704. This looks kind of fixed in Yosemite, but the player crashes after a certain while (i'll investigate more on that)
  • As a side effect of the same issue: calls to close() last at least 20 up to 100ms. calls to loadAsync()last also around the same time if not explicitly closed before. That renders the asyncness obsolete.
  • Furthermore, I'm not sure if the AVFoundation Player works in non-textured mode.

Pinging @bakercp since he mentioned having general problems with the AVFoundation player as well.

@openframeworks/macos

@arturoc
Copy link
Member

arturoc commented Mar 18, 2015

regarding the leak, might this be related:

#3672

@bilderbuchi
Copy link
Member

also, pinging @openframeworks/video

@admsyn
Copy link
Member

admsyn commented Mar 18, 2015

Yes that makes sense. We may also be able to move over to ARC soon w/ the migration to 64 bit, though that's probably a little too far down the road.

Giving the player a quick look-over it seems like the general structure of the player might be sound, but it could benefit a bit of a code-review session.

E.g. this looks like a bad merge(my mistake, the conditions are exclusive), and this assumes that any change to the status of the player's media item means it's ready to play which could explain some of the issues on long runs.

@urshofer
Copy link
Author

Thanks for your replies. I'm quite new to the community here and I'm very happy how the communication works here :) Indeed I have a very stressful application. What I can say is that the gStreamer implementation is really perfect (I use it now as an alternative on OSX as well), never crashes, never leaks.
The leaks by the way are gone on 10.8.5 and 10.10.2 on OSX as well, looks to me like an improper implementation by apple on 10.9.

best,
Urs

@urshofer
Copy link
Author

urshofer commented Apr 3, 2015

closed this with PR #3736

@urshofer urshofer closed this as completed Apr 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants