Hang in ofAVFoundationVideoPlayer


#1

Hi there!

I am having ocasional hangs (like 3 times a day) in an application using OF 0.9.8. The traces show that the hang is located in -[ofAVFoundationVideoPlayer seekToTime:withTolerance:] coming from -[ofAVFoundationVideoPlayer playerItemDidReachEnd].

I can’t reproduce myself the hang, but someone else using the app is, so I have some hang reports from him. The app can use a high number of video players, only few of them simultaneously playing.

Here a stacktrace (i replaced the relevant parts at the end with real symbols I got with atos ). The ones at the beginning is just ofApp going to pollEvents().

Heaviest stack for the main thread of the target process:
  10  start + 1 (libdyld.dylib + 21077) [0x7fffe1d04255]
  10  main + 526 (ProtoPixel + 6002142) [0x10806e5de]
  10  ??? (<9B56096C-857F-3177-A053-D57F65C74064> + 670678) [0x1085e4bd6]
  10  ??? (<9B56096C-857F-3177-A053-D57F65C74064> + 670949) [0x1085e4ce5]
  10  ??? (<9B56096C-857F-3177-A053-D57F65C74064> + 671325) [0x1085e4e5d]
  10  ??? (<9B56096C-857F-3177-A053-D57F65C74064> + 729000) [0x1085f2fa8]
  10  ??? (<9B56096C-857F-3177-A053-D57F65C74064> + 731954) [0x1085f3b32]
  10  std::__1::function<void ()>::operator()() const + 126 (ProtoPixel + 3759598) [0x107e4adee]
  10  ??? (<9B56096C-857F-3177-A053-D57F65C74064> + 684057) [0x1085e8019]
  10  ??? (<9B56096C-857F-3177-A053-D57F65C74064> + 684330) [0x1085e812a]
  10  ??? (<9B56096C-857F-3177-A053-D57F65C74064> + 678697) [0x1085e6b29]
  10  ??? (<9B56096C-857F-3177-A053-D57F65C74064> + 8307189) [0x108d2d1f5]
  10  -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1637 (AppKit + 7698667) [0x7fffcb06e8eb]
  10  _DPSNextEvent + 1093 (AppKit + 292341) [0x7fffca95e5f5]
  10  _BlockUntilNextEventMatchingListInModeWithFilter + 71 (HIToolbox + 199638) [0x7fffcc267bd6]
  10  ReceiveNextEventCommon + 184 (HIToolbox + 199849) [0x7fffcc267ca9]
  10  RunCurrentEventLoopInMode + 240 (HIToolbox + 200556) [0x7fffcc267f6c]
  10  CFRunLoopRunSpecific + 420 (CoreFoundation + 554420) [0x7fffcccc65b4]
  10  __CFRunLoopRun + 2205 (CoreFoundation + 557229) [0x7fffcccc70ad]
  10  __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 (CoreFoundation + 814217) [0x7fffccd05c89]
  10  _dispatch_main_queue_callback_4CF + 925 (libdispatch.dylib + 64435) [0x7fffe1cdbbb3]
  10  _dispatch_client_callout + 8 (libdispatch.dylib + 8488) [0x7fffe1cce128]
  10  _dispatch_call_block_and_release + 12 (libdispatch.dylib + 44895) [0x7fffe1cd6f5f]
  10  __avplayeritem_fpItemNotificationCallback_block_invoke + 4981 (AVFoundation + 566207) [0x7fffc96d13bf]
  10  _CFXNotificationPost + 604 (CoreFoundation + 367068) [0x7fffccc989dc]
  10  -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1827 (CoreFoundation + 371107) [0x7fffccc999a3]
  10  ___CFXNotificationPost_block_invoke + 50 (CoreFoundation + 643746) [0x7fffcccdc2a2]
  10  _CFXRegistrationPost + 427 (CoreFoundation + 644411) [0x7fffcccdc53b]
  10  __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12 (CoreFoundation + 644668) [0x7fffcccdc63c]
  10  -[ofAVFoundationVideoPlayer playerItemDidReachEnd] (in libopenFrameworks.dylib) + 115 [0x10893db63]
  10  -[ofAVFoundationVideoPlayer seekToStart] (in libopenFrameworks.dylib) + 150 [0x10893f5e6]
  10  -[ofAVFoundationVideoPlayer seekToTime:withTolerance:] (in libopenFrameworks.dylib) + 170 [0x10893f7ea]
  10  -[AVAssetReader cancelReading] + 284 (AVFoundation + 106231) [0x7fffc9660ef7]
  10  -[AVAssetReader _transitionToStatus:failureError:] + 359 (AVFoundation + 102368) [0x7fffc965ffe0]
  10  -[AVAssetReader _tearDownFigAssetReader] + 79 (AVFoundation + 603057) [0x7fffc96da3b1]
  10  FigMetadataReaderCreateForAVCHDMetadata + 7310 (MediaToolbox + 3504986) [0x7fffd01afb5a]
  10  FigMetadataReaderCreateForAVCHDMetadata + 7884 (MediaToolbox + 3505560) [0x7fffd01afd98]
  10  FigVideoRenderPipelineCreateWithVisualContext + 458 (MediaToolbox + 1278150) [0x7fffcff900c6]
  10  VMC2Invalidate + 103 (MediaToolbox + 420958) [0x7fffcfebec5e]
  10  VMC2WaitUntilCompletelyStopped + 159 (MediaToolbox + 421755) [0x7fffcfebef7b]
  10  VTDecompressionSessionInvalidate + 73 (VideoToolbox + 33958) [0x7fffd36ee4a6]
  10  ??? (VideoToolbox + 688169) [0x7fffd378e029]
  10  FigSemaphoreWaitRelative + 160 (CoreMedia + 273156) [0x7fffcda37b04]
  10  WaitOnConditionTimed + 85 (CoreMedia + 275164) [0x7fffcda382dc]
  10  __psynch_cvwait + 10 (libsystem_kernel.dylib + 105610) [0x7fffe1e32c8a]
 *10  psynch_cvcontinue + 0 (pthread + 39170) [0xffffff7f810a0902]

This seems to me of a weird race condition problem with videos when stoping? The only related thing I found was this topic but id didn’t seem to lead anywhere.

Any Idea on how to track this? I might have to change the video player if I can’t solve this issue… Which seems very complex in OSX :stuck_out_tongue:


#2

Same problem sometime, but i cannot reproduce the bug, so it’s really difficult to debug…