Skip to content

Commit 7b70ced

Browse files
Merge pull request #9 from RoboStack/fix-rviz-rendering-osx
fix: add patch to fix rviz stuck in initializing on osx platform
2 parents 65be811 + 627f005 commit 7b70ced

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
diff --git a/src/rviz_rendering/ogre_render_window_impl.cpp b/src/rviz_rendering/ogre_render_window_impl.cpp
2+
index 466e1d1e4..8fcd56d57 100644
3+
--- a/src/rviz_rendering/ogre_render_window_impl.cpp
4+
+++ b/src/rviz_rendering/ogre_render_window_impl.cpp
5+
@@ -235,12 +235,21 @@ void
6+
RenderWindowImpl::resize(size_t width, size_t height)
7+
{
8+
if (ogre_render_window_) {
9+
- this->setCameraAspectRatio();
10+
- ogre_render_window_->resize(
11+
- static_cast<unsigned int>(width), // NOLINT
12+
- static_cast<unsigned int>(height) // NOLINT
13+
- );
14+
- ogre_render_window_->windowMovedOrResized();
15+
+ // Skip the costly Ogre resize / windowMovedOrResized when the size has
16+
+ // not actually changed. On macOS Sonoma+, windowMovedOrResized triggers
17+
+ // [NSOpenGLContext update] -> CGLSetVirtualScreen, which is hundreds of
18+
+ // ms per call under the OpenGL-on-Metal compatibility path; each call
19+
+ // also re-fires an expose event, so calling it on every expose creates
20+
+ // a positive-feedback loop that makes the splash screen never progress.
21+
+ const auto w = static_cast<unsigned int>(width);
22+
+ const auto h = static_cast<unsigned int>(height);
23+
+ if (w != last_resize_width_ || h != last_resize_height_) {
24+
+ last_resize_width_ = w;
25+
+ last_resize_height_ = h;
26+
+ this->setCameraAspectRatio();
27+
+ ogre_render_window_->resize(w, h);
28+
+ ogre_render_window_->windowMovedOrResized();
29+
+ }
30+
}
31+
this->renderLater();
32+
}
33+
diff --git a/src/rviz_rendering/ogre_render_window_impl.hpp b/src/rviz_rendering/ogre_render_window_impl.hpp
34+
index 7bd7b2238..8391498fe 100644
35+
--- a/src/rviz_rendering/ogre_render_window_impl.hpp
36+
+++ b/src/rviz_rendering/ogre_render_window_impl.hpp
37+
@@ -150,6 +150,9 @@ protected:
38+
39+
bool animating_;
40+
41+
+ unsigned int last_resize_width_{0};
42+
+ unsigned int last_resize_height_{0};
43+
+
44+
Ogre::Viewport * ogre_viewport_;
45+
46+
// std::function<void()> pre_render_callback_; ///< Functor which is called before each render

pkg_additional_info.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,6 @@ compressed_depth_image_transport:
171171
additional_cmake_args: "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON"
172172
moveit_ros_visualization:
173173
additional_cmake_args: "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON"
174+
# Remove all lines after this one on new full rebuild
175+
rviz_rendering:
176+
build_number: 19

0 commit comments

Comments
 (0)