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

[Linux] GLSL ES 3.20 is not supported #10405

Open
FlPeo opened this issue Nov 11, 2022 · 2 comments
Open

[Linux] GLSL ES 3.20 is not supported #10405

FlPeo opened this issue Nov 11, 2022 · 2 comments
Labels
area/skia ✏️ Categorizes an issue or PR as relevant to Skia difficulty/challenging 🤯 Categorizes an issue for which the difficulty level is reachable with internals understanding kind/bug Something isn't working platform/gtk Categorizes an issue or PR as relevant to GTK platform/linux 🐧 Categorizes an issue or PR as relevant to Linux platforms project/core-tools 🛠️ Categorizes an issue or PR as relevant to core and tools

Comments

@FlPeo
Copy link

FlPeo commented Nov 11, 2022

Current behavior

The command "dotnet run" on the Gtk project is displaying a blank window. This message is displayed in the console:

Shader compilation error
------------------------
   1	#version 320 es
   2	
   3	precision mediump float;
   4	precision mediump sampler2D;
   5	out mediump vec4 sk_FragColor;
   6	uniform sampler2D uTextureSampler_0_Stage0;
   7	in highp vec2 vTextureCoords_Stage0;
   8	flat in highp float vTexIndex_Stage0;
   9	in mediump vec4 vinColor_Stage0;
  10	void main() {
  11	    mediump vec4 outputColor_Stage0;
  12	    mediump vec4 outputCoverage_Stage0;
  13	    {
  14	        outputColor_Stage0 = vinColor_Stage0;
  15	        mediump vec4 texColor;
  16	        {
  17	            texColor = texture(uTextureSampler_0_Stage0, vTextureCoords_Stage0).xxxx;
  18	        }
  19	        outputCoverage_Stage0 = texColor;
  20	    }
  21	    {
  22	        sk_FragColor = outputColor_Stage0 * outputCoverage_Stage0;
  23	    }
  24	}
  25	
Errors:
0:1(10): error: GLSL ES 3.20 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.40, 1.50, 3.30, 1.00 ES, and 3.00 ES

I have the same problem with a release executable (generated with "dotnet publish -c release").

Expected behavior

The command "dotnet run" on the Gtk project should be displaying a window containing this text: "Hello, world!", without a GLSL error in the console.

How to reproduce it (as minimally and precisely as possible)

I generated a new project Uno project on Ubuntu 18.04.6 inside a VM. The WM was launched from a Windows machine. The Ubuntu iso I used to create the VM is "ubuntu-18.04.6-desktop-amd64.iso".

I don't have a real Linux machine, I don't know if the bug is due to the VM environment or not. But I verified that the Gtk project is working on Windows.

To create a reproduction project, you will just have to use the command "dotnet new unoapp -o TestUnoApp"

Workaround

It is possible to call "dotnet run" with an environment variable to force the OpenGL version that should be used.

for instance:
MESA_GL_VERSION_OVERRIDE="3.00 ES" dotnet run

Works on UWP/WinUI

No response

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia, Uno.UI.RemoteControl / Uno.WinUI.RemoteControl

NuGet package version(s)

4.6.19
SkiaSharp: 2.88.3

Affected platforms

Skia (GTK on Linux/macOS/Windows)

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

@FlPeo FlPeo added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Nov 11, 2022
@jeromelaban
Copy link
Member

At this time, running under Virtual Machines is generally spotty, because hardware acceleration is not well supported (it's often running in software mode). Running a more recent version of Ubuntu may help, but you can also change the render surface type to software.

@jeromelaban jeromelaban added platform/linux 🐧 Categorizes an issue or PR as relevant to Linux platforms area/skia ✏️ Categorizes an issue or PR as relevant to Skia project/core-tools 🛠️ Categorizes an issue or PR as relevant to core and tools platform/gtk Categorizes an issue or PR as relevant to GTK and removed triage/untriaged Indicates an issue requires triaging or verification labels Nov 15, 2022
@FlPeo
Copy link
Author

FlPeo commented Nov 20, 2022

Thank you for the information.

I am currently using this code in Program.cs to handle the case:

using GLib;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Uno.UI.Runtime.Skia;
using Process = System.Diagnostics.Process;

namespace xxxxxxx
{
    internal class Program
    {
        static void Main(string[] args)
        {
            ExceptionManager.UnhandledException += delegate (UnhandledExceptionArgs expArgs)
            {
                Console.WriteLine("GLIB UNHANDLED EXCEPTION" + expArgs.ExceptionObject.ToString());
                expArgs.ExitApplication = true;
            };

            var host = new GtkHost(() => new App());

            if (IsRunningInLinuxOrBsdVm())
            {
                host.RenderSurfaceType = RenderSurfaceType.Software;
            }

            host.Run();
        }

        static bool IsRunningInLinuxOrBsdVm()
        {
            bool isRunningOnLinuxOrBsd = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD);

            if (!isRunningOnLinuxOrBsd) return false;

            try
            {
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.FileName = "systemd-detect-virt";
                psi.Arguments = "-v";
                psi.UseShellExecute = false;
                psi.RedirectStandardOutput = true;
                psi.RedirectStandardError = true;

                Process proc = new Process
                {
                    StartInfo = psi
                };
                proc.Start();

                string error = proc.StandardError.ReadToEnd();

                // It was not possible to be sure that the program is running in VM because of an error
                if (!string.IsNullOrEmpty(error))
                    return false;

                string output = proc.StandardOutput.ReadToEnd();
                proc.WaitForExit();

                return !string.IsNullOrEmpty(output) && !"none".Equals(output.Trim().ToLower());
            }
            catch
            {
                // It was not possible to be sure that the program is running in VM because of an error
                return false;
            }
        }
    }
}

It may be handled more precisely, for example by checking the version of the Linux distribution (in case some ones are supporting some ones are supporting hardware acceleration in VM) or by checking the VM software returned by systemd-detect-virt (if hardware acceleration is supported by some VM softwares).

It may be interesting to check this case (with the above code or another) when you are setting "OpenGLESRenderSurface.IsSupported" and "OpenGLRenderSurface.IsSupported" (it seems that it is used internally to set RenderSurfaceType). Currently, developpers that are discovering Uno (like me) may be a bit confused if they have a Windows desktop and are trying the Linux target inside a VM (maybe this could discourage them from using Uno).

@MartinZikmund MartinZikmund added difficulty/challenging 🤯 Categorizes an issue for which the difficulty level is reachable with internals understanding and removed difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/skia ✏️ Categorizes an issue or PR as relevant to Skia difficulty/challenging 🤯 Categorizes an issue for which the difficulty level is reachable with internals understanding kind/bug Something isn't working platform/gtk Categorizes an issue or PR as relevant to GTK platform/linux 🐧 Categorizes an issue or PR as relevant to Linux platforms project/core-tools 🛠️ Categorizes an issue or PR as relevant to core and tools
Projects
None yet
Development

No branches or pull requests

3 participants