Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX: Exclusive fullscreen failure in CGDisplaySetDisplayMode happening in dota2 #2711

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 2.0.6
Reported for operating system, platform: macOS 10.12, x86_64

Comments on the original bug report:

On 2017-11-08 19:39:50 +0000, Dan Ginsburg wrote:

The problem is that on several Mac models on version 10.12.5, 10.12.6, and 10.11.6 with AMD hardware are failing to enter exclusive fullscreen mode in Dota 2. See: ValveSoftware/Dota-2#1333

I am able to repro this on Mac Pro 10.11.6 with AMD FirePro D300 by setting my desktop resolution to Scaled 1600x900 and then choosing Exclusive Fullscreen 1920x1080 in Dota 2. After restarting Dota 2, each time it will fail to enter exclusive fullscreen mode.

I've bisected the problem to this change:

http://hg.libsdl.org/SDL/rev/1e26564c7288

Reverting that change makes the bug go awawy.

What is happening is that:

  • That commit changed Cocoa_GetDisplayModes to pass a dict with kCGDisplayShowDuplicateLowResolutionModes to CGDisplayCopyAllDisplayModes. If I remove that portion of the change, it resolves the issue.
  • What is happening is that in Cocoa_SetDisplayMode the call to CGDisplaySetDisplayMode is returning kCGErrorFailure.
  • I also see this in the output log:

Nov 8 11:29:28 dota2[62909] : displaySetMode: unable to find mode dict in array

I tried changing CGDisplaySetDisplayMode to take a similar dict, but it does not fix the problem.

It seems the kCGDisplayShowDuplicateLowResolutionModes is an undocumented API so I wonder if it can't reliably be used.

On 2017-11-08 19:57:04 +0000, Sam Lantinga wrote:

Alex, this is affecting DOTA 2, so we're going to back out the change until you have a chance to look at it.

On 2017-11-09 21:37:16 +0000, Eric Wasylishen wrote:

BTW here is a quick hacky bit of logging you can paste in Cocoa_GetDisplayModes to see what kCGDisplayShowDuplicateLowResolutionModes is doing on that machine / config:

{
    NSLog(@"display modes for %s with kCGDisplayShowDuplicateLowResolutionModes set to true:", Cocoa_GetDisplayName(data->display));
    for (id mode in (NSArray *)CGDisplayCopyAllDisplayModes(data->display, (CFDictionaryRef)@{(id)kCGDisplayShowDuplicateLowResolutionModes : (id)kCFBooleanTrue})) {
        CGDisplayModeRef cgmode = (CGDisplayModeRef)mode;
        NSLog(@"    %dx%d points, %dx%d pixels @ %d Hz", (int)CGDisplayModeGetWidth(cgmode), (int)CGDisplayModeGetHeight(cgmode), (int)CGDisplayModeGetPixelWidth(cgmode), (int)CGDisplayModeGetPixelHeight(cgmode), (int)CGDisplayModeGetRefreshRate(cgmode));
    }
    NSLog(@"display modes for %s with no flags:", Cocoa_GetDisplayName(data->display));
    for (id mode in (NSArray*)CGDisplayCopyAllDisplayModes(data->display, NULL)) {
        CGDisplayModeRef cgmode = (CGDisplayModeRef)mode;
        NSLog(@"    %dx%d points, %dx%d pixels @ %d Hz", (int)CGDisplayModeGetWidth(cgmode), (int)CGDisplayModeGetHeight(cgmode), (int)CGDisplayModeGetPixelWidth(cgmode), (int)CGDisplayModeGetPixelHeight(cgmode), (int)CGDisplayModeGetRefreshRate(cgmode));
    }
}

On my 15" retina macbook pro (2012) with nVidia graphics, setting kCGDisplayShowDuplicateLowResolutionModes to true causes "high DPI" display modes to show up in the list, e.g. "1920x1200 points, 3840x2400 pixels @ 0 Hz", otherwise all of the modes have equal points and pixels sizes.

It might also be worth checking the CGDisplayModeGetWidth and CGDisplayModeGetPixelWidth of the mode that causes CGDisplaySetDisplayMode to fail.

At first glance it seems like on the AMD machine, kCGDisplayShowDuplicateLowResolutionModes is causing some 1920x1080 points mode to be returned that can't actually be switched to.

On 2019-10-24 23:17:15 +0000, Alex Szpakowski wrote:

I've applied an improved version of the original change that was backed out. This time it also falls back to the legacy codepath on macOS 10.12 and older: https://hg.libsdl.org/SDL/rev/d62dcbe19211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant