shogo4405 / HaishinKit.swift

Camera and Microphone streaming library via RTMP and SRT for iOS, macOS, tvOS and visionOS.
BSD 3-Clause "New" or "Revised" License
2.76k stars 612 forks source link

RTMP再生中にメモリ落ち #619

Closed ryo0ka closed 4 years ago

ryo0ka commented 4 years ago

Describe the bug RTMP再生開始後、数秒以内にメモリ使用量のためクラッシュ。

再現レポ: https://github.com/ryo0ka/HaishinKitTest

To Reproduce

  1. 上記レポをgit clonepod install
  2. ViewController.streamAddress, ViewController.streamKeyを設定(後述)
  3. iOS実機でアプリ(target=HaishinKitTest)を実行
  4. (運が良ければ)最初の数秒間の映像が受信・表示できているのを確認
  5. 数秒後にアプリクラッシュ、コンソールでエラーログ確認: Message from debugger: Terminated due to memory issue

Expected behavior 指定のRTMP映像・音声が再生される。

Screenshots メモリ使用量の推移: memory usage

ログ:

2019-11-30 19:15:53.411591+0900 HaishinKitTest[35151:9535042] Metal API Validation Enabled
2019-30-11 19:15:53.510 [Warn] [com.haishinkit.HaishinKit] [VideoIOComponent.swift:151] continuousAutofocus > focusMode(2) is not supported
2019-30-11 19:15:53.511 [Warn] [com.haishinkit.HaishinKit] [VideoIOComponent.swift:210] continuousExposure > exposureMode(2) is not supported
2019-30-11 19:15:53.566 [Info] [com.haishinkit.HaishinKit] [AudioConverter.swift:86] inSourceFormat > nil
2019-30-11 19:15:53.591 [Info] [com.haishinkit.HaishinKit] [VideoIOComponent.swift:95] fps > (fps: 30.0, duration: __C.CMTime(value: 100, timescale: 3000, flags: __C.CMTimeFlags(rawValue: 1), epoch: 0))
"success"
2019-30-11 19:15:53.604 [Info] [com.haishinkit.HaishinKit] [AudioConverter.swift:86] inSourceFormat > Optional(__C.AudioStreamBasicDescription(mSampleRate: 44100.0, mFormatID: 1633772320, mFormatFlags: 2, mBytesPerPacket: 0, mFramesPerPacket: 1024, mBytesPerFrame: 0, mChannelsPerFrame: 2, mBitsPerChannel: 0, mReserved: 0))
2019-30-11 19:15:53.938 [Info] [com.haishinkit.HaishinKit] [AudioConverter.swift:72] actualBitrate > 8192
2019-11-30 19:16:05.717204+0900 HaishinKitTest[35151:9535111] [ServicesDaemonManager] interruptionHandler is called. -[FontServicesDaemonManager connection]_block_invoke
Message from debugger: Terminated due to memory issue

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context RTMP参照先は以下の手順で立てたローカルホストサーバを使用しています。 https://qiita.com/hagane5563/items/842afe6d6e7100db3a2 iOS版VLCアプリで動作確認。HaishinKitでも最初の数秒間の受信・表示ができているのを(稀に)確認できています。

また、再現用に提供しようとしていたパブリックなRTMP配信が受信できていません(RTMPConnection.Code.connectClosed)。 RTMPアドレス:rtmp://fms.105.net/live/rmc1 公開元:`https://www.wowza.com/community/questions/50896/live-247-rtmp-stream-demo-url.html このストリームに関してもiOS版VLCアプリで再生確認しました。そのため、こちらの問題がまず解決できれば、当Issueの再現・デバグも容易になるのではないかと思います。

自社のストリーミングは外部非公開のため、ここで提供できないことを申し訳なく思います。

shogo4405 commented 4 years ago

https://github.com/shogo4405/HaishinKit.swift/issues/618 このIssueで nginx + rtmp module で再生できないという不具合がありました。 再生できないため映像がスタックされてメモリー容量に達した可能性があります。一度、master で試していたただければと存じます。