Syphon / Syphon-Framework

Syphon is a Mac OS X technology to allow applications to share video and still images with one another in realtime, instantly.
Other
456 stars 79 forks source link

Headless rendering (modernGL) pipes into Syphon server #72

Open oogre opened 2 years ago

oogre commented 2 years ago

Hello, I'm working on a live video modular synthetizer since few years. With that perspective, I'm looking for solution to make its development easier, by splitting engine and UI. In fact, I want to explode the core engine into multiple simple modules, each of them connected with syphon to exchange visuals and other protocols to exchange controls.

ModerGL looks like the solution to generate live visuals, and syphonpy looks like to be the only python solution to handle syphon pipe.

Here's a simpler setup to debug things.


import syphonpy
import moderngl
from ported._example import Example

class EasySyphon(Example):
    gl_version = (3, 3)
    title = "easySyphon"

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.server = syphonpy.SyphonServer("headlessTest2")
        self.fbo = self.ctx.framebuffer(
            color_attachments=[self.ctx.texture((512, 512), 4)]
        )

    def render(self, time: float, frame_time: float):
        self.fbo.clear(1.0, 0.0, 0.0, 1.0)   
        viewPort = syphonpy.MakeRect(0,0,self.fbo.width,self.fbo.height)
        size = syphonpy.MakeSize(self.fbo.width,self.fbo.height)
        self.server.publish_frame_texture(self.fbo.glo, viewPort, size, False)

if __name__ == '__main__':
    EasySyphon.run()

I run

python3 EasySyphon.py

it works... the video output is piped to syphon which is what I need, the window build by moderGL is full white. but I want to run it headless. so

I run

python3 EasySyphon.py --window headless

it does not work. the syphon server looks to be created, but nothing is displayed into syphon recorder(which I use to visualize the rendering) later as debug, I saved the rendering FBO to a png file to isolate the bug origin, this worked without any troubble,

I'm not sure how syphon/syphonpy interacts with the opengl context to be honest. It might be realteed to this? Does it detect a context on server creation or something?

does anyone here've a bit of advice? Thanks for reading me.

vade commented 1 year ago

Hi

So, quickly - Syphon has no care about headless or not. This sounds like an issue with syphonpy project. My suspicion is that there is no CFRunloop created when running headless based on whatever tooling is going on!