Search Unity

Question Anyone know the difference between "Build and Run" and execute manually on Linux?

Discussion in 'Linux' started by MrMelSE, Nov 6, 2022.

  1. MrMelSE

    MrMelSE

    Joined:
    Dec 10, 2017
    Posts:
    25
    Hi,

    I have encountered this bug;
    https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-3645

    I'm in a dire need for a fix for this, but it does not seem to be priority.
    Since it works when you Build and Run I figure it might be a workaround somewhere.

    What's the difference between Build and Run and execute the program from terminal?
    Figuring that out might allow me to build a starter program or something to get a working solution.
     
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    602
    The bugs you report on unity bugtracker are private. I can't see the thing you linked. Please describe what problem are you actually talking about. What differences between "build and run" and manually executing are you observing? Does not launch at all, does it later crash, are there visual artifacts?


    The simplest differences between "build and run" and manually executing that might happen are differences in environment variables and working directory.

    You can find out a lot of information about execution process of specific process by inspecting proc filesystem. Ideally you should compare the results from running your game with "build and run" to results of manually running. But if it instantly crashes when run manually (you didn't really explain what differences are you observing), your can compare the result from starting with "Build and run" against running a simple gui program like calculator or gedit. Don't compare results against more complex like web browser, ide or anything electron based, as those might be doing a lot of fancy stuff which will only confuse and isn't representative of what your game does.

    1) find out the PID of process you want to investigate. You can do that using process monitoring tool of your choice. If you are using Ubuntu or other distro with gnome based desktop it should have it called "System Monitor" or "Gnome System Monitor". If you are using KDE or other desktop environment it might have a tool with different name. Of course there are also plenty of commandline tools for inspecting process list.

    2) Open "/proc/<PID>" folder from terminal or file browser. Where "<PID>" is the process id you identified in previous step. It should contain mostly read only text files describing the state of process. Some of the items like cwd, exe and the ones inside fd folder are symlinks. Note that some of the items describe current state not the initial state so thing might be 100% accurate for your usecase, but it's still a good starting point. It should look something like this:
    upload_2022-11-7_12-8-0.png

    I recommend starting your investigation with following:
    *) environ -> environment variables
    *) cwd -> symlink to current working directory, when manually starting from terminal should be same as current shell directory before starting the game, who know what Unity editor uses. If this is the problem I recommend fixing your code by correctly handling relative paths instead of creating a launcher script.
    *) exe -> symlink to the executable file, shouldn't be any surprises here. But just in case you can confirm that you are trying to run the correct file.
    *) cmdline -> commandline arguments passed to executable. I doubt unity passes anything extra by default, but it doesn't hurt verifying that.

    Don't forget about using diff tools to help spotting any differences.

    If there is nothing obvious in those start going through the rest of them. You might even try to run a graphical directory comparison tool on the whole directories, although I don't promise that it will work reliably. Directory comparison tool might get confused because those are not normal filesystem files. In my case it almost worked but acted somewhat laggy and often incorrectly detected text encoding (probably because some of those text files contain 0 bytes).
     
    Last edited: Nov 7, 2022
    MrMelSE likes this.
  3. MrMelSE

    MrMelSE

    Joined:
    Dec 10, 2017
    Posts:
    25
    Thank you, I will surely check your pointers.

    It's linked to how unity opens windows and what framerates.
    I use 2 x high fps monitors/projectors, 120fps each.

    Running my executable manually and engaging second monitor it caps the FPS to half of what it should (120fps becomes 60)

    But if use the editor, and Build and Run for the same program both monitors gets 120fps.
    They have confirmed it to be a bug.

    I am thinking it's because the editor is already open and it opens perhaps from an "owner" window? That's the only thing I could think of...
     
  4. MrMelSE

    MrMelSE

    Joined:
    Dec 10, 2017
    Posts:
    25
    Thank you!! You solved it.

    Environment variable __GL_SYNC_TO_VBLANK was set to zero by the editor