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 781296 - Changing monitor refresh rate does not work correctly
Changing monitor refresh rate does not work correctly
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: wayland
git master
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2017-04-13 23:04 UTC by kerryliu123
Modified: 2019-02-18 02:29 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description kerryliu123 2017-04-13 23:04:35 UTC
When changing the monitor refresh rate through the displays page in settings, only the specified refresh rate is changed, and not the monitors actual refresh rate.  For example when I change my monitors refresh rate to 48 Hz from 60 Hz, glxgears still runs at 60 fps, not 48 fps.  This problem only seems to occur on wayland, and not on xorg.
Comment 1 Jonas Ådahl 2017-06-14 08:15:10 UTC
Accidentally wrote a comment related to this on bug on another bugzilla <https://bugs.freedesktop.org/show_bug.cgi?id=101383> so copying it here where it is more relevant:

It's currently not possible to affect the refresh rate of the actual drawing. This is not by design; it's simply not implemented. Making it work involves updating MetaRendererNative to pass around refresh rates and presentation timings to ClutterStageCogl, so that it can schedule frames given the actual refresh rate of the monitor. Currently, it'll just fall back on 60 Hz, which of course is not good.

Another related issue is that if one monitor is 144 Hz, while another is 60 Hz, we'd still end up drawing at 60 Hz, as mutter still doesn't support drawing separate monitor as individual frames.

