You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
macOS SDK crashes when moving between screens #6654
When moving the macOS SDK window between screens (one with a Retina pixel ratio, and the other with a regular pixel ratio in my case), I'm getting a crash when trying to update the FrameHistory texture. It doesn't appear to be specific to that texture since it crashes at other locations as well if that upload is commented out. It seems like doing any sort of OpenGL API call triggers this crash.
Using apitrace, I found that just prior to the crash, CGLUpdateContext is called, and returns kCGLBadDrawable.
The crash does not appear when moving GLFW windows between screens, making me believe that there's something fishy in our use of NSOpenGLLayer or the macOS implementation in general.
Out of curiosity, @kkaefer do you see this as merely an annoyance / nice to have or something we should prioritize more highly to be 100% correct? Like, it's not a very common user scenario, right?
It's not super common, but it is an unavoidable crash bug that might deter people from using it on an actual macOS app. That being said, it's also annoying when testing since I sometimes move windows between screens.
It's pretty common to have screens with different pixel densities, particularly on a MacBook that may be hooked up to a non-Apple monitor or a projection screen.
The higher priority would be to not crash in this scenario. Ideally, the map would refresh with the correct pixel density – there's a notification for that – but auto-refreshing might buck developer expectations around the runtime styling API.
Per #7819 (comment), moving a map view between different screens doesn’t crash in a Release build, but it does stop rendering, which suggests that it would crash in a Debug build.
#1799 removed the ability for an mbgl::Map object to transition between different pixel densities. So a proper fix for this issue would entail either undoing #1799 or somehow creating a new mbgl::Map whenever the window moves between screens. Either approach sounds daunting.
I debugged this further with apitrace and found that when moving the window to a new screen, the underlying NSOpenGLLayer implementation actually destroys the OpenGL context and creates a new one. Of course, that means that all of the OpenGL handles we've stored in our internal state are now invalid, leading to the crash.
Activity
jfirebaugh commentedon Oct 11, 2016
Probably should consolidate with #5010 and #3451.
incanus commentedon Oct 12, 2016
Out of curiosity, @kkaefer do you see this as merely an annoyance / nice to have or something we should prioritize more highly to be 100% correct? Like, it's not a very common user scenario, right?
kkaefer commentedon Oct 13, 2016
It's not super common, but it is an unavoidable crash bug that might deter people from using it on an actual macOS app. That being said, it's also annoying when testing since I sometimes move windows between screens.
1ec5 commentedon Oct 13, 2016
It's pretty common to have screens with different pixel densities, particularly on a MacBook that may be hooked up to a non-Apple monitor or a projection screen.
The higher priority would be to not crash in this scenario. Ideally, the map would refresh with the correct pixel density – there's a notification for that – but auto-refreshing might buck developer expectations around the runtime styling API.
1ec5 commentedon Oct 13, 2016
As far as I know, GLFW uses NSOpenGLView but doesn't use NSOpenGLLayer directly as this SDK does.
1ec5 commentedon Jan 25, 2017
Per #7819 (comment), moving a map view between different screens doesn’t crash in a Release build, but it does stop rendering, which suggests that it would crash in a Debug build.
#1799 removed the ability for an
mbgl::Mapobject to transition between different pixel densities. So a proper fix for this issue would entail either undoing #1799 or somehow creating a newmbgl::Mapwhenever the window moves between screens. Either approach sounds daunting.kkaefer commentedon Feb 6, 2017
I debugged this further with apitrace and found that when moving the window to a new screen, the underlying NSOpenGLLayer implementation actually destroys the OpenGL context and creates a new one. Of course, that means that all of the OpenGL handles we've stored in our internal state are now invalid, leading to the crash.