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.
Map view should use pixel density of current screen #7819
buggl-iosiOSMapbox Maps SDK for iOSmacOSMapbox Maps SDK for macOSnavigationFor the Mapbox Navigation SDK for Android or iOS or navigation use cases in general
When running macapp on a non-retina screen, the map graphics are aliased and chunky. This is on 10.12.3 beta — when I update to today’s official release version I will retest.
I wonder if this is happening because +[NSScreen mainScreen] is returning a screen other than the one this window is on. At the time you opened this window, did your MacBook Pro’s built-in Retina screen have keyboard focus?
At the time you opened this window, did your MacBook Pro’s built-in Retina screen have keyboard focus?
Yes, it turns out I was doing that — opened macapp from finder on the retina screen, but the app opened on the second, non-retina display. Focusing the non-retina screen and opening macapp on that screen works as expected (it’s anti-aliased).
Moving to a screen with a different pixel density doesn’t crash (on a release build), but the GL view does stop working and goes gray/whatever-the-style’s-background-color-is. MGLMapView UI elements remain visible and map interactions appear to still work, but nothing is drawn.
changed the title [-]Map graphics are aliased on non-retina screen[/-][+]Map should adjust pixel density when transitioning to non-Retina screen[/+]on Jan 25, 2017
changed the title [-]Map should adjust pixel density when transitioning to non-Retina screen[/-][+]Map view should use pixel density of current screen[/+]on Jan 25, 2017
The root cause is that we create mbgl::Map with the backing scale factor of the main screen (the screen that has keyboard focus) at the time of the view’s creation. But if you open the window on one screen by clicking on some icon on another screen, the main screen and the window’s screen are distinct and may have different scale factors.
We’re in a catch-22. Ideally we’d use a solution similar to #7846 when creating mbgl::Map. Unfortunately, we create mbgl::Map in -commonInit, before the view is added to a window, yet #1799 removed the ability for mbgl::Map to transition to a different pixel density once the view is added to a window. We’d need to move the map’s creation and anything that depends on mbgl::Map’s presence from -commonInit to -viewDidMoveToWindow. But it’s most common to call -setStyleURL: between initializing the map view and adding it to a subview, which would trigger a crash. Therefore, the only solution would be to undo #1799, and I don’t know if that would be feasible under the current architecture.
As of #12933, mbgl requests both 1× and 2× resources unconditionally, though the decision of which to display is still made at initialization and can’t be changed dynamically.
Per #13701, it’s also possible for the iOS map SDK to run in a mixed pixel density environment, specifically when connected to an external display via either AirPlay or CarPlay.
buggl-iosiOSMapbox Maps SDK for iOSmacOSMapbox Maps SDK for macOSnavigationFor the Mapbox Navigation SDK for Android or iOS or navigation use cases in general
Activity
1ec5 commentedon Jan 23, 2017
I wonder if this is happening because
+[NSScreen mainScreen]is returning a screen other than the one this window is on. At the time you opened this window, did your MacBook Pro’s built-in Retina screen have keyboard focus?friedbunny commentedon Jan 23, 2017
Yes, it turns out I was doing that — opened macapp from finder on the retina screen, but the app opened on the second, non-retina display. Focusing the non-retina screen and opening macapp on that screen works as expected (it’s anti-aliased).
1ec5 commentedon Jan 23, 2017
Incidentally, are you able to reproduce #6654?
friedbunny commentedon Jan 23, 2017
Moving to a screen with a different pixel density doesn’t crash (on a release build), but the GL view does stop working and goes gray/whatever-the-style’s-background-color-is. MGLMapView UI elements remain visible and map interactions appear to still work, but nothing is drawn.
friedbunny commentedon Jan 23, 2017
It looks like #3451 covered both the original aliasing issue and the disappearing GL view. That was closed in favor of #6654.
[-]Map graphics are aliased on non-retina screen[/-][+]Map should adjust pixel density when transitioning to non-Retina screen[/+][-]Map should adjust pixel density when transitioning to non-Retina screen[/-][+]Map view should use pixel density of current screen[/+]1ec5 commentedon Jan 25, 2017
The root cause is that we create
mbgl::Mapwith the backing scale factor of the main screen (the screen that has keyboard focus) at the time of the view’s creation. But if you open the window on one screen by clicking on some icon on another screen, the main screen and the window’s screen are distinct and may have different scale factors.We’re in a catch-22. Ideally we’d use a solution similar to #7846 when creating
mbgl::Map. Unfortunately, we creatembgl::Mapin-commonInit, before the view is added to a window, yet #1799 removed the ability formbgl::Mapto transition to a different pixel density once the view is added to a window. We’d need to move the map’s creation and anything that depends onmbgl::Map’s presence from-commonInitto-viewDidMoveToWindow. But it’s most common to call-setStyleURL:between initializing the map view and adding it to a subview, which would trigger a crash. Therefore, the only solution would be to undo #1799, and I don’t know if that would be feasible under the current architecture.1ec5 commentedon Sep 24, 2018
As of #12933, mbgl requests both 1× and 2× resources unconditionally, though the decision of which to display is still made at initialization and can’t be changed dynamically.
kkaefer commentedon Sep 24, 2018
@1ec5 no, that's quite what #12933 does. We only request both when creating an offline pack, not in regular operation.
1ec5 commentedon Jan 14, 2019
Per #13701, it’s also possible for the iOS map SDK to run in a mixed pixel density environment, specifically when connected to an external display via either AirPlay or CarPlay.
stale commentedon Jul 13, 2019
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.