Skip to content

macOS: GStreamer video sinks hang without NSApplication initialization in LGI #341

@andrewstarks

Description

@andrewstarks

Hi, I'm having trouble with a basic script on macOS. I also tried the Overview tutorial, which also doesn't work. I suspect support on the Mac is not available?

I created this issue report with AI help. My apologies if anything obvious is wrong. I am not fluent in GStreamer, at all. Just learning it for the first time.

Repro

Save this as repro.lua and run with plain Lua 5.3 on macOS:

local lgi  = require 'lgi'
local Gst  = lgi.require('Gst','1.0')
local GLib = lgi.require('GLib')

Gst.init()

-- Ensure LGI did _not_ expose macOS init helpers
assert(Gst.macos_init == nil)

local pipeline = Gst.parse_launch(
  'videotestsrc pattern=solid-color ! videoconvert ! autovideosink'
)
pipeline:set_state(Gst.State.PLAYING)

-- Block so the window would stay open if it appeared
local loop = GLib.MainLoop()
loop:run()

pipeline:set_state(Gst.State.NULL)

Environment

  • LGI: 0.9.2-1 (installed via luarocks install lgi)
  • Lua: 5.3.6 (built from source)
  • macOS: 15.5 “Sequoia”
  • GStreamer: 1.26.3
  • Installed via Homebrew:
brew install gstreamer gst-plugins-base \
             gst-plugins-good gst-plugins-bad \
             gst-plugins-ugly gobject-introspection

Environment Variables

export GI_TYPELIB_PATH="$(brew --prefix gobject-introspection)/lib/girepository-1.0"
export DYLD_FALLBACK_LIBRARY_PATH="$(brew --prefix glib)/lib"

Output / Error

Running lua repro.lua prints:

GStreamer-GL-WARNING **: An NSApplication needs to be running on the main thread to ensure correct behaviour on macOS. Use gst_macos_main() or call [NSApplication sharedApplication] in your code before using this element.

and no window ever appears. The process hangs indefinitely until killed.

Expected

  • A video window should open showing the test pattern and remain until closed or EOS.
  • No GL warning should be emitted.

Workarounds Tried

  • Switched between autovideosink, osxvideosink, glimagesink, and avfvideosink—all hang with the same warning.
  • Verified the same pipeline works in gst-launch-1.0 on macOS and in Docker/Linux environments.

Request

Please expose the macOS initialization helpers in LGI (e.g. Gst.macos_init() and/or Gst.macos_main()) so that simple Lua scripts on macOS can start the NSApplication and drive video sinks without additional native glue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions