lgi-devs / lgi-devs/lgi

macOS: GStreamer video sinks hang without NSApplication initialization in LGI

Open
#341 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
491
Forks
81
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with repro.lua and the requested Gst.macos_init() and Gst.macos_main() entry points, then trace how LGI exposes GStreamer APIs. Use the macOS pipeline in the report to verify the helpers can be called from plain Lua without the NSApplication warning or a hanging video sink.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, macos
Domain
desktop, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.