-
Notifications
You must be signed in to change notification settings - Fork 51
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
[macOS] add a QML version of simple_demo #373
[macOS] add a QML version of simple_demo #373
Conversation
nice! About upgrading the version of ogre:
I think the best way forward for Edifice (ign-rendering5) and possibly Citadael (ign-rendering3) is to do 1. then make a new release of ogre 2.1 from our fork. @j-rivero is that do-able? |
I thought that would be the case but figured placing the Ogre2 PR against the head of the
I can rebase the PR against the Ogre2.1 commit used in the osrf/simulation formula for ogre2.1 if that makes it easier, or you can edit my branch if you prefer? |
yeah that's fine. Once the PR is accepted upstream, we can pull the commit into our fork.
yes, that'll be easier for us to get this in, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution! I made a first pass
@ahcorde thanks for your review. I've made the changes you suggested and pushed them. I still need to rebase on the branch of Ogre2.1 used by ignition-rendering5 which will eliminate some of the other changes not directly related to the example. |
a7a77a9
to
4c33243
Compare
OGRECave/ogre-next#216 is merged. I just opened a pull request to build our ogre 2.1 bottle with that patch: |
looks like the patch failed because we're using an older commit of ogre 2.1 and there have been quite a few changes to the osx render system in the 2.1 branch since then.
Were you able to get this working with our version of ogre 2.1? |
Yes, the other changes on the current version of Ogre2.1 were not specific to macOS. If you let me know the commit that you'd like me to rebase on I'll get the PR updated. Having reviewed the Gazebo Scene3D plugin code in more detail I see that there is a synchronisation system in place to prevent a race condition between QML and Ogre. I've not implemented this in the demo, which does not seem to matter (mostly), probably because the window for contention is very small as explained in the dev notes by @darksylinc: Race condition between Qt and Ogre2 in presentation #304 and Fix race condition when rendering the UI #774 . It might be useful to add this in any case to make the example better reflect what happens in the main app. The other issue I noticed when running the example on an Ubuntu VM hosted on macOS, is that I cannot necessarily rely on the scene graph calling @iche033's suggestion here of using event callbacks may provide a solution in this case as well. |
Just to clear something up: Gazebo was rendering in two threads (Qt in one thread, Ogre in another) without proper synchronization. While "proper" synchronization is possible via a double buffer scheme; there were many difficulties so the solution we ended up implementing was brute force: serialize everything (i.e. thread A can't run while B is running, thread B can't run while A is running). Such a simple concept ended up being more complex than we'd want to because of the signal/slot system Qt was using to communicate between threads; which could easily end up in either Deadlock or not serializing the threads as intended. But ultimately all the code is trying to do is to simply have A -> B -> A -> B executing as if it were just one thread. |
our ogre 2.1 version is on this commit: b4c4fa785c03c2d4ba2a1d28d94394c7ca000358. Let me know if you're able to get a patch with your changes that can be applied on top of this particular ogre commit, and I'll apply that to our homebrew formula. Thanks! |
- Use ogre2 instead of ogre in examples that do not accept a command line argument - Enable logger to display additional Ogre information for debugging Signed-off-by: Rhys Mainwaring <[email protected]>
- Prevent the Ogre2RenderEngine searching in /usr/local/opt/ogre2.1/lib/OGRE-2.1 for render system plugins Signed-off-by: Rhys Mainwaring <[email protected]>
- This is a QML version of the simple_demo. It uses the same approach to rendering to QML as used in ignition-gui Scene3D. - For macOS there is an upstream dependency on a pending PR in Ogre2-1 for support of the `currentGLContext` flag. - The core application render thread is based on the Qt Toolkit example: - https://code.qt.io/cgit/qt/qtdeclarative.git/tree/examples/quick/scenegraph/textureinthread?h=5.15 Signed-off-by: Rhys Mainwaring <[email protected]>
Signed-off-by: Rhys Mainwaring <[email protected]>
Signed-off-by: Rhys Mainwaring <[email protected]>
Signed-off-by: Rhys Mainwaring <[email protected]>
- Remove unused section from CMakeLists.txt - Move using namespace declarations to translation unit scope - Remove addition separator line - Use ignmsg instead of std::cout in ThreadRenderer - Roll back changes to example text_geom Signed-off-by: Rhys Mainwaring <[email protected]>
4c33243
to
69e7438
Compare
Codecov Report
@@ Coverage Diff @@
## ign-rendering5 #373 +/- ##
==================================================
- Coverage 57.77% 57.77% -0.01%
==================================================
Files 161 161
Lines 15947 15947
==================================================
- Hits 9214 9213 -1
- Misses 6733 6734 +1
Continue to review full report at Codecov.
|
@iche033 this turns out to be a bit trickier. macOS Applying just the OpenGL shared context change 79be9e99 to the OSRF ogre2.1 version is not enough. The linux On an Ubuntu 20.04 virtual machine the Proposal In order to move this along I suggest the following:
Then as a follow up we can deal with macOS. I suspect to support Ignition Edifice GUI apps on macOS we'll need to incorporate many of the changes on the ogre-next v2-1 branch (up to v2-1-2). @darksylinc may be able to advise if a smaller subset of changes will suffice - I'm not sure where to begin! I don't think there is an advantage in releasing a new version of ogre2.1 on homebrew unless all the GUI functionality is available. |
69e7438
to
96d2444
Compare
Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Rhys Mainwaring <[email protected]>
Signed-off-by: Rhys Mainwaring <[email protected]>
Signed-off-by: Rhys Mainwaring <[email protected]>
Signed-off-by: Rhys Mainwaring <[email protected]>
- Remove QML_NAMED_ELEMENT from ThreadRenderer - Rename Renderer in QML to ThreadRenderer Signed-off-by: Rhys Mainwaring <[email protected]>
- Roll back changes to other examples, keeping only simple_demo_qml. Signed-off-by: Rhys Mainwaring <[email protected]>
- Remove additional plugin path for macOS. Signed-off-by: Rhys Mainwaring <[email protected]>
hi, thanks for looking into it. It does look like there have been quite a few changes to the osx render system since 2018:
yeah it's optional. We'll typically squash the commits when merging this PR. Agree to get this PR in first then follow-up on macOS afterwards. I'll continue reviewing this PR as is to make sure it works on linux, |
Did some quick tests. The example built fine but ran into a segfault on launch. I see these error msgs in the console:
backtrace points to this line: I'm on Ubuntu Bionic, Qt 5.9.5 |
Ah yes, the current version needs the Qt Quick Scene Graph to use the basic render loop: export QSG_RENDER_LOOP=basic should get it working, but I think a better approach is needed. |
ah yes thanks, that worked! I should've read your earlier comment about the env variable. I think this may not be obvious to the user. We could either add a README.md file with instructions on how to run the demo. Alternatively, just set the env for them with this patch:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall this looks good to me.
While we don't run linters or enforce coding style in examples directory, it's encouraged so we can keep the style consistent with the rest of the ignition library. Here are some suggestions for files that are not adapted from Qt:
- 2 space indentation
- wrap line to 80 chars
- use .hh and .cc file extensions
- function separator style:
//////////////////////////////////////////////////
I'm also happy to do this in a separate PR afterwards if you don't mind me changing the coding style. We can also leave the style as is if you prefer.
// on OSX the plugins may be placed in the parent lib directory | ||
if (ogrePath.rfind("OGRE") == ogrePath.size()-4u) | ||
this->ogrePaths.push_back(ogrePath.substr(0, ogrePath.size()-5)); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm interesting. I remember this was added for a reason but looks like our CI homebrew builds are passing with this removed so this maybe ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will definitely break running under macOS if left in. The brew installer places the plugin libs only in the sub-directory and the plugin loader raises an (subsequently uncaught) exception if not.
If you run clang format with this file I'm attaching it should be pretty close to gazebo's style. Things it does not cover:
while gazebo enforces the following for each variable:
However it will enforce the 80 line columns, it will also enforce spaces between conditional control keyword, e.g. |
Happy for you to reformat to match house style. |
I like this, it keeps the env variable local and explains why it is there. I'd like to rework the initialisation in a follow up so its not needed - the same approach can then be used for the Scene3D plugins and sensor system that need similar changes to support macOS. |
@iche033 the branch feature/v2-1-osrf should match the commit used in The branch feature/v2-1-osrf-macos contains a cherry-picked set of commits extracted from the These changes should be sufficient to support ign-rendering including You may want to omit the last commit on feature/v2-1-osrf-macos, I've added it because it's needed for me to build on macOS Big Sur without any of the additional patches in the |
great, thanks for working through those commits. I'll give your branch a try later this week / early next week. |
the feature/v2-1-osrf-macos branch without the last commit worked for me locally (on ubuntu). I've updated the homebrew formula with a new patch: https://github.com/ignition-forks/ogre-2.1-release/compare/b4c4fa785c03c2d4ba2a1d28d94394c7ca000358..81632330e3ab041345c7fa1075022cf6af30c658 Now just waiting for new bottles to be built 🤞 |
Just updated brew, reinstalled ogre2.1 and rebuilt ign-rendering. This demo working as are my local changes to support ignition gazebo 👍 |
awesome, thanks for verifying that the bottle works! I'm going to merge this and will update the coding style in a separate pull request. |
@ahcorde, just went through your comments, I think most of them have been addressed. Some style changes will come in follow-up PR. |
address some style changes in a separate PR
🎉 New feature
Summary
This PR adds a QML version of the simple_demo example. It uses a similar mechanism to render as used
by the Scene3D plugin and so serves as a useful prototyping and test environment for investigating
rendering issues in QML applications without the complexity of the full ignition gui or plugin infrastructure.
The initial use for this example was to resolve issues around support of ignition guis on macOS (gazebosim/gz-gui#145).
Upstream dependencies
For macOS there is an upstream dependency on Ogre2 pending this PR: OGRECave/ogre-next#216 which adds support for the currentGLContext parameter when creating a render window.
Test it
The changes may be tested by building and running the example. The expected outcome is the window below showing the rendered ignition scene under a QML overlay (run on macOS Big Sur 11.4).
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge