Programming and Technology

By Robert Roos

I recently stumbled upon a problem with Vulkan on one of my laptops running a NVIDIA Optimus setup, that is two graphics cards running on the same computer where you depending on the workload switch between the integrated one (Intel) and the dedicated one (NVIDIA).

The problem was that after upgrading Ubuntu to the latest kernel (5.3.7 at the time of writing) and the NVIDIA drivers (440 at the time of writing) all Vulkan based games stopped working.

This is quite the problem, since for example Steam Play (Proton) uses Vulkan for most games. Running vulkaninfo in the terminal showed that Vulkan could not be initialized, even though all the files and dependencies were in order.

After some extensive searching i found a very easy fix that seems to solve the problem, although it seems it needs to be done after each time you have switched between the Intel and NVIDIA card through the NVIDIA X Server software.

Simply run sudo vulkaninfo in a terminal instance and the problem is solved. This points to the problem being a rights one, I have not been able to figure out the source of it. But the above workaround at least works for now.

Screen tearing on some systems has been a common problem for users with Ubuntu based distros and running NVIDIA cards, I've never experienced it on any of my laptops (even though NVIDIA Optimus is another problem...), but I seem to be getting it quite frequently on stationary computers, especially with high-res screens.

No need to worry though, the solution is quite simple and as far as I can tell after some testing in games - the response times are next to not affected at all by the fix.

  1. Open the NVIDIA X server settings control panel
  2. Go to X Server Display Configuration
  3. At the bottom, click on the Advanced button
  4. Enable Force Full Composition Pipeline

Screenshot from 2019-10-19 13-45-28.png

Optionally to have the settings stored, save to X Configuration File.

And that should do it, after enabling this the screen tearing i had (very occasionally) in Ubuntu and in (very often) games disappeared. To explain what the 'Force Full Composition Pipeline' does, here is a quote for the NVIDIA forums:

The difference is scaling between ViewPortIn and ViewPortOut. If the display hardware can do the scaling, then the driver will use it even if ForceCompositionPipeline is enabled. However, ForceFullCompositionPipeline will disable the display scaling and use the GPU's shaders to do the scaling instead.

There's no difference if there's no scaling.

There will be somewhat of an impact to power draw and performance, but it's hard to quantify and depends heavily on your scaling configuration.

https://devtalk.nvidia.com/default/topic/1003420/linux/can-someone-really-explain-the-difference-between-force-full-composition-pipeline-and-force-composition-pipeline-/post/5124915/#5124915

Good luck and hope it solves any screen tearing issues you may have!

I use Github for almost every programming project, both for work and personal projects. It's a great tool for version management and collaboration, there are of course other Git-based services such as Bitbucket. But Github has always been my favorite, now with unlimited private repositories even if you are a non-paying customer it has become even better.

To work with Github you don't really need a GUI, and more often than not if you are using a IDE such as Visual Studio or JetBrains Rider you will already have a built-in command-line/GUI hybrid tool built in.

With that said, I find that working with a dedicated GUI for Github at times just makes things a bit faster and easier, therefore I've been a user of Github Desktop for a very long time. It should be added that my main dev-setup has been Windows + Visual Studio for the longer part, but nowadays I've moved on to Linux and JetBrains Rider instead.

The good news is that Github Desktop is available on Linux as well for various distros, through this project: https://github.com/shiftkey/desktop

Go with the install instructions for your distro, if you are on a Ubuntu based distro the snap image is probably the easiest way to get started, just open up snap store and search for Github Desktop and install.

However

I've tested the (at the time of writing) latest release 2.1.0 on several Ubuntu-based distros and it's just not working. After installation through the snap store the following error is thrown:

user@user:~$ env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/github-desktop_github-desktop.desktop /snap/bin/github-desktop
/snap/github-desktop/63/app/github-desktop: symbol lookup error: /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0: undefined symbol: g_date_copy

This seems to be a bug that the developers are aware of and should be fixed in the future, until we are in the future the easiest solution for this is to head on over to: https://github.com/shiftkey/desktop/releases/tag/release-2.0.4-linux1 and download the 2.0.4 version (select the .snap package and download).

After downloading run the following in terminal:

snap remove github-desktop
snap install ~/Downloads/GitHubDesktop-linux-2.0.4-linux1.snap --classic --dangerous

Just change the path to where the downloaded file is located on your system.

This installs the 2.0.4 version of Github Desktop that runs without any issues. You can now login to Github through the GUI and start hacking away!

 

I run Ubuntu on my laptop and Elementary OS on my stationary computer as my daily driver. Linux overall has come a very long way in the last couple of years, much due to the explosion in open-source applications available. But also due to companies working harder to make their programs and games run on Linux (Steam, Lutris and JetBrains Rider the real MVP).

We are getting closer to linux going mainstream I think, especially with user friendly distros such as Ubuntu, Elementary OS, Fedora and of course Manjaro.

