GNOME Bugzilla – Bug 765883
console error on OS X when using a HiDPI display
Last modified: 2017-05-09 18:03:47 UTC
I am seeing the following error in the console when using a HiDPI display. *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
The error occurs due to the following line of code in gdk/quartz/gdkscreen-quartz.c: _gdk_screen_set_resolution (screen, 72.0 * [nsscreen userSpaceScaleFactor]); I tried changing userSpaceScaleFactor to backingScaleFactor and this suppressed the error but everything was displaying too large. Upon further examination I discovered the following: normal display HiDPI display -------------- ------------- userSpaceScaleFactor 1.0 1.0 backingScaleFactor 1.0 2.0 Hard-coding the scale factor to 1 here will both suppress the error and produce the correct scaling. I'm not sure if that is the right solution because the author clearly didn't expect userSpaceScaleFactor to always be 1. My testing was done on OS X 10.11.4 (El Capitan).
I think the problem for us here is that by moving to the non-deprecated API, we would have to significantly bump the required OS X version and that dependency would fall through to applications using GTK+.
Well, as I described, the fix seems to be to remove the API altogether. It doesn't seem to be returning what the author expected. Even if it was, couldn't there be a check for the OS X version and use the appropriate API for the version?
(In reply to draymond from comment #3) > Well, as I described, the fix seems to be to remove the API altogether. It > doesn't seem to be returning what the author expected. Even if it was, > couldn't there be a check for the OS X version and use the appropriate API > for the version? Developers and users often do not run the same version of OS X. So a compile time check is probably not sufficient.
Perhaps a runtime check is possible? How far back do we support anyways? The API was deprecated starting with OS X 10.7 (Lion). The previous release was 10.6 (Snow Leopard) and it was released in 2009. My app supports 10.7 and later (and I have to use CFLAGS=-mmacosx-version-min=10.7 for that). But, once again, all of this is a moot point if we don't need the API at all as my testing suggests. If nobody has any objections I propose we close out this bug by changing the above line to: _gdk_screen_set_resolution (screen, 72.0);
This issue still exists in 3.22.7.
I've changed gdk_quartz_screen_init and gdkquartz-screen.c's get_mm_from_pixels to use NSScreen:deviceDescription[NSDeviceResolution] which is the documented way to get the resolution and is supported at least as far back as 10.6 (it's not marked with an NS_AVAILABLE macro so it might go back to NextStep). This returns 72.0 on non-retina monitors and 144.0 on retina ones. A followup on bug 781118 reports the same issue noted here: When the larger value is passed to _gdk_screen_set_resolution the text size (but not icon size) doubles. When I copied a bundled gtk3-demo compiled on 10.12.3 to a retina MacBookPro running 10.11.6 I didn't see that issue. draymond, can you please test either master or gtk-3-22 HEAD and see if you see the text-doubling issue?
The original problem reported here is fixed. The font size doubling is addressed explicitly by bug 782393.