native display initialize issue

Hi Guys,

I am trying to run an executable using node.js. I run a script from the nodeserver hosted on my TX2. When I initiate the nodeserver manually through terminal and try to invoke the executable everything works fine. However, when I try to invoke the executable at boot time by initiating the nodeserver, the program exits at the following code :

Window &window = Window::getInstance();
PROPAGATE_ERROR(g_display.initialize(window.getEGLNativeDisplay()));

Upon googling I found that the issue might be due to “xserver start”. Could you guys please let me know how to solve this problem ?

Thanks.

I haven’t worked with nodejs, YMMV.

On the other hand, if it is EGL, then it needs a display for its context. When you log in locally at a GUI and run the command, does it work then? And then you log in remotely and it does not work? If so, then it is just because you have not given a valid “$DISPLAY” environment variable to tell it which display to bind to.

If you are in a non-GUI console login directly on the Jetson, and if you are using the same user name for both the console and the GUI login, then this would work:

export DISPLAY=:0
...run your command...

If you are using a remote PC to run a command on the Jetson, then it gets a lot more complicated. The simplest case is if you have a user logged in to the GUI of the Jetson, and the ssh login is via the same user name. Then this once more works:

export DISPLAY=:0
...run your command...

If you are not logged in with the same user name, or if there is no GUI logged in on the Jetson, then it gets a lot more complicated. Be aware that the DISPLAY environment variable says where X protocol traffic goes. This is where the GPU does the work, but the basic program might do its work somewhere else. You can tell a remote system to use your local system and automatically deal with DISPLAY via either of these when using ssh to log in to the Jetson (example using user “ubuntu”):

ssh -Y ubuntu@<the jetson>
ssh -X ubuntu@<the jetson>

The trouble here is that the GPU code will be asked to execute on your PC and not the Jetson! If you happen to have a Titan Xp or Tesla I’m sure you’ll be impressed by the extraordinary speed of the Jetson! Only it won’t be the Jetson’s GPU. Or if the PC doesn’t have an NVIDIA GPU of the same architecture and for the version of CUDA, the command will fail. To do remote use of the Jetson (including its GPU) you’d need a virtual X server running on the Jetson.

So how are you logging in to the Jetson?

Please try with linuxdev’s suggestion. Thanks!

Hi Guys,

Thanks for your response. I tried the suggestion by linuxdev but still could not make it work. Let me describe my situation a little bit more. I have a script file which runs an executable. This script file is triggered via nodeserver. I have the following two cases:

Case 1:

When I open a terminal and run nodeserver and send request to trigger script file via nodeserver from other machine, everything works fine - the display comes on the screen and the frames get rendered.

Steps:

  1. Open a new terminal
  2. Execute the command “sudo node <node.js_filename>”
  3. Send request to nodeserver from other machine
  4. Run script file with following contents
<executable_path>
  1. Display initiated and frames rendered. Code works fine.

Case 2:

When I try to run nodeserver during boot time by invoking the nodeserver command as in Case 1 in rc.local file and repeat the process of sending request from other machine, the code exits at the specified line where egl display gets initialized.

Steps:

  1. Run script file with command “sudo node <node.js_filename>” by including in /etc/rc.local
  2. Send request to nodeserver from other machine
  3. Run script file with following contents:
<executable_path>
  1. Display not initiated and frames not rendered. Code returns at the egl display initialization step.

Attempts:

I tried including the statement “export DISPLAY=:0” at the following locations:

  1. Before invoking nodeserver in rc.local
  2. Before running the executable

In cases #1 and #2 I checked the value of $DISPLAY within my code using system command and it seems to reflect value “:0”

  1. In main function of my code at the very start.

All 3 attempts above failed and the program still returns at the following line:

PROPAGATE_ERROR(g_display.initialize(window.getEGLNativeDisplay()));
  1. I included “export DISPLAY=:0” in ~/.bashrc

The code does not reflect this change in the environment variable when run.

Please help me out.
Thanks

Hi Guys,

I tried running “argus_multisensor” example and still face the same issue.

Thanks.

What user is your script running as? You will need that user to be logged in to the GUI when the script runs, and this will bind that GUI to the GPU use.

If the user is not “ubuntu” or “nvidia”, then you’ll need to be sure your user is a member of group “video” (see “grep video /etc/group”…root is already a member even when not listed).

Once the same user is logged in to the local GUI of the Jetson the script can be preceeded by the “DISPLAY=:0” and this will bind to the correct GPU.

FYI, one of the big problems of using a script which is part of boot is that most of the time the GUI won’t be up yet, and if it is, it won’t have the right user logged in yet. If the user is “root”, then you probably need to prefix the script command with "sudo -u <whoever_it_is_that_isnt_root> " to get it to run as that user.

If you don’t want to log in a user to a real GUI, then you need to install a virtual desktop (the command won’t care if you are bound to the framebuffer of a GPU connected to a real monitor or simply to a buffer with no real monitor).

The fact that you are running the script with “sudo” implies it must be root who logs in to the GUI…which is usually a problem since default sets root to not be available for GUI logins.

A way to be certain DISPLAY is set is to use it as a prefix on your command line. If my script is “whatever.sh”, then this would do the job:

DISPLAY=:0 /where/ever/it/is/whatever.sh

I strongly suggest that you debug by running as user “ubuntu” or “nvidia” under a logged in local GUI. Running the script with sudo while logged in to a local GUI might give root permission to display there without the DISPLAY environment variable (I am thinking that a local console, from in the GUI, will pass through any GPU use to DISPLAY automatically and open security to not disallow it).

Note that rc.local cannot succeed for any application requiring the GUI. Don’t think of GUI as a graphical desktop, think of it as a buffer with an API for the GPU and security.

Does the script have to run sudo root? Does the script work from a local GUI command line start?

lamegeorge,

I still wonder if your lightdm and DISPLAY environment var is set correctly or not.

Could you try to run any samples in mmapi with EGL render enabled?