簡體   English   中英

當 Xcode 調試 iOS 時,GStreamer 不需要的啟動延遲和單元測試崩潰

[英]GStreamer unwanted startup delay and unit test crashes when Xcode debugging for iOS

我有一個 iOS 應用程序,它使用 Gstreamer 到 stream 來自 UDP 的源的實時視頻。 當我在連接了 Xcode 調試器的情況下運行此應用程序時,視頻出現之前有5-10 秒的延遲。 然后它似乎會快速顯示所有先前的幀,直到它“趕上”當前時間戳。 起初我認為這是由我的管道轉換為動態代碼引起的,但是我已經將問題隔離到僅在調試時:

  • 如果我停止管道並重新創建它,則沒有明顯的延遲。
  • 如果我停止調試並使用該應用程序就可以了(也可以從多任務處理中殺死)。
  • TestFlight 版本也很好。

這是我的控制台 output ,其中包含一些調試消息、GStreamer 回調和我在代碼注釋語法中的注釋:

WARNING: no real random source present!
💠 GST_STATE_READY
playOrStopVideo
2019-09-26 15:45:19.442411-0400  pipeline is null
2019-09-26 15:45:19.502487-0400  pad_added_handler: tee
2019-09-26 15:45:19.534644-0400  Metal GPU Frame Capture Enabled
2019-09-26 15:45:19.535959-0400  Metal API Validation Enabled
[GStreamer check_initialization_complete]:[00m Initialization complete, notifying application.
ViewController gstreamerInitialized()
2019-09-26 15:45:19.646378-0400  💬 message NEED_CONTEXT
2019-09-26 15:45:19.646436-0400  💬 message HAVE_CONTEXT
2019-09-26 15:45:19.646465-0400  💬 message NEED_CONTEXT
2019-09-26 15:45:19.646492-0400  💬 message ELEMENT
2019-09-26 15:45:19.646547-0400  💬 message NEED_CONTEXT
2019-09-26 15:45:19.646636-0400  💬 message NEED_CONTEXT
2019-09-26 15:45:19.646685-0400  💬 message NEED_CONTEXT
💠 GST_STATE_READY
2019-09-26 15:45:19.649381-0400  💬 message STREAM_STATUS CREATE for src
2019-09-26 15:45:19.652090-0400  💬 message STREAM_STATUS CREATE for src
2019-09-26 15:45:19.652148-0400  💬 message STREAM_STATUS CREATE for src
💠 GST_STATE_PAUSED
2019-09-26 15:45:19.652808-0400  💬 message STREAM_STATUS ENTER for src
2019-09-26 15:45:19.652926-0400  💬 message NEW_CLOCK
2019-09-26 15:45:19.652980-0400  💬 message STREAM_STATUS ENTER for src
2019-09-26 15:45:19.653166-0400  💬 message STREAM_STATUS ENTER for src
2019-09-26 15:45:19.987250-0400  pad_added_handler: decodebin0
2019-09-26 15:45:19.999452-0400  💬 message STREAM_START
2019-09-26 15:45:20.032557-0400  💬 message TAG
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView frame]
PID: 3788, TID: 1475176, Thread name: (none), Queue name: org.freedesktop.gstreamer.glwindow, QoS: 0
Backtrace:
4   MyApp                               0x0000000105ef14f8 gst_gl_context_eagl_update_layer + 652
5   MyApp                               0x0000000105edd4b8 gst_gl_window_eagl_set_window_handle + 92
6   MyApp                               0x0000000105ef5f6c _set_window_handle_cb + 104
7   MyApp                               0x0000000105edd790 __gst_gl_window_eagl_send_message_async_block_invoke + 36
8   libdispatch.dylib                   0x00000001097e51dc _dispatch_call_block_and_release + 24
9   libdispatch.dylib                   0x00000001097e519c _dispatch_client_callout + 16
10  libdispatch.dylib                   0x00000001097f3dfc _dispatch_queue_serial_drain + 768
11  libdispatch.dylib                   0x00000001097e86ac _dispatch_queue_invoke + 328
12  libdispatch.dylib                   0x00000001097f4d54 _dispatch_root_queue_drain_deferred_wlh + 352
13  libdispatch.dylib                   0x00000001097fbe38 _dispatch_workloop_worker_thread + 676
14  libsystem_pthread.dylib             0x0000000184c83e70 _pthread_wqthread + 860
15  libsystem_pthread.dylib             0x0000000184c83b08 start_wqthread + 4
2019-09-26 15:45:20.049748-0400 MyApp[3788:1475176] [reports] Main Thread Checker: UI API called on a background thread: -[UIView frame]
PID: 3788, TID: 1475176, Thread name: (none), Queue name: org.freedesktop.gstreamer.glwindow, QoS: 0
Backtrace:
4   MyApp                               0x0000000105ef14f8 gst_gl_context_eagl_update_layer + 652
5   MyApp                               0x0000000105edd4b8 gst_gl_window_eagl_set_window_handle + 92
6   MyApp                               0x0000000105ef5f6c _set_window_handle_cb + 104
7   MyApp                               0x0000000105edd790 __gst_gl_window_eagl_send_message_async_block_invoke + 36
8   libdispatch.dylib                   0x00000001097e51dc _dispatch_call_block_and_release + 24
9   libdispatch.dylib                   0x00000001097e519c _dispatch_client_callout + 16
10  libdispatch.dylib                   0x00000001097f3dfc _dispatch_queue_serial_drain + 768
11  libdispatch.dylib                   0x00000001097e86ac _dispatch_queue_invoke + 328
12  libdispatch.dylib                   0x00000001097f4d54 _dispatch_root_queue_drain_deferred_wlh + 352
13  libdispatch.dylib                   0x00000001097fbe38 _dispatch_workloop_worker_thread + 676
14  libsystem_pthread.dylib             0x0000000184c83e70 _pthread_wqthread + 860
15  libsystem_pthread.dylib             0x0000000184c83b08 start_wqthread + 4
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView layer]
PID: 3788, TID: 1475176, Thread name: (none), Queue name: org.freedesktop.gstreamer.glwindow, QoS: 0
Backtrace:

