After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 765883 - console error on OS X when using a HiDPI display
console error on OS X when using a HiDPI display
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
3.20.x
Other Mac OS
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-05-01 19:37 UTC by draymond
Modified: 2017-05-09 18:03 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description draymond 2016-05-01 19:37:01 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.
Comment 1 draymond 2016-05-01 22:21:04 UTC
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).
Comment 2 Christian Hergert 2016-05-03 08:47:18 UTC
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+.
Comment 3 draymond 2016-05-03 13:12:32 UTC
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?
Comment 4 Christian Hergert 2016-05-03 15:37:54 UTC
(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.
Comment 5 draymond 2016-05-04 01:07:04 UTC
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);
Comment 6 draymond 2017-01-31 02:13:30 UTC
This issue still exists in 3.22.7.
Comment 7 John Ralls 2017-04-16 22:22:34 UTC
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?
Comment 8 John Ralls 2017-05-09 18:03:47 UTC
The original problem reported here is fixed. The font size doubling is addressed explicitly by bug 782393.