dimitris-c / AudioStreaming

An AudioPlayer/Streaming library for iOS written in Swift using AVAudioEngine.
MIT License
266 stars 56 forks source link

Crashed if recreatePlayer before call player.play() #12

Closed newbdez33 closed 3 years ago

newbdez33 commented 3 years ago

This happened sometimes. I'm playing bunch of episodes. it crashes sometimes if we call recreatePlayer before playing next.

self.player.stop()
self.recreatePlayer()
self.player.play(url: url)

bug demo repo:

https://github.com/newbdez33/AudioStreamingBug/tree/render-crash

Screen Shot 2020-12-25 at 11 26 33

Tested main branch in iOS 14.2 Simulator and iPhone 7. (Xcode 12.2 and Xcode 12.3)

newbdez33 commented 3 years ago

Another crash report

Crashed: AURemoteIO::IOThread 0 libsystem_platform.dylib 0x18728ad98 _platform_memmove + 88 1 bugdemo 0x100cef3c0 AudioPlayerRenderProcessor.inRender(inNumberFrames:) + 4304384960 2 bugdemo 0x100ce9c6c partial apply for closure #1 in AudioPlayer.setupEngine() + 4304362604 3 bugdemo 0x100ce5dec thunk for @escaping @callee_guaranteed (@unowned UInt32) -> (@unowned UnsafePointer?) + 4304346604 4 AVFAudio 0x18d547670 GenericInputNodeRenderCallback(void, unsigned int, AudioTimeStamp const, unsigned int, unsigned int, AudioBufferList) + 92 5 AudioToolbox 0x18b9a5174 AUInputElement::PullInput(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int) + 176 6 AudioToolbox 0x18b6df84c AUInputFormatConverter2::InputProc(OpaqueAudioConverter, unsigned int, AudioBufferList*, AudioStreamPacketDescription, void) + 204 7 AudioToolbox 0x18b649248 AudioConverterChain::CallInputProc(unsigned int) + 640 8 AudioToolbox 0x18b4f2ea0 AudioConverterChain::FillBufferFromInputProc(unsigned int, CABufferList) + 276 9 AudioToolbox 0x18b4f2ce0 BufferedAudioConverter::GetInputBytes(unsigned int, unsigned int&, CABufferList const&) + 208 10 AudioToolbox 0x18b4f2a18 CBRConverter::RenderOutput(CABufferList, unsigned int, unsigned int&, AudioStreamPacketDescription) + 116 11 AudioToolbox 0x18b4f2894 BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription) + 800 12 AudioToolbox 0x18b4f23a4 AudioConverterChain::RenderOutput(CABufferList, unsigned int, unsigned int&, AudioStreamPacketDescription) + 132 13 AudioToolbox 0x18b4f2894 BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription) + 800 14 AudioToolbox 0x18b82ba8c AudioConverterFillComplexBuffer + 964 15 AudioToolbox 0x18b6df02c AUConverterBase::RenderBus(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int) + 688 16 AudioToolbox 0x18b9a9bc4 AUBase::DoRenderBus(unsigned int&, AudioTimeStamp const&, unsigned int, AUOutputElement, unsigned int, AudioBufferList&) + 172 17 AudioToolbox 0x18b9a94c0 AUBase::DoRender(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int, AudioBufferList&) + 488 18 AudioToolbox 0x18b9b1524 AUMethodRender(void, unsigned int, AudioTimeStamp const, unsigned int, unsigned int, AudioBufferList) + 44 19 AudioToolbox 0x18b78c160 invocation function for block in AUAudioUnitV2Bridge_Renderer::renderBlock() + 136 20 AudioToolbox 0x18b63a870 __26-[AUAudioUnit renderBlock]_block_invoke + 516 21 AVFAudio 0x18d546740 invocation function for block in AUGraphNodeBaseV3::AllocateInputBlock() + 468 22 AudioToolbox 0x18b9a5174 AUInputElement::PullInput(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int) + 176 23 AudioToolbox 0x18b86249c AUNewTimePitch::PullForInput(unsigned int, AudioBufferList const&, double&) + 224 24 AudioToolbox 0x18b8b3eb8 PhaseVocoderTwo::RenderEffect(unsigned int, AudioBufferList, double) + 508 25 AudioToolbox 0x18b862774 AUNewTimePitch::Render(unsigned int&, AudioTimeStamp const&, unsigned int) + 388 26 AudioToolbox 0x18b9a9bc4 AUBase::DoRenderBus(unsigned int&, AudioTimeStamp const&, unsigned int, AUOutputElement, unsigned int, AudioBufferList&) + 172 27 AudioToolbox 0x18b9a94c0 AUBase::DoRender(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int, AudioBufferList&) + 488 28 AudioToolbox 0x18b9b1524 AUMethodRender(void, unsigned int, AudioTimeStamp const, unsigned int, unsigned int, AudioBufferList) + 44 29 AudioToolbox 0x18b78c160 invocation function for block in AUAudioUnitV2Bridge_Renderer::renderBlock() + 136 30 AudioToolbox 0x18b63a870 26-[AUAudioUnit renderBlock]_block_invoke + 516 31 AVFAudio 0x18d546740 invocation function for block in AUGraphNodeBaseV3::AllocateInputBlock() + 468 32 AudioToolbox 0x18b9a5174 AUInputElement::PullInput(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int) + 176 33 AudioToolbox 0x18b68a138 AUNBandEQ::Render(unsigned int&, AudioTimeStamp const&, unsigned int) + 244 34 AudioToolbox 0x18b9a9bc4 AUBase::DoRenderBus(unsigned int&, AudioTimeStamp const&, unsigned int, AUOutputElement, unsigned int, AudioBufferList&) + 172 35 AudioToolbox 0x18b9a94c0 AUBase::DoRender(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int, AudioBufferList&) + 488 36 AudioToolbox 0x18b9b1524 AUMethodRender(void, unsigned int, AudioTimeStamp const, unsigned int, unsigned int, AudioBufferList) + 44 37 AudioToolbox 0x18b78c160 invocation function for block in AUAudioUnitV2Bridge_Renderer::renderBlock() + 136 38 AudioToolbox 0x18b63a870 __26-[AUAudioUnit renderBlock]_block_invoke + 516 39 AVFAudio 0x18d546740 invocation function for block in AUGraphNodeBaseV3::AllocateInputBlock() + 468 40 AudioToolbox 0x18b5e473c AUMultiChannelMixerInputElement::PullMixerInput(unsigned int, unsigned int&, AudioTimeStamp const&, unsigned int, AudioBufferList) + 380 41 AudioToolbox 0x18b5e3914 AUMultiChannelMixer::MixerCore::RenderInput(unsigned int, AudioTimeStamp const&, unsigned int) + 224 42 AudioToolbox 0x18b5e66bc AUMultiChannelMixer::MixerCore::Mix(InputRenderOrderInfo const, int, AudioTimeStamp const&, unsigned int) + 552 43 AudioToolbox 0x18b5e61b4 AUMultiChannelMixer::MixerCore::MasterMix(AudioTimeStamp const&, unsigned int) + 2072 44 AudioToolbox 0x18b5e5554 AUMultiChannelMixer::Render(unsigned int&, AudioTimeStamp const&, unsigned int) + 772 45 AudioToolbox 0x18b9a9bc4 AUBase::DoRenderBus(unsigned int&, AudioTimeStamp const&, unsigned int, AUOutputElement, unsigned int, AudioBufferList&) + 172 46 AudioToolbox 0x18b9a94c0 AUBase::DoRender(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int, AudioBufferList&) + 488 47 AudioToolbox 0x18b9b1524 AUMethodRender(void, unsigned int, AudioTimeStamp const, unsigned int, unsigned int, AudioBufferList) + 44 48 AudioToolbox 0x18b78c160 invocation function for block in AUAudioUnitV2Bridge_Renderer::renderBlock() + 136 49 AudioToolbox 0x18b63a870 26-[AUAudioUnit renderBlock]_block_invoke + 516 50 AVFAudio 0x18d546740 invocation function for block in AUGraphNodeBaseV3::AllocateInputBlock() + 468 51 AudioToolbox 0x18b9a5174 AUInputElement::PullInput(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int) + 176 52 AudioToolbox 0x18b6df84c AUInputFormatConverter2::InputProc(OpaqueAudioConverter, unsigned int, AudioBufferList*, AudioStreamPacketDescription*, void) + 204 53 AudioToolbox 0x18b649248 AudioConverterChain::CallInputProc(unsigned int) + 640 54 AudioToolbox 0x18b4f2ea0 AudioConverterChain::FillBufferFromInputProc(unsigned int, CABufferList) + 276 55 AudioToolbox 0x18b4f2ce0 BufferedAudioConverter::GetInputBytes(unsigned int, unsigned int&, CABufferList const&) + 208 56 AudioToolbox 0x18b4f2a18 CBRConverter::RenderOutput(CABufferList, unsigned int, unsigned int&, AudioStreamPacketDescription) + 116 57 AudioToolbox 0x18b4f2894 BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription) + 800 58 AudioToolbox 0x18b4f23a4 AudioConverterChain::RenderOutput(CABufferList, unsigned int, unsigned int&, AudioStreamPacketDescription) + 132 59 AudioToolbox 0x18b4f2894 BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription) + 800 60 AudioToolbox 0x18b82ba8c AudioConverterFillComplexBuffer + 964 61 AudioToolbox 0x18b6df02c AUConverterBase::RenderBus(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int) + 688 62 AudioToolbox 0x18b9a9bc4 AUBase::DoRenderBus(unsigned int&, AudioTimeStamp const&, unsigned int, AUOutputElement, unsigned int, AudioBufferList&) + 172 63 AudioToolbox 0x18b9a94c0 AUBase::DoRender(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int, AudioBufferList&) + 488 64 AudioToolbox 0x18b9b1524 AUMethodRender(void, unsigned int, AudioTimeStamp const, unsigned int, unsigned int, AudioBufferList) + 44 65 AudioToolbox 0x18b78c160 invocation function for block in AUAudioUnitV2Bridge_Renderer::renderBlock() + 136 66 AudioToolbox 0x18b63a870 __26-[AUAudioUnit renderBlock]_block_invoke + 516 67 AVFAudio 0x18d547054 AUGraphNodeGenericIOV3::RenderToABL(unsigned int, AudioBufferList, long long) + 96 68 AVFAudio 0x18d5276e8 AVAudioEngineGraph::RenderToABL(unsigned int, AudioBufferList, int) + 144 69 AVFAudio 0x18d59b3fc invocation function for block in AVAudioEngineImpl::GetManualRenderingBlock() + 164 70 bugdemo 0x100cf0204 specialized AudioPlayerRenderProcessor.render(inNumberFrames:ioData:flags:) + 4304388612 71 bugdemo 0x100cf0130 partial apply for implicit closure #2 in implicit closure #1 in AudioPlayerRenderProcessor.attachCallback(on:audioFormat:) + 4304388400 72 bugdemo 0x100ceffd0 thunk for @escaping @callee_guaranteed (@unowned UnsafeMutablePointer, @unowned UnsafePointer, @unowned UInt32, @unowned Int, @unowned UnsafeMutablePointer) -> (@unowned Int32) + 4304388048 73 AudioToolbox 0x18b78ba78 AUHALOutputUnit_ProvideOutputCallback(void, unsigned int, AudioTimeStamp const, unsigned int, unsigned int, AudioBufferList) + 80 74 AudioToolbox 0x18b9a5174 AUInputElement::PullInput(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int) + 176 75 AudioToolbox 0x18b6df84c AUInputFormatConverter2::InputProc(OpaqueAudioConverter, unsigned int, AudioBufferList, AudioStreamPacketDescription, void) + 204 76 AudioToolbox 0x18b649248 AudioConverterChain::CallInputProc(unsigned int) + 640 77 AudioToolbox 0x18b4f2ea0 AudioConverterChain::FillBufferFromInputProc(unsigned int, CABufferList) + 276 78 AudioToolbox 0x18b4f2ce0 BufferedAudioConverter::GetInputBytes(unsigned int, unsigned int&, CABufferList const&) + 208 79 AudioToolbox 0x18b4f2a18 CBRConverter::RenderOutput(CABufferList, unsigned int, unsigned int&, AudioStreamPacketDescription) + 116 80 AudioToolbox 0x18b4f2894 BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription) + 800 81 AudioToolbox 0x18b4f23a4 AudioConverterChain::RenderOutput(CABufferList, unsigned int, unsigned int&, AudioStreamPacketDescription) + 132 82 AudioToolbox 0x18b4f2894 BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription) + 800 83 AudioToolbox 0x18b82ba8c AudioConverterFillComplexBuffer + 964 84 AudioToolbox 0x18b6df02c AUConverterBase::RenderBus(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int) + 688 85 AudioToolbox 0x18b5c34a4 AURemoteIO::RenderBus(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int) + 332 86 AudioToolbox 0x18b9a9bc4 AUBase::DoRenderBus(unsigned int&, AudioTimeStamp const&, unsigned int, AUOutputElement, unsigned int, AudioBufferList&) + 172 87 AudioToolbox 0x18b9a94c0 AUBase::DoRender(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int, AudioBufferList&) + 488 88 AudioToolbox 0x18b5c305c AURemoteIO::PerformIO(unsigned int, unsigned int, unsigned int, AudioTimeStamp const&, AudioTimeStamp const&, AudioBufferList const, AudioBufferList, int&) + 728 89 AudioToolbox 0x18b5c4778 AURIOCallbackReceiver_PerformIO + 572 90 AudioToolbox 0x18b753bb8 _XPerformIO + 96 91 AudioToolbox 0x18b9941a8 mshMIGPerform + 232 92 AudioToolbox 0x18b9943c0 MSHMIGDispatchMessage + 40 93 AudioToolbox 0x18b5c3894 AURemoteIO::IOThread::Run() + 276 94 AudioToolbox 0x18b5c87f0 AURemoteIO::IOThread::Entry(void) + 76 95 AudioToolbox 0x18b99b4f8 CAPThread::Entry(CAPThread*) + 88 96 libsystem_pthread.dylib 0x1872992c0 _pthread_body + 128 97 libsystem_pthread.dylib 0x187299220 _pthread_start + 44 98 libsystem_pthread.dylib 0x18729ccdc thread_start + 4

dimitris-c commented 3 years ago

Closing this as you shouldn't have the recreate the player as part of a playlist...