openscenegraph / OpenSceneGraph

OpenSceneGraph git repository
http://www.openscenegraph.org
Other
3.19k stars 1.41k forks source link

[macOS Catalina 10.15] Only the bottom left quadrant of the screen is used #926

Open PetrBo opened 4 years ago

PetrBo commented 4 years ago

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:

macos_catalina

CMake log (3.7.0):

OSG_OSX_VERSION=10.15 The C compiler identification is AppleClang 11.0.0.11000033 The CXX compiler identification is AppleClang 11.0.0.11000033 Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works Detecting C compiler ABI info Detecting C compiler ABI info - done Detecting C compile features Detecting C compile features - done Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works Detecting CXX compiler ABI info Detecting CXX compiler ABI info - done Detecting CXX compile features Detecting CXX compile features - done Looking for pthread.h Looking for pthread.h - found Performing Test CMAKE_HAVE_LIBC_PTHREAD Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success Found Threads: TRUE
Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework
Could NOT find EGL, try to set the path to EGL root folder in the system variable EGL_DIR (missing: EGL_LIBRARY EGL_INCLUDE_DIR) Found X11: /opt/X11/include
Looking for XOpenDisplay in /opt/X11/lib/libX11.dylib;/opt/X11/lib/libXext.dylib Looking for XOpenDisplay in /opt/X11/lib/libX11.dylib;/opt/X11/lib/libXext.dylib - found Looking for gethostbyname Looking for gethostbyname - found Looking for connect Looking for connect - found Looking for remove Looking for remove - found Looking for shmat Looking for shmat - found Looking for IceConnectionNumber in ICE Looking for IceConnectionNumber in ICE - found Performing Test GL_HEADER_HAS_GLINT64 Performing Test GL_HEADER_HAS_GLINT64 - Success Performing Test GL_HEADER_HAS_GLUINT64 Performing Test GL_HEADER_HAS_GLUINT64 - Success Could NOT find Freetype (missing: FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS) Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR) Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR JPEG_LIBRARIES) Found LibXml2: /usr/lib/libxml2.dylib (found version "2.9.4") Found ZLIB: /usr/lib/libz.dylib (found version "1.2.11") Found GDAL: /usr/local/lib/libgdal.dylib (found version "2.4.4") Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) Found CURL: /usr/lib/libcurl.dylib (found version "7.64.1")
Trying to find DCMTK expecting DCMTKConfig.cmake Trying to find DCMTK expecting DCMTKConfig.cmake - failed Trying to find DCMTK relying on FindDCMTK.cmake Please set DCMTK_DIR and re-run configure (missing: DCMTK_config_INCLUDE_DIR DCMTK_dcmdata_INCLUDE_DIR DCMTK_dcmimage_INCLUDE_DIR DCMTK_dcmimgle_INCLUDE_DIR DCMTK_dcmjpeg_INCLUDE_DIR DCMTK_dcmjpls_INCLUDE_DIR DCMTK_dcmnet_INCLUDE_DIR DCMTK_dcmpstat_INCLUDE_DIR DCMTK_dcmqrdb_INCLUDE_DIR DCMTK_dcmsign_INCLUDE_DIR DCMTK_dcmsr_INCLUDE_DIR DCMTK_dcmtls_INCLUDE_DIR DCMTK_ofstd_INCLUDE_DIR DCMTK_oflog_INCLUDE_DIR DCMTK_LIBRARIES) Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) Could NOT find GStreamer (missing: GSTREAMER_INCLUDE_DIRS GSTREAMER_LIBRARIES GSTREAMER_VERSION GSTREAMER_BASE_INCLUDE_DIRS GSTREAMER_BASE_LIBRARIES GSTREAMER_APP_INCLUDE_DIRS GSTREAMER_APP_LIBRARIES GSTREAMER_PBUTILS_INCLUDE_DIRS GSTREAMER_PBUTILS_LIBRARIES) (found version "") Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) Found GLIB: /usr/local/include/glib-2.0;/usr/local/lib/glib-2.0/include (found version "2.54.0") Found SDL2: /Library/Frameworks/SDL2.framework;-framework Cocoa
Found SDL: /Library/Frameworks/SDL.framework;-framework Cocoa (found version "1.2.15") Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR) Disabling QuickTime on 64-bit architectures Performing Test _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS Performing Test _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS - Success Performing Test _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS Performing Test _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS - Failed Performing Test _OPENTHREADS_ATOMIC_USE_SUN Performing Test _OPENTHREADS_ATOMIC_USE_SUN - Failed Performing Test _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED Performing Test _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED - Failed Performing Test _OPENTHREADS_ATOMIC_USE_BSD_ATOMIC Performing Test _OPENTHREADS_ATOMIC_USE_BSD_ATOMIC - Success Looking for pthread_yield Looking for pthread_yield - not found Looking for sched_yield Looking for sched_yield - found Looking for pthread_setconcurrency Looking for pthread_setconcurrency - found Looking for pthread_getconcurrency Looking for pthread_getconcurrency - found Looking for pthread_setaffinity_np Looking for pthread_setaffinity_np - not found Performing Test HAVE_THREE_PARAM_SCHED_SETAFFINITY Performing Test HAVE_THREE_PARAM_SCHED_SETAFFINITY - Failed Performing Test HAVE_TWO_PARAM_SCHED_SETAFFINITY Performing Test HAVE_TWO_PARAM_SCHED_SETAFFINITY - Failed Could NOT find Fontconfig (missing: FONTCONFIG_LIBRARY FONTCONFIG_INCLUDE_DIR) osgText will not be linked with FontConfig library Looking for gethostbyname in nsl Looking for gethostbyname in nsl - not found Looking for socket in socket Looking for socket in socket - not found

The build system is configured to install libraries to /usr/local/lib Your applications may not be able to find your installed libraries unless you: set your LD_LIBRARY_PATH (user specific) or update your ld.so configuration (system wide) The following OPTIONAL packages have been found:

  • OpenGL
  • X11
  • LibXml2
  • ZLIB
  • GDAL
  • CURL
  • GLIB
  • SDL2
  • SDL
  • ZeroConf
  • CoreVideo
  • CoreMedia
  • QuartzCore
  • Threads

-- The following OPTIONAL packages have not been found:

  • EGL
  • Freetype
  • ilmbase
  • Inventor
  • JPEG
  • Jasper
  • OpenEXR
  • OpenCascade
  • COLLADA
  • FBX
  • GTA
  • LibVNCServer
  • DCMTK
  • FFmpeg
  • GStreamer
  • DirectShow
  • Poppler-glib
  • RSVG
  • GtkGl
  • DirectInput
  • NVTT
  • Asio
  • LIBLAS
  • TIFF
  • QuickTime
  • QTKit
  • AVFoundation
  • Fontconfig

Configuring done

robertosfield commented 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.

tkittel commented 4 years ago

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.

PetrBo commented 4 years ago

Hi, so I solved the issue by following (thanks @robertosfield for pointing out the GraphicsWindowCocoa.mm):

[_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.

openscenegraph commented 4 years ago

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 .

tkittel commented 4 years ago

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.

remoe commented 4 years ago

@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;
     }
robertosfield commented 4 years ago

Could you generate a PR on the main OpenSceneGraph repo, I can review and merged from there, Thanks.

tkittel commented 5 months ago

@openscenegraph any chance for a new release, so this fix can be distributed to e.g. conda packages?

robertosfield commented 5 months ago

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.

tkittel commented 5 months ago

@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!