-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support running server and client in the same process #556
Comments
For applications that integrate Ignition Gazebo as a library, this feature would be life-changing. Currently, the only way to integrate both server and gui is running the server in the main process, and programmatically spawn a new process with the gui (example). There are C++ libraries that help handling the life of external processes, however this is just a suboptimal workaround. My main comment on a single server+gui process is about Qt. I'm not an expert GUI developer, but I remember past experiments failing due to the need of the Qt application to run in the main thread. In fact, from here I read:
|
I have started to take a look to this issue. Right now we are using Ruby to launch the server and the GUI, in particular we are forking the threads in Ruby, I believe this is making more complex to share the ECM between them? Does it make sense to work first in this PR #694 ? which is adding standalone (C++) executables to ignition. @mjcarroll and @chapulina thoughts? |
Just for the records there is a closed PR which tries in to implement this feature https://github.com/ignitionrobotics/ign-gazebo/pull/417/files |
I think that PR may have conflicts to be resolved with the solution to this issue, but I don't think that PR is blocking this. I expect the single process implementation to add a new function to The tricky part when it comes to the ECM will be finding a way to:
It's also important to keep the current behaviour working, so keep that in mind. For example, I imagine the @ahcorde , I recommend you start working on top of Fortress so you're comfortable making breaking changes. Once you have an idea of what the architecture could look like, feel free to open a draft PR with a proposal for review. After we've iterated on the high-level implementation, then you can clean it up and add tests. If it turns out that the implementation is backportable, we can rebase and retarget the PR. What do you think? |
I have started to work in this draft PR #793
@chapulina or @iche033 thoughts ? |
|
The ideal case would be to use the same scene, that should be better for performance and memory because we don't need to keep both of them updated. I don't know how hard this will be, but I think we should also have a single As discussed offline, I think this rewrite could be a good opportunity to look into how we could integrate
That would be working around the real problem, which is that we shouldn't have two separate scene managers trying to add entities to the scene. The proper solution would be to have a single manager that's bridging the rendering scene and the ECM. |
+1 on using the same Scene / RenderUtil. Some notes:
|
This sounds wrong. There is nothing special about the main() thread (at least for Windows/Linux/macOS. Android and iOS are another deal). However I suspect the wording is to prevent pointless bugs from clueless users starting with Qt and mixing UI calls in multiple threads, which are really hard to diagnose because it works but everything's glitchy. UI applications should be fine as long as:
Note that ensuring points 1 & 2 are hard to enforce. It is very easy to call a UI operation from the wrong thread by accident Note that iOS & Android are different though. |
there is some relevant discussion in the draft PR adding standalone executables for the |
The GUI currently relies on the
SceneBroadcaster
system relaying the ECM state to stay in sync with the server. This operation is very costly, in fact, state broadcasting is one of the main performance bottlenecks when running the simulation with a GUI.One possible workaround would be to run both client and server on the same process. Moreover, they could share the same ECM, so that there's no need to gather the entire state, serialize it, then update it on another process.
Some things to be careful about when looking into this approach:
GuiSystem
s should continue not writing to the ECM, and instead perform requests through theUserCommands
system, so that commands can be queued up for when we support undo / redo.The text was updated successfully, but these errors were encountered: