We currently have an application developed for us that has a screen that provides the ability to take a picture. I requested that the camera portion of the application be separated from the main application and made into a separate executable. The camera portion of the application uses the SDL library. The main application is using GTK4. I was told the following by a developer regarding the use of SDL in the camera application and why the camera portion could not be made into a separate application: “the camera application cannot be a separate executable because it runs in an SDL window,Launching it separately via a shell command could lead to crashes and runtime instability. Separating the camera app would also result in memory fragmentation, increased context switching, and potential resource conflicts.Top-level control conflicts occur when multiple applications using X11 or Wayland run simultaneously, leading to uncertainty over display ownership. Integrating everything into a single binary ensures unified control and stable display management.”
SDL has APIs that allow it to take control of a window it didn’t create (such as a GTK+ window), but I think they all depend on having those windows in the same process.
I think conversations about memory fragmentation are probably overblown (unless you’re on extremely low-end embedded hardware), but I’m not sure you’ll get a lot of value from being in a separate process for this in any case, but you will have a lot of troubles. What was the benefit of having it separated?
The application is running on a Toradex Colibri SoM. It has plenty of ram for the application. There are several reasons for separating the camera portion, but the primary reason is to take advantage of it running in a separate process in case of a crash, the user would end up right where they left off prior to entering the camera function. I can avoid bloating the main application with different versions of the camera application for supporting different camera hardware and different features, etc.
Maybe set up a shared memory buffer that the camera process reads video frames into, and draw them into the GTK+ window (maybe even just using GDK drawing functions) as new pixels are made available in that buffer?
If you want to do this with multiple processes, that might be the easiest and most efficient way. But if you go this route, I’d recommend trying to make it trivial to move this all to one process later…so the program eventually doesn’t get a shared memory buffer from another process but just a memory buffer that a function in the same process fills in…then, once you are comfortable you have something stable, you can remove a bunch of complexity trivially.