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

Stutter on Linux X11 when using multiple monitors #62821

Closed
poiati opened this issue Jul 7, 2022 · 7 comments · Fixed by #48364
Closed

Stutter on Linux X11 when using multiple monitors #62821

poiati opened this issue Jul 7, 2022 · 7 comments · Fixed by #48364

Comments

@poiati
Copy link
Contributor

poiati commented Jul 7, 2022

Godot version

4.0-alpha11

System information

Linux 5.18.9-arch1-1, NVIDIA driver version 515.57, RTX 2070 Super

Issue description

I have a 3 monitors setup where two are 240hz and one is 60hz. When I run my project with vsync enabled I see a consistent stutter every 120 frames.

image

I don't know if this is related but my primary monitor is a 240hz, when I launch my scene, Godot reads my refresh rate as 60hz. It seems that's happening because it thinks my 60hz monitor is the primary one.

image

image

If I disable vsync, the problem goes away.

xrandr info:

DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 connected 1080x1920+4480+0 right (normal left inverted right x axis y axis) 800mm x 340mm
   1920x1080     60.00 +  59.94*   50.00    29.97
   1680x1050     59.95
   1600x900      60.00
   1280x1024     75.02    60.02
   1280x720      60.00    59.94    50.00
   1152x864      75.00
   1024x768      75.03    60.00
   800x600       75.00    60.32
   720x576       50.00
   720x480       59.94
   640x480       75.00    59.94    59.93
HDMI-0 connected (normal left inverted right x axis y axis)
   3840x2160     60.00 +  59.94    50.00    29.97    25.00    23.98
   4096x2160     59.94    50.00    29.97    25.00    24.00    23.98
   2560x1440    120.00
   1920x1080    119.88   100.00    60.00    59.94    50.00    29.97    25.00    23.98
   1280x1024     60.02
   1280x720      59.94    50.00
   1152x864      60.00
   1024x768      60.00
   800x600       60.32
   720x576       50.00
   720x480       59.94
   640x480       59.95    59.94    59.93
DP-2 connected 1920x1080+0+551 (normal left inverted right x axis y axis) 544mm x 303mm
   1920x1080     60.00 + 239.76*  143.98   119.98    59.94    50.00
   1600x900      60.00
   1280x1024     75.02    60.02
   1280x720      59.94    50.00
   1152x864      75.00
   1024x768      75.03    60.00
   800x600       75.00    60.32
   720x576       50.00
   720x480       59.94
   640x480       75.00    59.94    59.93
DP-3 disconnected (normal left inverted right x axis y axis)
DP-4 connected primary 2560x1440+1920+371 (normal left inverted right x axis y axis) 1mm x 1mm
   2560x1440    144.00 + 239.96*  120.00    59.95
   1920x1080    239.76   143.98   119.88    60.00    59.94    50.00
   1680x1050     59.95
   1600x900      60.00
   1440x900      59.89
   1280x1024     75.02    60.02
   1280x800      59.81
   1280x720      60.00    59.94    50.00
   1152x864      75.00
   1024x768      75.03    70.07    60.00
   800x600       75.00    72.19    60.32    56.25
   720x576       50.00
   720x480       59.94
   640x480       75.00    72.81    59.94

Steps to reproduce

Not sure how to properly reproduce this but I can help with fixing the issue if you give some ideas about what might be happening.

Minimal reproduction project

No response

@Calinou
Copy link
Member

Calinou commented Jul 7, 2022

The incorrect primary monitor detection is likely related to the issue where Godot spawns its first window on the wrong monitor on Linux.

@poiati
Copy link
Contributor Author

poiati commented Jul 7, 2022

The incorrect primary monitor detection is likely related to the issue where Godot spawns its first window on the wrong monitor on Linux.

Would this explain the stutter? I mean, if we fix the monitor issue, do you think the stutter would go away?

@Calinou
Copy link
Member

Calinou commented Jul 7, 2022

Would this explain the stutter? I mean, if we fix the monitor issue, do you think the stutter would go away?

I can't guarantee the issue will be fixed if primary monitor detection is fixed. The stutter may be due to how Godot uses X11 functions (it doesn't use SDL).

In the meantime, this would be a good opportunity to finish #48364 and godotengine/godot-proposals#1923. In general, V-Sync on monitors with different refresh rate is a difficult proposition. Compositors will often lower their update rate to match the slowest monitor, making for a poor user experience. It's like using monitors with different DPI on X11 – it's one of the biggest reasons Wayland is being pushed these days.

@poiati
Copy link
Contributor Author

poiati commented Jul 7, 2022

What we are missing to finish #48364?

@Calinou
Copy link
Member

Calinou commented Jul 7, 2022

What we are missing to finish #48364?

It needs to be rebased and reviewed 🙂

@poiati
Copy link
Contributor Author

poiati commented Jul 12, 2022

This indeed seems to be more like an X11 / Vulkan issue as you suggested. I just noticed the exact same behavior on vkcube. It gets the lowest display refresh rate and has the same stutter. Setting the present mode to VK_PRESENT_MODE_IMMEDIATE_KHR instead of FIFO solves the issue.

@Cyangmou
Copy link

I can confirm that this monitor issue is also happening on non Linux setups with different Hertz hardware. I tested it with a 60hz, 100hz adaptive monitor and experienced the same issues when V-Sync was switched on.
I posted my tests and findings in this thread:
Issue #81727

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

Successfully merging a pull request may close this issue.

4 participants