Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How to build WebGL project on a Linux VM? (And why is Win CLI build so dark?)

Discussion in 'WebGL' started by TheMostGeneralUnifier, Apr 30, 2022.

  1. TheMostGeneralUnifier

    TheMostGeneralUnifier

    Joined:
    Sep 11, 2017
    Posts:
    2
    I'm trying to build a WebGL project on a Linux VM using the CLI, but it doesn't seem to be working. The project builds, but nothing shows up once it's launched. What am I doing wrong?

    To try to isolate the problem. I've created a completely fresh project with one Cube and the following script in Assets\Scripts\Editor\WebGLBuilder.cs
    Code (CSharp):
    1. using UnityEditor;
    2. namespace MyBuilder
    3. {
    4.     public class WebGLBuilder
    5.     {
    6.         [MenuItem("Build/Build MyWebGL")]
    7.         public static void build()
    8.         {
    9.             string[] scenes = { "Assets/Scenes/SampleScene.unity" };
    10.             BuildPipeline.BuildPlayer(scenes, "Build", BuildTarget.WebGL, BuildOptions.None);
    11.         }
    12.     }
    13. }
    Also, in the Player Settings, I've change Compression Format to Disabled.
    If I build it in the editor, everything is as expected and looks like this:
    build-in-editor.png

    If I delete the Library folder and build on Window CLI with the command
    Code (csharp):
    1. %UNITY% -nographics -batchmode -quit -projectPath TestProject -logfile unity-build.log -executeMethod MyBuilder.WebGLBuilder.build
    I get almost the same, but the scene is darker:
    build-cli-win.png
    It makes no difference, whether I pass '-nographics' or not, it's still dark.

    On Linux:
    Code (csharp):
    1. $UNITY -nographics -batchmode -quit -projectPath TestProject -executeMethod MyBuilder.WebGLBuilder.build -logfile
    I can't remove '-nographics' as that causes a segfault.
    The build log says 'Build Finished, Result: Success.',
    but the 'Made with Unity' splash does not appear at all and it just gives and empty view:
    build-cli-linux.png
    The browser console is full of error messages like this:
    The resource Internal-ErrorShader.shader could not be loaded from the resource file!

    I'm running Unity-2021.3.1f1 on both Linux & Windows. The Linux is Ubuntu 20.04 running on Virtual Box with VMSVGA & 3D Acceleration enabled.
     
  2. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    235
    This issue of building WebGL on Linux is known and being currently investigated by our team.
     
  3. TheMostGeneralUnifier

    TheMostGeneralUnifier

    Joined:
    Sep 11, 2017
    Posts:
    2
    Good to know the Linux issue is known. Is there a ticket in the Issue Tracker for it?

    Found the solution to the light problem. I have to click on "Generate Lighting" in the Lighting window to create a Lighting Data Asset for Baked Lightmaps. Or alternatively, create a Lighting Settings Asset by clicking on "New Lighting Settings" and then enabling "Auto Generate".

    This is a bit strange, as the scene doesn't actually have any objects that have Contribute Global Illumination flag enabled.

    Pics before on left and how it should look like on the right.
    two-boxes.png boxes-in-editor.png
     
    Last edited: Apr 30, 2022
  4. RedBeardMan

    RedBeardMan

    Joined:
    Jun 13, 2022
    Posts:
    4
    @unityruba any update on this problem with WebGL on Linux? I also have the same problem trying to setup an automated pipeline with ubuntu and webGL build. Using 2021.3.15f1
     
  5. RedBeardMan

    RedBeardMan

    Joined:
    Jun 13, 2022
    Posts:
    4
    Solved the problem on my end. My ubuntu worker did not had Git LFS installed. Just need to have it proper set. False alarm.
     
  6. strKllr

    strKllr

    Joined:
    Dec 3, 2018
    Posts:
    1
    Is there any info about that?
    I might have a related issue and would like to, at least, have a tracker reference
     
  7. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    235