4   MyApp                               0x0000000105ef1300 gst_gl_context_eagl_update_layer + 148
5   MyApp                               0x0000000105edd4b8 gst_gl_window_eagl_set_window_handle + 92
6   MyApp                               0x0000000105ef5f6c _set_window_handle_cb + 104
7   MyApp                               0x0000000105edd790 __gst_gl_window_eagl_send_message_async_block_invoke + 36
8   libdispatch.dylib                   0x00000001097e51dc _dispatch_call_block_and_release + 24
9   libdispatch.dylib                   0x00000001097e519c _dispatch_client_callout + 16
10  libdispatch.dylib                   0x00000001097f3dfc _dispatch_queue_serial_drain + 768
11  libdispatch.dylib                   0x00000001097e86ac _dispatch_queue_invoke + 328
12  libdispatch.dylib                   0x00000001097f4d54 _dispatch_root_queue_drain_deferred_wlh + 352
13  libdispatch.dylib                   0x00000001097fbe38 _dispatch_workloop_worker_thread + 676
14  libsystem_pthread.dylib             0x0000000184c83e70 _pthread_wqthread + 860
15  libsystem_pthread.dylib             0x0000000184c83b08 start_wqthread + 4
2019-09-26 15:45:27.554390-0400 MyApp[3788:1475176] [reports] Main Thread Checker: UI API called on a background thread: -[UIView layer]
PID: 3788, TID: 1475176, Thread name: (none), Queue name: org.freedesktop.gstreamer.glwindow, QoS: 0
Backtrace:
4   MyApp                               0x0000000105ef1300 gst_gl_context_eagl_update_layer + 148
5   MyApp                               0x0000000105edd4b8 gst_gl_window_eagl_set_window_handle + 92
6   MyApp                               0x0000000105ef5f6c _set_window_handle_cb + 104
7   MyApp                               0x0000000105edd790 __gst_gl_window_eagl_send_message_async_block_invoke + 36
8   libdispatch.dylib                   0x00000001097e51dc _dispatch_call_block_and_release + 24
9   libdispatch.dylib                   0x00000001097e519c _dispatch_client_callout + 16
10  libdispatch.dylib                   0x00000001097f3dfc _dispatch_queue_serial_drain + 768
11  libdispatch.dylib                   0x00000001097e86ac _dispatch_queue_invoke + 328
12  libdispatch.dylib                   0x00000001097f4d54 _dispatch_root_queue_drain_deferred_wlh + 352
13  libdispatch.dylib                   0x00000001097fbe38 _dispatch_workloop_worker_thread + 676
14  libsystem_pthread.dylib             0x0000000184c83e70 _pthread_wqthread + 860
15  libsystem_pthread.dylib             0x0000000184c83b08 start_wqthread + 4

//
// THIS IS WHERE IT HANGS (check the timestamps)
//

2019-09-26 15:45:27.692918-0400  💬 message ASYNC_DONE
💠 GST_STATE_PLAYING
2019-09-26 15:45:28.023985-0400  💬 message QOS
2019-09-26 15:45:28.190131-0400  💬 message QOS
2019-09-26 15:45:28.418494-0400  💬 message QOS
2019-09-26 15:45:28.657004-0400  💬 message QOS
2019-09-26 15:45:28.665464-0400  💬 message QOS
2019-09-26 15:45:28.668784-0400  💬 message QOS
2019-09-26 15:45:28.672105-0400  💬 message QOS
2019-09-26 15:45:28.675492-0400  💬 message QOS

//
// Sometimes I see output with QoS about "a lot of buffers being dropped"
//

//
// STOPPING VIDEO VIA UI AND RESTARTING (plays immediately)
//
playOrStopVideo
2019-09-26 15:45:32.959316-0400  💚 SENT EOS OK
2019-09-26 15:45:32.962257-0400  💚 GST_MESSAGE_EOS
2019-09-26 15:45:32.969720-0400  💚 Pipeline set to NULL
💠 GST_STATE_NULL
[GStreamer setupVideoWithRecording:]:[00m Exited main loop
2019-09-26 15:45:32.970650-0400  💚 Exited main loop
2019-09-26 15:45:32.970712-0400  💣 destroy()
playOrStopVideo
2019-09-26 15:45:35.330103-0400  pipeline is null
2019-09-26 15:45:35.369882-0400  pad_added_handler: tee
[GStreamer check_initialization_complete]:[00m Initialization complete, notifying application.
ViewController gstreamerInitialized()
2019-09-26 15:45:35.385008-0400  💬 message NEED_CONTEXT
2019-09-26 15:45:35.385064-0400  💬 message HAVE_CONTEXT
2019-09-26 15:45:35.385099-0400  💬 message NEED_CONTEXT
2019-09-26 15:45:35.385134-0400  💬 message ELEMENT
2019-09-26 15:45:35.385241-0400  💬 message NEED_CONTEXT
2019-09-26 15:45:35.385305-0400  💬 message NEED_CONTEXT
2019-09-26 15:45:35.385368-0400  💬 message NEED_CONTEXT
💠 GST_STATE_READY
2019-09-26 15:45:35.389410-0400  💬 message STREAM_STATUS CREATE for src
2019-09-26 15:45:35.389992-0400  💬 message STREAM_STATUS CREATE for src
2019-09-26 15:45:35.390051-0400  💬 message STREAM_STATUS CREATE for src
💠 GST_STATE_PAUSED
2019-09-26 15:45:35.390270-0400  💬 message STREAM_STATUS ENTER for src
2019-09-26 15:45:35.390301-0400  💬 message NEW_CLOCK
2019-09-26 15:45:35.390437-0400  💬 message STREAM_STATUS ENTER for src
2019-09-26 15:45:35.390519-0400  💬 message STREAM_STATUS ENTER for src
2019-09-26 15:45:35.659082-0400  pad_added_handler: decodebin1
2019-09-26 15:45:35.676625-0400  💬 message STREAM_START
2019-09-26 15:45:35.682690-0400  💬 message TAG
2019-09-26 15:45:35.693208-0400  💬 message ASYNC_DONE
💠 GST_STATE_PLAYING

這沒什么大不了的,因為它只是在調試時,但是這給我的開發增加了很多不必要的時間。 它似乎與 iOS Thread 投訴有關。 只要我使用它(甚至可能已經提交了一個錯誤),它們就已經在 GStreamer 中了,我不確定它的解決方法,因為它在庫本身中。 想法?

編輯

在這里報道:

https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/568 https://www.bountysource.com/issues/48924739-glwindow-eagl-bug-with- -0-beta-4 https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/372 https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/394

不確定正確的修復方法是什么。 我正在嘗試各種調度隊列的組合。

編輯2:

使用 XCTWaiter 創建一些單元測試,但正在運行的應用程序在同一時間死機。 假設這也與線程有關,因為測試(主)線程正在等待 GStreamer,他正在后台修改應該在主線程上修改的內容(UIView 屬性視圖和框架)。

我能夠通過重新編譯 GStreamer 並添加一些調度調用來解決這個問題,其中[UIView layer][UIView frame]gst_gl_context_eagl_update_layer和窗口的draw_cb中使用。

將此提交用作參考,但您也可以查看堆棧跟蹤,因為我需要較少的調用。
gstglcontext_eagl.m gstglwindow_eagl.m

調度: https://stackoverflow.com/a/5226271/890558

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM