ios - MusicPlayerSetPlayRateScalar causes hang/freeze in __psynch_mutexwait -


i'm using avfoundation's musicplayer play midi music in game, , periodically call musicplayersetplayratescalar set tempo. ported game objective-c swift, , since i've been getting hanging/freezing after couple dozen calls function. when freeze happens , pause execution, main thread sitting in following state:

* thread #1: libsystem_kernel.dylib`__psynch_mutexwait + 8, queue = 'com.apple.main-thread', stop reason = signal sigstop * frame #0: libsystem_kernel.dylib`__psynch_mutexwait + 8 frame #1: libsystem_pthread.dylib`_pthread_mutex_lock_wait + 96 frame #2: audiotoolbox`camutex::lock() + 52 frame #3: audiotoolbox`sequenceplayer::settemposcalefactor(double) + 36 frame #4: audiotoolbox`musicplayersetplayratescalar + 136

cpu usage jumps 100% when happens, , memory usage starts growing steadily. don't have other threads of own running. other thread activity varies, here's example (top level of other threads' stack traces):

thread #5: libsystem_kernel.dylib`kevent_qos + 8, queue = 'com.apple.libdispatch-manager' thread #6: libsystem_kernel.dylib`__semwait_signal + 8, name = 'gputools.smt_poll.0x126fe8680' thread #10: libsystem_kernel.dylib`mach_msg_trap + 8, name = 'com.apple.coreaudio.aqclient' thread #11: libsystem_kernel.dylib`semaphore_wait_trap + 8, name = 'audiostreamerimpl::sioworkerprocess' thread #12: libc++abi.dylib`__cxa_decrement_exception_refcount + 32, name = 'auremoteio::iothread' thread #13: libsystem_kernel.dylib`mach_msg_trap + 8, name = 'auremoteio::iothread'

i'd have guessed kind of deadlock given mutexes , semaphores, cpu , memory usage patterns seem indicate otherwise. how can debug further?

(incidentally, debugger crashes when bt all in situation, doubt that's related.)

something apple folks said in wwdc 2015 core audio video makes me think there's lot of c++ voodoo going on behind scenes in areas this, , swift therefore can't interface unless take precautions (and didn't understand are). in situation, if don't need backwards compatibility far back, might want try using new avaudiosequencer instead. i've found easy , reliable.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -