Open PetrBo opened 4 years ago
I don't have an macOS system or expertise with macOS so have to defer to Mac users to figure out things. My guess is that Apple have changed the way they manage the scaling of the display, I believe there is already code in osgViewer's Mac support for this, but Apple have a habit of moving the goal posts so it might be worth having a look at the OpenSceneGraph/src/osgViewer/GraphicsWindowCocoa.mm source to see what t's doing now, and then have a to see if any of these API have changed or new API introduced by Apple in recent revs that deprecate the original API usage.
Just to confirm that we see the same issue in our OSG-based application, also starting with OSX 10.15 Catalina. Indeed, this "moving the goal posts" seems to be a major sport at Apple.
Hi, so I solved the issue by following (thanks @robertosfield for pointing out the GraphicsWindowCocoa.mm
):
OpenSceneGraph/src/osgViewer/GraphicsWindowCocoa.mm
I have added the line[_view setWantsBestResolutionOpenGLSurface: NO];
[_view setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable) ];
[_view setGraphicsWindowCocoa: this];
[_view setOpenGLContext:_context];
Probably it's not the "ultimate" solution, but as a quick fix good enough.
Good to hear you've found a workaround. Could you post a PR for this fix so others can try out the fix to see it works fine on different macOS versions and other software. Thanks,
On Tue, 17 Mar 2020 at 13:47, Petr Bobák notifications@github.com wrote:
Hi, so I solved the issue by following (thanks @robertosfield https://github.com/robertosfield for pointing out the GraphicsWindowCocoa.mm):
-
in OpenSceneGraph/src/osgViewer/GraphicsWindowCocoa.mm I have added the line [_view setWantsBestResolutionOpenGLSurface: NO];
under the block:
[_view setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable) ]; [_view setGraphicsWindowCocoa: this]; [_view setOpenGLContext:_context];
Probably it's not the "ultimate" solution, but as a quick fix good enough.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openscenegraph/OpenSceneGraph/issues/926#issuecomment-600080664, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABUA26JSCC24AVUNYVTLFLRH55OHANCNFSM4LLEG4DQ .
So I can confirm that the workaround by @PetrBo works for our application as well (on Catalina), great find this is a real life-saver! The lower resolution that comes as a result is somewhat noticeable, but is not really a big problem for our use-case.
I had another problem as well, though, with lots of crashes that werent there before Catalina. And the crashes always came after resizing the window or going full screen. After debugging and googling I found reading https://github.com/golang/go/issues/35177 where people had a similar problem, and I came upon the very useful comment:
However, I realize now that [ctx update]; is not necessary for the main purpose of makeCurrentContext and can be taken out. It was added in CL 154461 and I suspect that change is faulty, it's not thread safe to call [ctx update]; inside the makeCurrentContext function.
Inspired by this, I tried to comment out the call to [_context update] inside GraphicsWindowCocoa::makeCurrentImplementation(). Indeed this made the crashes go away, and until now I didn't observe any adverse effects. It is not clear to me if the change is backwards compatible with older versions of OSX or XCode.
@tkittel @PetrBo I can confirm this patch solves this issue (OSG 3.6.3):
---
src/osgViewer/GraphicsWindowCocoa.mm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/osgViewer/GraphicsWindowCocoa.mm b/src/osgViewer/GraphicsWindowCocoa.mm
index 5a3a54012..f8b1929a9 100644
--- a/src/osgViewer/GraphicsWindowCocoa.mm
+++ b/src/osgViewer/GraphicsWindowCocoa.mm
@@ -1223,6 +1223,7 @@ virtual void getWindowBounds(CGRect& rect)
[_view setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable) ];
[_view setGraphicsWindowCocoa: this];
[_view setOpenGLContext:_context];
+ [_view setWantsBestResolutionOpenGLSurface: NO];
// enable multitouch
if (_multiTouchEnabled || (windowData && windowData->isMultiTouchEnabled()))
@@ -1305,7 +1306,7 @@ virtual void getWindowBounds(CGRect& rect)
{
if (_updateContext)
{
- [_context update];
+ //[_context update];
_updateContext = false;
}
Could you generate a PR on the main OpenSceneGraph repo, I can review and merged from there, Thanks.
@openscenegraph any chance for a new release, so this fix can be distributed to e.g. conda packages?
I'm overwhelmed with other work right now so not in position to make an OSG release. OSG releases typically took me 4-6weeks of unpaid work to get all the testing and fixes merged so it's not something easy to add into my schedule.
@robertosfield that's perfectly understandable of course, unpaid work is unpaid work. And if you nonetheless at some point find the time and motivation to make a new release, we are many that would appreciate it highly - even if that release would only consist of the most critical fixes (like this one). Cheers!
Hello, the
osgviewer
draws the scene only in the bottom left quadrant of the screen on macOS 10.15.3 (19D76) Catalina (please see the image below). I have tried to build OSG from the latest source 3.7.0, as well as the stable 3.6.5 version – nothing helped.It seems it is somehow related to the issue:
CMake log (3.7.0):