ValveSoftware / csgo-osx-linux

Counter-Strike: Global Offensive
http://counter-strike.net
771 stars 68 forks source link

CS2 as fullscreen always tries to launch secondary monitor, tries to use refresh rates of primary monitor #3282

Open delbonis opened 9 months ago

delbonis commented 9 months ago

Your system information

Please describe your issue in as much detail as possible:

I have a 165Hz monitor which is normally my primary (left) and a 60Hz monitor which is normally my secondary (right), both are 2560x1440. See Ubuntu displays configuration UI screenshot below.

CS2 seems to only want to start to start on the secondary monitor, regardless of which monitors are configured as which in Ubuntu, and then it only provides refresh rate options for the primary monitor. That is to say:

In either case, I can enter a game, but there's pretty noticeable latency between moving my mouse and the camera rotating. I'm not sure if that's on the input side or the display output side, I'm not sure how to test that.

I've tried swapping the sockets on my graphics card that the monitors are plugged into, rebooting, etc, behavior is unchanged. I thought it could be some issue with how Linux/Xorg enumerates the displays and swapping the physical inputs could change that but that doesn't seem to be the problem, but I may be wrong.

xrandr output (in first configuration listed above):

$ xrandr 
Screen 0: minimum 320 x 200, current 5120 x 1440, maximum 16384 x 16384
DisplayPort-0 connected 2560x1440+2560+0 (normal left inverted right x axis y axis) 597mm x 336mm
   2560x1440     59.95*+
   1920x1200     59.88  
   1920x1080     60.00    60.00    50.00    59.94  
   1600x1200     60.00  
   1680x1050     59.95  
   1280x1024     75.02    60.02  
   1440x900      59.89  
   1366x768      60.00  
   1280x800      59.95  
   1152x864      75.00  
   1280x720      60.00    50.00    59.94  
   1024x768      75.03    60.00  
   832x624       74.55  
   800x600       75.00    60.32    56.25  
   720x576       50.00  
   720x480       60.00    59.94  
   640x480       75.00    60.00    59.94  
   720x400       70.08  
DisplayPort-1 connected primary 2560x1440+0+0 (normal left inverted right x axis y axis) 598mm x 336mm
   2560x1440     59.95 + 165.00*  144.00   120.00    99.95    84.98    23.97  
   1920x1200     59.95  
   1920x1080     59.95  
   1600x1200     59.95  
   1680x1050     59.95  
   1280x1024     59.95  
   1440x900      59.95  
   1280x800      59.95  
   1280x720      59.95  
   1024x768      60.00  
   800x600       60.32  
   640x480       60.00    59.94  
HDMI-A-0 disconnected (normal left inverted right x axis y axis)
DisplayPort-2 disconnected (normal left inverted right x axis y axis)

When unplugging the 60Hz monitor, the game does start on the 165Hz monitor and shows the appropriate refresh rates (up to 164Hz and some other weird ones, but it looks close enough), but it still renders underneath the GNOME window decoration (as below, notice the transparent left bar shows the game underneath it) even when in-game and still has the control latency issue.

Screenshot from 2023-09-27 21-36-52

Once, when trying to switch to borderless windowed mode in the two monitor configuration it started rapidly switching between my primary and secondary monitors. I ended up having to force reboot because my computer became unusable at that point, and added -fullscreen to be able to play it again. I also had a weird incident where it started as "fullscreen" but was 1920x1080 in the upper left of the primary monitor, I can't really figure out how to reproduce that. Trying to switch it to fullscreen again I had some weird pixel scaling issues that looked like it was rendering at 1920x1080 scaled up to the reported 2560x1440 until I restarted the game.

Ubuntu displays configuration:

image

Steps for reproducing this issue:

  1. Have two monitors, possibly needing different refresh rates.
  2. Use launch options SDL_AUDIO_DRIVER=pipewire %command% -nojoy -vulkan -fullscreen.
  3. Try to play CS2, in fullscreen. Using -fullscreen or just the normal setting in the menu doesn't seem to make a difference.
  4. It's weird, as described above.

I have not tried using Wayland yet, will update if it persists.

delbonis commented 9 months ago

Wayland:

Weird refresh rate selection issue persists the same as under X. However, the input/control latency issue was gone and some weirdness associated with changing display formats seemingly fixed? Maybe I didn't mess with it long enough for the issues to appear.

However I was able to reproduce the fake fullscreen corner rendering thing.

  1. 165Hz as primary, 60Hz as secondary.
  2. Start game, which opens on secondary in fullscreen.
  3. Leave default 164Hz refresh rate as-is normal. Switch to widowed 1920x1080.
  4. Drag window to 165Hz primary monitor. The game can be played basically normally at the high refresh rate, albeit in the smaller window and with what being windowed entails.
  5. Switch to fullscreen 2560x1440, which, amazingly, fullscreens on the 165Hz monitor. I don't think there was the possible resolution scaling issue that I described above but the HUD looked kinda weird. I may have been imagining that.
  6. Close game.
  7. Restart game. It reports as being "fullscreen" at 1920x1080 in the upper left as below.

image

Update: After closing the game again and restarting it, it does the rapidly-switch-monitors thing that it did under X when trying to do borderless windowed and I can't seem to stop it. Although it's not really in danger of making my whole OS unstable anymore so I can force quit it through Steam normally.

Update 2: I can't reproduce this anymore, maybe I wrote down the steps differently than I actually did or the update changed. I've been playing windowed at the second-highest resolution option for now. I think there may still be a couple extra frames of latency somewhere in there that's leading to camera motion still feeling somewhat sluggish, but I don't have the tools to figure out if that's actually true.

OlliC commented 9 months ago

Same problem here in Fedora 38 with Wayland and dual monitors. Without -fullscreen launch option it does this strange flicking between monitors thing. But if you are fast, you can time it to bring the steam window up again to close cs2. With -fullscreen option it always launches on the secondary monitor even after dragging the window to my primary monitor and closing it there. Old CSGO would remember my last monitor and start there.

peiart99 commented 9 months ago

Same problem on pop_os 22.04. I have dual monitors, 60Hz and 165Hz. The game launches on the secondary 60Hz monitor and when I do anything outside of the game window it starts flicking between monitors making it hard to even close the game.

eNTi commented 9 months ago

Having the exact same issue on Artix Linux. Why can't we set the preferred display?

gargoyle commented 9 months ago

Same here. Dual monitors, both 2560x1440. Primary is 160hz, secondary is 60hz. If I disable the secondary monitor the game launches on the primary one ok. Otherwise if I window it, I get the flickering (I can probably upload and link a video if it helps). If I fullscreen, it always opens on the secondary monitor.

sm9cc commented 9 months ago

I managed to force the correct display using KDE Window Rules.

Having the exact same issue on Artix Linux. Why can't we set the preferred display?

Fellow Artix user 💪

gargoyle commented 9 months ago

Finally got into a game and it's completely unplayable.... pretty much any movement rubber-bands back to where I spawned.

alioguzhan commented 9 months ago

Same here on NixOS / Gnome / Wayland / Dual monitors (both 2560x1440). If I go with the windowed full screen it keeps jumping between the monitors. With fullscreen enabled it always launches on the secondary monitor. And since it is fullscreen, I can't move it to my primary monitor.

Note: This occurs both on X11 / Wayland.

gargoyle commented 9 months ago

Fedora 38 + wayland workaround:-

1.) Launch the game (assuming fullscreen), and it will be on your secondary. Change to windowed mode apply and drag to your primary, then set back to fullscreen. Game seems perfectly playable (I had a few stutters, but I have bad internets).

2.) Next time you launch the game, it will launch on your primary, but it some silly resolution on the top left corner. Set it back to your desired res (2560x1440 in my case). However, this will fill the screen but the resolution wont change and you'll have a blocky minecraft looking POS. Quit the game and releaunch. You'll be back on your secondary monitor in fullscreen mode. Go back to step 1 and repeat!

Yeah, a total PITA, bit at least you can play for a little while.

furai commented 9 months ago

Getting exactly the same issue with 3 monitors. My main one is the middle one and it always tries to open game on the screen to the right and then jumps between the two. (Side note: the same issue happens when launching steam in big picture mode.)

danginsburg commented 9 months ago

Does using -sdl_displayindex # (#=0,1,2 for display index) fix this for you? We don't have this exposed in the UI but it is supported by the engine.

slovdahl commented 9 months ago

Does using -sdl_displayindex # (#=0,1,2 for display index) fix this for you? We don't have this exposed in the UI but it is supported by the engine.

Two monitors here, -sdl_displayindex 0 or -sdl_displayindex 2 did not change anything, but -sdl_displayindex 1 seemed to at least allow me to start the game, albeit on the monitor I don't want it on, and I'm also unable to alt+tab to any other window while the game is running with the switch active.