But there are still quite a few things to work out - I think the lack of GUI:s for a lot of "under the hood" settings still scares off a lot of users. For example, I realized yesterday when running an older single-threaded game through Lutris that I had bad performance (AMD Ryzen CPU). I checked the CPU frequency and found out that the governor for the CPU was set to "ondemand", which is good for most standard work/multi-threaded games. But in this case forcing the CPU to work at a higher frequency was the only solution to get an acceptable framerate. This however needed some scary terminal tinkering... well not that scary at all to be honest, let me show you.

Start off by opening a fresh instance of the terminal and run:

sudo apt-get install cpufrequtils

This installs the cpu freq tools we will be using to set the governor to performance mode. But before we do that, run the following command in the terminal:

cpufreq-info

This should render information about your CPU, look for the governor settings line and make sure it's not already set to "performance". Usually Ubuntu and other Debian distros sets the governor to "ondemand", so that is what you should be seeing here.

Next off, open another terminal instance (keep your previous open) and run the following command:

watch -n1 "lscpu | grep MHz | awk '{print $1}'";

This will render your current CPU min, max and current frequency. If you want you can try running a game or larger video to see it go up and down, but overall trying to stay closer to the minimum frequency than the maximum. This is due to the governor beeing set to "ondemand", which is trying to save power and generate less heat.

Let's crank up the performance. Run the following in your first terminal instance:

sudo bash -c 'for i in {0..11}; do cpufreq-set -c $i -g performance; done'

NOTICE! Make sure you set the number 11 to the amount of cores your CPU has minus one (since the count starts at 0). In my case I run a 12 core Ryzen CPU, therefore I need to set it to 11. If you have an 8 core CPU, you set it to 7 and so on. Then hit enter to run the script.

Now run:

cpufreq-info

And look for the governor once again, your should now see it set to "performance" instead of "ondemand".

Open up the second terminal instance again and you should now see your overall cpu frequency staying at a higher number, closer to maximum than minimum. Try running a game or large video again and see the difference (and feel the difference with higher FPS in games).

To return the governor to "ondemand" simply run:

sudo bash -c 'for i in {0..11}; do cpufreq-set -c $i -g ondemand; done'

And that's it!

Now there are a lot of ways to work with this, for example the one I've just shown. Another is to add this script to your ".bashrc" for easier execution in the future. You could also add it to the startup scripts for your distro to have it set the CPU to performance mode permanently. I won't go into this since I think switching manually is better and ondemand is what you probably should be running most of the time when not doing heavy work, it saves some power and that is always good.

I will however show how you can make the execution of the script easier through ".bashrc".

Open a terminal instance and run:

sudo nano ~root/.bashrc

This will open a editor, on a new line paste the following (again change 11 to the number of cores you have minus one)

function setgov ()
{
     for i in {0..11}; 
     do 
         cpufreq-set -c $i -g $1; 
     done
}

Press CTRL+X and you will be asked if you want to save the changes, save the changes and the editor will close.

You can now change your CPU governor by running the following in a terminal instance:

sudo bash
sudo setgov performance

And to set it back to ondemand:

sudo bash
sudo setgov ondemand

That's it, you now have a very simple way to crank up the performance when gaming or whatever else needs that extra kick. Good luck!

I recently started work on a small project in need of authentication and handling of users. The Identity provider https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-3.0&tabs=visual-studio is a good foundation for this and is highly customizable for most small project needs. Larger ones as well, but in combination with Identity Server.

With the release of .NET Core 2.2 there were some major changes done to Identity and how it's added to a project. Moving on from installing a NuGet (or using the default template in Visual Studio) with controllers and views set up in a MVC pattern, to Razor Pages/Razor Class Library instead.

This has it's pros and cons, personally I prefer the old MVC way. Razor Pages while quite nifty to work with in smaller projects, give me horrendous flashbacks to the old Web Forms way of doing things with a view and a code-behind file. And that is after scaffolding the library, that otherwise "just works" but hides the views and source code: https://docs.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-3.0&tabs=visual-studio#scaffold-identity-into-a-razor-project-with-authorization

By chance though i stumbled upon a project on Github I feel deserves some more recognition: https://github.com/TanvirArjel/AspNetCoreMvcIdentity

What this project offers is the old MVC way of Identity, where things are separated into views and controllers like before. So instead of doing the work yourself of moving everything into place, you can just use this instead, don't be like me and start the manual process BEFORE doing a search.

As of writing this the project seems to be well maintained and the author has just updated everything to work with the newly released .NET Core 3.0.

Hi!

Wow, it's been a while. Way back (in relative internet terms) there used to be a semi-active blog here. But it kind of due to work and life in general went inactive for several years. Also since it was so general in theme, it felt like it never was a good fit for writing about programming, technology and my since a couple of years back strong interest in privacy and data ownership.

So my hope is, moving on from this small introductory post, focus on this type of content. Since I'm mostly a full-stack developer working with Microsoft technologies, programming articles will focus on C# and ASP.NET Core mixed with VueJS and other goodies.

Welcome and hope you find something of interest while browsing through here!