g_main_loop_quit: fatal zombie object error (iOS)
GStreamer Version: iOS v1.8.1
Operating System: iOS 14.2
Steps to reproduce:
** I do not have access to the source of the pipeline creating the crash. Attempts I've made to reproduce the source on terminal do not cause this issue.
- Follow the steps in Tutorial 3.
- In
GStreamerBackend.m
, modify for screen transitions by changing the@implementation
section to__weak id ui_delegate
and__weak UIView *ui_video_view
, remove thedealloc
call that sets the pipeline to null, and instead copy thedeinit
function found in Tutorial 4. Do not setui_video_view = NULL;
andui_delegate = NULL;
at the end ofapp_function
- (possibly optional) Add a
{project-name}-Bridging-Header.h
to the project, addingGStreamerBackendDelegate.h
,GStreamerBackend.h
, andgst_ios_init.h
in order to implement theVideoViewController
andEaglUIView
in Swift 5 (and translate to Swift.) - In
VideoViewController.swift
, customize for live streaming by removing Play/Pause controls and callgStreamerBackend?.play()
upongstreamerInitialized
event in theGstreamerBackendDelegate
extension of theVideoViewController
. Then inviewDidDisappear(_:)
, callgStreamerBackend?.shutdown()
(viewDidLoad()
should callgStreamerBackend?.init(uiDelegate: Any!, videoView: UIView!)
; matching the tutorial implementation. - Add a transition to another screen that deallocates the
VideoViewController
, such as aUINavigationController
usingsetViewControllers
to remove the reference to theVideoViewController
. Make a button or timer to transition to the next screen for testing, such as adding the following on the last line ofviewDidLoad()
:
DispatchQueue.main.asyncAfter(deadline: .now() + 7.0) {
if let navigationController self.parent as? UINavigationController {
let viewController = UIViewController()
navigationController.setViewControllers([viewController], animated: true)
}
}
- In the top-left of Xcode, go to
Edit Scheme
>Run
>Diagnostics
and checkZombie Objects
thenClose
. Now press▶
to Run on a device connected to a source.
You should observe a Zombie Object detected upon crashing when using a video pipeline with high throughput. Using Instruments, I was able to see that EaglUIView
was deferenced twice (bringing the ARC count to -1) upon transitioning from the VideoViewController
but unable to see the function names even with Debug Symbols turned on in my Build Settings. I was unable to reproduce this issue using iOS simulator and any pattern in gst-launch-1.0 -v videotestsrc pattern=...
, suggesting it may only appear in high throughput pipelines. I'm unable to reproduce the source for the pipeline causing the crash.
Solution:
To fix the crash that occurs in certain conditions, modify the deinit
function in GStreamerBackend.m
to execute on the main dispatch queue like this:
-(void) shutdown
{
dispatch_async(dispatch_get_main_queue(), ^{
if (self->main_queue) {
GST_DEBUG("Quit main loop")
g_main_loop_quit(self->main_loop)
}
});
}
Let me know if I can provide any more details.