inlart commented 9 months ago

Does using -sdl_displayindex # (#=0,1,2 for display index) fix this for you? We don't have this exposed in the UI but it is supported by the engine.

I also have a dual monitor setup with different refresh rates (144Hz and 60Hz). I also experience the fast switching between monitors in fullscreen windowed mode and the game only launching on the secondary monitor in fullscreen mode. The game is also not movable to the primary screen in fullscreen mode.

I tried the -sdl_displayindex option with different indices but the game still always launches on the secondary monitor if in fullscreen mode.

Interestingly, the game now launches fine on the secondary monitor in fullscreen windowed mode with -sdl_displayindex 1. I can also drag the game to the primary display without any issues. With -sdl_displayindex 0 I still get the fast switching between the monitors.

Example launch option I used, e.g. for index 0: +exec autoexec.cfg -novid -nojoy -vulkan -sdl_displayindex 0

The only way to launch the game on my 144Hz monitor right now is by selecting the 60Hz monitor as primary display in the Gnome display settings.

JellyWX commented 9 months ago

I've got a bit of a workaround by using gamescope. I installed from here (Pop_OS 22) https://launchpad.net/~samoilov-lex/+archive/ubuntu/gamescope

And then used these launch options in Steam: gamescope -W 1920 -H 1080 -f -- %command% +exec autoexec.cfg -sdlaudiodriver pipewire (adjust -W, -H as required). I set CS2 to then run in fullscreen mode.

I haven't tested it thoroughly: the mouse sensitivity on menus is too low for some reason, but in game it seems fine. Additionally, Alt-F4 to close doesn't work in gamescope.

...From playing a few deathmatch games, the framerate feels bad. Not sure how to fix this- the game shows high enough FPS

OlliC commented 9 months ago

After the CS2 update today it does not do the flicking between monitors anymore without any startup parameters. But it still always launches on the secondary monitor. I can then go to the graphics settings, change to window mode, drag the window over and go fullscreen again. -sdl_displayindex does not seem to have an effect.

Kenajcrap commented 9 months ago

Another clue about the problem: I have a monitor in which I overwrote the EDID to only present 74hz as compatible, and not 60hz, and I have another one of the same model which is default. Whichever monitor the game loads on, in fullscreen (and not fullscreen windowed) the refresh rate option only shows the frequencies compatible with the primary monitor as set in the GNOME Display Options (or NVIDIA X Server).

Maybe the problem is that SDL not enumerating the displays correctly on all boxes or the game is wrongly assuming the first one applies to every monitor

On older source games, when selecting between fullscreen or windowed, you had the option to choose which monitor you wanted to use for fullscreen. Regardless of the bugs with monitor detection on CS2, I think this option is more user friendly since it doesn't require the user to know the common "Super + Shift + Arrow Keys" shortcut, or in the worse/less informed scenario, set the game to windowed, drag the window, then set it to full screen again.

image

micr0-dev commented 9 months ago

Same problem here, unable to use my 240hz monitor as the game locks to the refresh rate of my primary 60hz monitor, this was not an issue with CSGO

OpenSauce04 commented 9 months ago

Recreated on both Debian and Gentoo, both using Gnome 44/45 + X11

alioguzhan commented 8 months ago

OK, Here is how I workarounded this:

First, CS2 is consistent here at least. It always tries to launch on the secondary monitor. If you go the gnome settings and change the primary monitor to the other one, the game will start on the correct monitor. You can also change the primary monitor via xrandr command. So based on this, here is my CS2 startup command:

xrandr --output DP-3 --primary && mangohud %command% && xrandr --output DP-1 --primary

DP-3 is my secondary monitor. DP-1 is my primary monitor.
&& waits for the commands till exit.

So here is what happens here:

  1. Change the primary monitor to the left one (my left)
    • So the game will start on the right one (the one I stare at directly)
  2. Start the game with mangohud
  3. When the game exits, restore the original positions.

And this works. Thanks, Valve.

Note: You can see your active monitors and their names via xrandr | grep -i connected command. Here is mine:

❯ xrandr | grep -i connected    
DP-1 connected primary 2560x1440+2560+0 (normal left inverted right x axis y axis) 597mm x 336mm
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 connected 2560x1440+0+0 (normal left inverted right x axis y axis) 597mm x 336mm
HDMI-1 disconnected (normal left inverted right x axis y axis)
Mind78 commented 8 months ago