In other words, making it work with multiple monitors with different refresh rates is non-trivial, but making it (non 60 Hz refresh rates) work for just a single monitor is probably not very hard.
Comment 2 Salvatore Pellitteri 2017-10-03 10:31:31 UTC
I have 75hz monitors because I think 60hz is not enough in an interactive environment, simply do not feel smooth. For my eyes 75hz is a much more smooth experience than 60hz, 75hz is enough for me for the desktop but higher refresh rate would be great.
This is true on kde and matedesktop not true in Gnome-Shell. If I set 75hz refresh rate on the monitor by randr mutter continue run at 60hz and the experience is horrible, it's become a stutter fest.
This is why I just run plasma desktop (never used in 20year and it's great).
Not supporting refresh rate > 60hz in 2017 is a NO-GO, gnome-shell is not usable for me. This is a shame right now because the wayland support now is great.
I hope this will be addressed as soon as possible.
Comment 3 stevengruspier 2017-10-07 02:56:49 UTC
I am having the same issue. I have a 144 Hz monitor and cannot use it at its full potential under Wayland. While I am very happy with its current progress since switching to it in Fedora 24, it still has some ways to go.
Comment 4 Jan Niklas Hasse (Account disabled) 2017-10-26 20:06:54 UTC
> Currently, it'll just fall back on 60 Hz

Do you mean these lines in clutter-stage-cogl.c?

  refresh_rate = stage_cogl->refresh_rate;
  if (refresh_rate == 0.0)
    refresh_rate = 60.0;
Comment 5 Owen Taylor 2018-03-13 15:50:13 UTC
(In reply to Jan Niklas Hasse (Account disabled) from comment #4)
> > Currently, it'll just fall back on 60 Hz
> 
> Do you mean these lines in clutter-stage-cogl.c?
> 
>   refresh_rate = stage_cogl->refresh_rate;
>   if (refresh_rate == 0.0)
>     refresh_rate = 60.0;

I'm not sure exactly things are hooked up these day, so I can't say what role this plays, but overall  the goal is not simply to get the application at the same frame rate as the display, but have it locked to the actual refresh - which is clearly not working if the display is refreshing  at 75hz and the app at 60hz. So it's necessary to figure out where that's broken or not implemented - which could be anywhere along the 

 glx => xwayland => Mutter => KMS

path.
Comment 6 Jonas Ådahl 2018-04-06 10:45:44 UTC
(In reply to Owen Taylor from comment #5)
> (In reply to Jan Niklas Hasse (Account disabled) from comment #4)
> > > Currently, it'll just fall back on 60 Hz
> > 
> > Do you mean these lines in clutter-stage-cogl.c?
> > 
> >   refresh_rate = stage_cogl->refresh_rate;
> >   if (refresh_rate == 0.0)
> >     refresh_rate = 60.0;
> 
> I'm not sure exactly things are hooked up these day, so I can't say what
> role this plays, but overall  the goal is not simply to get the application
> at the same frame rate as the display, but have it locked to the actual
> refresh - which is clearly not working if the display is refreshing  at 75hz
> and the app at 60hz. So it's necessary to figure out where that's broken or
> not implemented - which could be anywhere along the 
> 
>  glx => xwayland => Mutter => KMS
> 
> path.

The situation in the native backend is that it's simply hard coded to 60. In the above code, stage_cogl->refresh_rate IIRC is always 0.0. There are two things we need to do: split up stage frame scheduling into per monitor, then use the refreh rate from the monitor when scheduling.
Comment 7 Salvatore Pellitteri 2018-04-11 13:58:24 UTC
I would like to look at the code, is there any internals guide that introduce the to the rendering stack? I would like to see gnome run at 1000hz (why not).
Comment 8 Daniel van Vugt 2018-06-29 09:40:00 UTC
Comments 4 and 6 are incorrect, but in the right function.

There are two root causes of this bug:

1. The Wayland backend is missing hardware presentation timestamps etc, which causes clutter_stage_cogl_schedule_update to return even earlier:

  if (stage_cogl->last_presentation_time == 0||
      stage_cogl->last_presentation_time < now - 150000)
    {
      stage_cogl->update_time = now;
      return;
    }

That is fixed in https://gitlab.gnome.org/GNOME/mutter/merge_requests/144

2. For Xorg (and soon Wayland) that has presentation timestamps and the correct refresh rate information, we accidentally ignore the correct refresh rate in master_clock_next_frame_delay because:

  swap_delay = master_clock_get_swap_wait_time (master_clock);
  if (swap_delay != 0)
    return swap_delay;

and when swap_delay is zero, we may end up using clutter_get_default_frame_rate (which is 60) to calculate the next update time.

So the remaining fix we need relates to master_clock_next_frame_delay, and eliminating the call to clutter_get_default_frame_rate() somehow. Without breaking it :)
Comment 9 Daniel van Vugt 2018-07-19 10:22:01 UTC
Oops. I spent too long working on other branches no realizing I had already completed the fix for this bug. Here it is:

https://gitlab.gnome.org/GNOME/mutter/merge_requests/171
Comment 10 Jason Pleau 2018-07-28 14:20:44 UTC
Hi Daniel,

I have rebuilt mutter from Ubuntu's latest .dsc package and  include your changes in the #171 merge request, and so far it seemed to have fixed the issue for me.

Both my monitors are at 144hz and the windows now seem to be running more smoothly.

Thanks
Comment 11 Daniel van Vugt 2018-08-01 04:02:23 UTC
Thanks Jason.

If you can then please comment in https://gitlab.gnome.org/GNOME/mutter/merge_requests/171

Also, the code changed yesterday if you would like to retest.
Comment 12 Daniel van Vugt 2018-08-02 03:17:31 UTC
Workaround:

1. Add a line to /etc/environment like:
     CLUTTER_DEFAULT_FPS=144
   or whatever your monitor's real refresh rate is.

2. Reboot.
Comment 13 Daniel van Vugt 2018-11-23 11:12:02 UTC
Fix landed in mutter master:
1. https://gitlab.gnome.org/GNOME/mutter/commit/e9e4b2b7
2. https://gitlab.gnome.org/GNOME/mutter/commit/e8c27603
Comment 14 Bastien Nocera 2018-11-23 11:20:30 UTC
Closing as per comment 13.
Comment 15 Marius 2019-02-15 14:14:53 UTC
Hi. how can i apply to fix the problem. I am on ubuntu 18.04.
Thank you.
Comment 16 Marius 2019-02-15 14:15:47 UTC
btw, i did try the work around with no success.
Comment 17 Daniel van Vugt 2019-02-18 02:29:41 UTC
Marius,

You are right that the fix is not yet in Ubuntu 18.04. However that should be discussed in the Ubuntu bug instead:

https://bugs.launchpad.net/bugs/1763892