Help with Minecraft flickering, and general advice

Hello. I’m fairly new to NixOS, and I’m trying to set up ATLauncher to run Minecraft. I’ve been able to get it working for the most part, and my instance runs with good performance now. Unfortunately, it has terrible flickering. Multiple times a second the screen will go all white or all black. The problem is worse when I make the window larger, but it happens even on small windows. It also happens in full screen mode.

I’m on nixos-unstable, via a flake, though I was also having the same problem on 23.11. I’m running ATLauncher with steam-run atlauncher (I’d eventually like to make my module do that automatically). This is the module I used to install ATLauncher:

{pkgs, home-manager, config, system,  ...}: {
  home-manager.users.${config.main-user.userName} = {pkgs, ...}: {
    home = {
      packages = with pkgs; [
        atlauncher
      ];
    };
  };
}

I have an Nvidia RTX 4080. This is my nvidia.nix module:

{pkgs, config, ...}: {
  hardware.opengl = {
    enable = true;
    driSupport = true;
  };

  services.xserver.videoDrivers = ["nvidia"];

  hardware.nvidia = {
    modesetting.enable = true;
    powerManagement = {
      enable = false;
      finegrained = false;
    };
    open = false;
    nvidiaSettings = true; # accessible via `nvidia-settings`.
    package = config.boot.kernelPackages.nvidiaPackages.stable;
  };

  environment.systemPackages = with pkgs; [glxinfo mesa-demos nvtop];
}

I’ve seen that Nvidia fixed a flickering bug in August (thread), so I’ve made sure to be on the latest stable driver.

You can see the rest of my configuration here: GitHub - mythmon/nixos-configs at minecraft

Other games work without flickering. Specifically Helldivers 2 and Mindustry, both through steam. (I think they are both using the Proton compatibility layer though, now that I think about it).

I’d also be interested in any general feedback about the way I’ve organize that repo, if anyone has comments.

I’ve made a short video of my problem. Watch Minecraft flicker problem (warning, intense flicker!) | Streamable

I have the same issues on nvidia under wayland/wlroots. I’m 70% sure it comes down to the nvidia driver issues that are rumored to be close to resolving (we might see explicit sync land in the next ~6 months maybe perhaps?).

In the mean time, patching out glFlush and using Minecraft in fullscreen at least mostly resolved the issue for me.

Do you use a high refresh rate monitor? Variable refresh rate?

I don’t think my monitor supports variable refresh rate, and it only goes up to 75hz anyways. Is there a way I can check if the GPU is trying to do VRR anyways?

Thanks for the tip about glFlush, I’ll check that out.

Edit: oh, I see that was glFlush patch was to wlroots. I don’t think that’s applicable for Gnome. Maybe it’s time to try something new

Under sway you can use:

$ swaymsg -t get_outputs
Output DP-2 'Dell Inc. DELL G2723HN 5B0C3H3' (focused)
  Current mode: 1920x1080 @ 164.997 Hz
  Position: 0,0
  Scale factor: 1.000000
  Scale filter: nearest
  Subpixel hinting: unknown
  Transform: normal
  Workspace: 2
  Max render time: 3 ms
  Adaptive sync: enabled
  Available modes:
    1920x1080 @ 60.000 Hz
    <snip>

It’d be listed as Adaptive sync: enabled. If it doesn’t support gsync or anything it almost certainly won’t, though. I was mainly curious because I thought that was part of the issue in my case, with no way to verify.

Have you tried running at 60 Hz?

Ah, you’re under gnome, didn’t recognize it with the non-rounded corners. No idea then, that should not at all be relevant to gnome, though the explicit sync issue is present for all wayland compositors.

In case anyone is curious, I ended up switching to X11 instead of Wayland, and all my flickering problems went away. :man_shrugging:

1 Like

Hey, you said that part of your issue was with adaptive sync not being enabled. I have a monitor that has adaptive sync capabilities, but hyprctl monitors returns Adaptive sync: disabled. I tried to force it on with no luck. Could you elaborate on your problem?

In my case, adaptive sync being enabled caused issues, rather than the other way around. This is several nvidia driver releases ago, adaptive sync actually works for most things these days.

To get adaptive sync to work I had to explicitly enable it in the monitor settings, too. For whatever reason the enable switch is marked as AMD Freesync, too, which is confusing - gsync is definitely in use according to nvidia-settings.

That said, I’ve not experimented with minecraft in a little while, not had much time to play anything at all. Even if it’s still broken, with some luck the next NixOS release should resolve the problems, if I’m not mistaken explicit sync finally merged.

I’m on 23.11, would specifying something for hardware.nvidia.package from the unstable branch be able to fix anything for me? i’ve tried searching the unstable branch for nvidia kernel packages, but i’m getting a little lost by all of the different parts working together here.

Maybe, see this similar post: Nvidia drivers update? - #3 by TLATER

9 minute reply with relevant, detailed information - you’re amazing, thank you. unfortunately, trying that did work to update the drivers but did not fix the issue; I will keep searching for possible solutions.

thx again <3

1 Like

Yeah, unfortunately it’s mostly expected to not work yet. Explicit sync just very recently merged in the nvidia drivers - apparently the beta release is only supposed to be released a few weeks from now.

That thread is a treasure trove of other information regarding similar issues, if you follow it around a bit you’ll note that just the nvidia driver supporting explicit sync will likely not be enough to solve the issue; various wayland-related upstreams need to update too.

I think chances are good that some of this makes it into NixOS 24.05, afaik most of these branches have in fact been merged and should end up in package updates very soon, but just switching to unstable isn’t good enough yet.

Of course, there’s also a good chance the issue persists even with explicit sync finally working, but my bet is that it’s related to this - most of the flickering supposedly is.

Hello,

I’ve been having a very similar flickering problem (albeit much worse in Minecraft)
In my case, I managed to temporarily “solve” it by disabling the “FreeSync Premium” feature on my monitor. It’s only accessible by using the buttons on the monitors.

1 Like

I tested the recently released 555.42.02 driver. While in theory the explicit sync changes haven’t landed elsewhere in the stack yet (well, on NixOS stable, on unstable it should all be working), so this should not be fixing this, it still fixed flickering in minecraft for me. Guess there is more to it.

Here’s my overall nvidia config for anyone interested in reproducing: dotfiles/nixos-config/hosts/yui/nvidia/default.nix at f989a86890f27f6b089e9d74b7e8356ec8e5683d · TLATER/dotfiles · GitHub

Edit: hmmm, sway is still off a few merges even on NixOS unstable: Draft: linux-drm-syncobj-v1: new protocol (!4262) · Merge requests · wlroots / wlroots · GitLab

1 Like