Exactly the same problem here, primary display 165 Hz, secondary 60 Hz. But I am using Linux Mint mate, latest version.

It's definitively a CS2 issue. cs:go did not do this, neither does any other game. I can switch to windowed mode, move the window to the primary display and then switch back to fullscreen. It will then run on the primary display until next time I start the game. However, all sounds are delayed by 1 second. Input is fine. But performance is really really poor. Everything at absolute minimum gives 80 fps (on average, meaning 15 to 140 fps fluctuating) and stuttering with a machine that would give several hundreds of fps on any other game with comparable graphics.

[Edit:]

Some update fixed the performance issue to a large degree, but not perfectly. However, the latest update that added the new gamemode and extra content also totally destroyed the performance. To the degree game freezes, character keeps walking into a wall, and is pressed against the wall for 10 seconds. Or if I'm shooting, empties the entire mag. It spams the console with sound errors. Tried playing with no sound, meaning it goes to a dummy device and is thrown away with no processing, this doesn't help. Console still spams about starved samples 256. So it might have something to do with sound rather than display. As of now [Feb 12, 2024], the game is totally unplayable, like 1 fps, with an AMD 6700.

mvrk69 commented 8 months ago

Same thing here (Fedora 37 / Xorg), game always opens on secondary monitor

shucking commented 7 months ago

Similar behaviour on EndeavourOS, X11 and Wayland, where game launches on secondary monitor and shows primary monitor's refresh rate (165hz) instead of secondary's (60hz). I tried the -sdl_displayindex launch option with no luck.

symbn commented 6 months ago

Same issue with cs2 opening on secondary monitor. Funny thing is Albion online, opens on the correct primary monitor ( same steam launcher )

Nobara 38

limoges commented 6 months ago

Same issue. I tried -sdl_displayindex 0|1|2 with no success. I'm also running it with -fullscreen to prevent the display ping-pong flickering issue.

HappyGoFishing commented 5 months ago

This is still an issue for me. LinuxMint 21.3 Cinnamon X11 RTX 2060 proprietary drivers.

Running in a Wayland (eg KDE5) DOES fix this (well at least for me), but regardless, I'm sure this isn't intended behavior for X11.

thevinter commented 4 months ago

For me it's even worse. It launches on the primary, but as soon as I perform any changes to the video settings it snaps to the secondary (which has a smaller resolution, thus half of the window is not in frame and I can't change the settings) and then it just shuts down my primary monitor forcing me to restart.

To even be allowed to play I need to unplug my secondary monitor whenever I want to start the game

HappyGoFishing commented 4 months ago

For me it's even worse. It launches on the primary, but as soon as I perform any changes to the video settings it snaps to the secondary (which has a smaller resolution, thus half of the window is not in frame and I can't change the settings) and then it just shuts down my primary monitor forcing me to restart.

To even be allowed to play I need to unplug my secondary monitor whenever I want to start the game

OK so some revelations...

There seems to be a strange issue where only on linux (X11 more than Wayland, however sometimes both) the system ALWAYS treats the left-most monitor as the primary one, despite what is actually selected in the X11 or Wayland config. The ONLY way I've figured out how to fix this is to (I'm not joking) physically switch my monitor setup so that my primary monitor is now the most-left.

This seems MUCH bigger than just a Valve/CS2 issue, this is a desktop Linux issue that needs WAY more publicity.

Akip25 commented 3 months ago

There seems to be a strange issue where only on linux (X11 more than Wayland, however sometimes both) the system ALWAYS treats the left-most monitor as the primary one, despite what is actually selected in the X11 or Wayland config. The ONLY way I've figured out how to fix this is to (I'm not joking) physically switch my monitor setup so that my primary monitor is now the most-left.

thank you, for me it wasn't the left most but the upper most monitor that started the application regardless of screen priority

HappyGoFishing commented 3 months ago

There seems to be a strange issue where only on linux (X11 more than Wayland, however sometimes both) the system ALWAYS treats the left-most monitor as the primary one, despite what is actually selected in the X11 or Wayland config. The ONLY way I've figured out how to fix this is to (I'm not joking) physically switch my monitor setup so that my primary monitor is now the most-left.

thank you, for me it wasn't the left most but the upper most monitor that started the application regardless of screen priority

Every time i mention this issue to anyone, they just deny its existence, glad to see others admit that its a problem.

JellyWX commented 3 months ago

Anyone else confirming this fixed? Loading on primary monitor consistently for me

HappyGoFishing commented 3 months ago

Anyone else confirming this fixed? Loading on primary monitor consistently for me

this seems a fundamental flaw with X/wayland compositors/DEs or something to me, but I dont understand it enough.

JellyWX commented 3 months ago

I'm talking about the issue where CS2 launches on the wrong monitor, not the one you were discussing with others here.

Played a few games today and CS2 launched on my primary 144hz monitor, and there was no issue with it blinking between monitors when tabbing in and out.

More info: I have two monitors, a 60hz and a 144hz in the following array: image

Previously, CS2 would launch on the secondary monitor with the wrong refresh rates selected etc. as in the original report. Now, CS2 consistently launches on my primary 144hz monitor, in either fullscreen or fullscreen windowed, and in fullscreen it has the correct refresh rate selected (the expected behaviour as seen in other games e.g Insurgency: Sandstorm)

Pop_OS 22 with default DE/WM, kernel 6.8.0, Nvidia with the proprietary drivers

baecky commented 3 months ago

Also on pop_os 22.04 on nvidia, not fixed for me. The mentioned fixes don't work for me unfortunately

minionprocyk commented 2 months ago

I am on fedora 40 with a primary 240hz monitor and a secondary 60hz monitor. When I launch cs2 non-fullscreen it still swaps between the two monitors until force-killing the app. The only way I have gotten to play the game is when I disable the secondary monitor, then launch the game.

Happens with:

It's enough of a problem I've basically stopped playing the game entirely unfortunately quite a long time ago.

Arniiiii commented 1 month ago

Guys, I think it can be related to nvidia drivers.

I have notebook with intel's iGPU and nvidia 4070 and 4 monitor: 2 connected through usb-C -- hdmi adapters to iGPU ( 60 hz and 60 hz, priority 3,4), one is connected through hdmi port to iGPU (75 hz, priority 2), and my built-in screen connected to nvidia's GPU (240Hz priority 1).

When I start kde plasma this way:

dbus-launch --exit-with-session startplasma-wayland

it launches plasma on my iGPU and allows using nvidia GPU for something intensive.

And when I start CS2, it uses nvidia GPU, and it makes refresh rate 239 Hz possible (which is refresh rate for the built-in monitor)( why not 240 ? ). And it places CS2 at my primary screen, which is connected to nvidia card.

On another hand, when I start kde plasma this way:

__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_options=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia KWIN_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0 dbus-launch --exit-with-session startplasma-wayland

It launches kde's plasma and all my applications on nvidia GPU.

It gives this strange behaviour for CS2. And for me it seems that it tries to render at nvidia for secondary screen or for screen that is the most ABOVE from primary screen. That's why changing screen priority in kde settings doesn't work for me, maybe ( I checked changing priority of screen when cs2 is not launched, relaunch - fail. Maybe steam relaunch is expected?)

When I use -sdl_displayindex # it seems to just place a window on another screen, but not render for it. I think that's why even if I change -sdl_displayindex # to screen with 240Hz, it still allows only 75Hz (as on secondary monitor)

I use Gentoo btw

HappyGoFishing commented 1 month ago

On my RTX 2060 system running the nvidia 555 driver on archlinux plasma wayland, I am no longer getting this issue on CS2, however I still get it on other games, such as minecraft (only when running via native wayland).

this is a very strange issue, as I see no reason why Xwayland/Wayland apps should ever have a different primary monitor.

paulo-erichsen commented 1 month ago

this issue is still reproducing for me. Opening CS2 on Linux always opens on the wrong monitor.

days since this issue was created: 249 days or 8 months and 6 days

HappyGoFishing commented 1 month ago

this is a problem with linux not CS2

thevinter commented 1 month ago

While this might be a problem with linux it doesn't happen for any other games

HappyGoFishing commented 1 month ago

it does.

Fxzzi commented 2 weeks ago

Also experiencing this issue.

Fxzzi commented 1 week ago

Does using -sdl_displayindex # (#=0,1,2 for display index) fix this for you? We don't have this exposed in the UI but it is supported by the engine.

Hey there! This launchopt seems to affect windowed fullscreen and windowed, however fullscreen resolutions in the menu are still limited to my secondary monitor. (Main Monitor 2560x1440@170Hz, secondary monitor 1920x1080@75Hz). Is there a seperate launch option for fullscreen display index?