Fullscreen with P2D hangs Ubuntu 18.04

I’m running Ubuntu 18.04 with an AMD Radeon R7 M445 GPU, the amdgpu drivers and Processing 3.5.1. When running a simple sketch like the one below, the entire system hangs after some time (70-120 seconds) and I have to power cycle the machine. Other than the solution (revert) of this thread, is there a fix (and reason) for this bug?

void setup(){
  fullScreen(P2D);
}

void draw(){
  background(0);
  text(millis(), 100, 100);
}

Btw, this only happens with fullscreen(P2D);. If I use size(200, 200, P2D); instead, it works normally.

Any help is appreciated and thank you in advance!

1 Like

try on RPI 3B+ with current Raspbian Buster
but use Processing 3.5.3 ( any reason you use 3.5.1 ? )
no problem


get 50 FPS


add i login remote SSH terminal

htop

and after start your Processing sketch could not see any memory leak


note: pictures are screenshot from a Win10 PC

you see the RPI desktop in a VNC window
and the terminal htop as overlay in a bitvise xterm window

1 Like

I wonder how hard does it hang. It may be just the sketch hanging and locking the desktop environment, or the desktop environment itself hanging, or the X11 server hanging, or the entire Linux kernel screwing up. I had stuff locking up GNOME before on Ubuntu 18.04.

I think it’s reasonable to try see what it can be.

  • Can you test it with other desktop environments (xfce4, KDE Plasma, whatever?)

  • Can you log into a TTY by pressing CTRL+ALT+F2, and then try to run killall -9 java from there to force close Processing? (then CTRL+ALT+F1 or CTRL+ALT+F7 to return back)

  • Can you (turn on and) test X11 zapping with CTRL+ALT+BACKSPACE in the middle of such a hang? It should drop you to the login screen.

  • Can you (turn on and) try the Magic SysRq sequence in the middle of such a hang? (i.e. holding ALT+PrintScreen and, without releasing them, pressing keys R,E,I,S,U,B one after another with a second or two of delay between each)

@kll There is no particular reason for 3.5.1 other than being kinda bored to update every minor version :stuck_out_tongue:.

@Architector_4 I was able to log into a TTY and kill Processing. So that is better than power-cycling.

But I still cannot figure out what is happening.
P.S.: I’m specifying P2D in fullScreen so that it is true fullscreen. If you know any other way I can do this, it would eliminate the problem.

You should try with the latest version. Who knows, maybe it has this specific thing fixed?

This means that sketch itself hangs, and, therefore, locks up the desktop environment. Is this specific to fullscreen(P2D); exactly? Does the sketch hang after 70-120 seconds if you do something like size(1920,1080, P2D); i.e. not fullscreen, but with your screen size?

It hanged with size(1920,1080, P2D); as well. I tried with 3.5.3, same thing. Also many times TTY doesn’t work and I have to REISUB out of this.

Doesn’t work in what way? You can’t switch to it? ALT+PrintScreen+R is supposed to reset keyboard layout which might make CTRL+ALT+F2 work.

And if that doesn’t, maybe your system gets overloaded. Try launching such a sketch with a task manager open i.e. while watching RAM usage. If it peaks to 100%, then that should indicate a problem. In that case, ALT+PrintScreen+F manually triggers the Out Of Memory condition i.e. instantly kills the most memory hungry process, which should also be better than REISUB or hardware power cycling. Although you might need to press it several times, as it might first kill a few browser tabs or other applications depending on what you have other.

Also, when TTY doesn’t work, does CTRL+ALT+Backspace (to kill X11) work?

1 Like

Yes it does not switch to it (sorry for being unclear). Or sometimes it tries to switch to it (screen goes all black) but never quite gets there.

Something I just noticed, RAM usage does not seem normal to me!! When I run the sketch above with the task manager open as you suggested, I see the memory usage going up significantly. For that sketch, it starts at ~100MiB and during the first two minutes it goes up to ~150MiB. If I run the sketch below, the situation becomes more interesting, as memory usage starts at 130MiB and after one minute it reaches almost 700MiB (hangs at 730-740MiB).

void setup(){
  fullScreen(P2D);
}

void draw(){
  background(0);
  fill(255);
  textFont(createFont("Calibri", 38));
  text(millis(), 100, 100);
}

During this experiment for example, nothing short of REISUB worked.

How much RAM do you have? Do JAVA2D, P3D, FX2D modes also hang your system?

Can you test with other desktop environments?

8 GB RAM. JAVA2D and FX2D are working normally, P3D also skyrockets memory usage.

Sorry, can’t test with other environments.

Also, on the same machine in Windows 10, Java 8 and Processing 3.3.5, memory usage skyrockets again (it reaches several GB).

In Ubuntu I have jdk 11.

What is so wrong with P2D??

Do not use createFont() in draw()! As most assets, do them all only once in setup(). :warning:

2 Likes

Ubuntu 18.04 with amdgpu and Processing 3.5.3 here. But an RX 560 which I think is next generation from yours? Original sketch works fine without problem.

Are you using the default Processing install? You mention JDK 11 - why? Are you using Processing with system JDK? (I assume not since P2D, well JOGL, hard crashes with stock OpenJDK 11 on Ubuntu anyway, although works fine with other ones).

1 Like

@neilcsmith Yes I am using the default install. I just checked which version is installed in the system through the terminal, not sure if that’s the one Processing uses (can I check that?). I haven’t done anything weird though, just the regular processing installation.

There is a JDK inside the Processing install. Unless you go out of your way to use another one, it will use the one it ships with.

OTOH, I am pointing it at the system installed OpenJDK 8, which might be a cause of difference, but unlikely.

Which desktop and display server (X11 / Wayland) are you using?

try

  println( "__SYS INFO :");
  println( "System     : " + System.getProperty("os.name") + "  " + System.getProperty("os.version") + "  " + System.getProperty("os.arch") );
  println( "JAVA       : " + System.getProperty("java.home")  + " rev: " +javaVersionName);

on my RPI see in terminal

pi@RPI:~ $ java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-post-Raspbian-5)
OpenJDK Server VM (build 11.0.3+7-post-Raspbian-5, mixed mode)
pi@RPI:~ $ 

processing 3.5.3 say

__SYS INFO :
System     : Linux  4.19.66-v7+  arm
JAVA       : /usr/local/lib/processing-3.5.3/java rev: 1.8.0_202

so processing is delivered and using its internal JAVA 8


p-bench ( full code )
float rset=120, r;
int x = 0;
int w = 400;
int h = 200;
int grid=20, many = grid*grid;
boolean stressenable=true;

void settings() {
  size(w, h); // default use JAVA2D 
  // not on RPI  size(w, h,FX2D);
  //  size(w, h,P2D);
  //  size(w, h,P3D);
}

void setup() {
  frameRate(rset);
  println("target "+rset+" FPS");
  background(200, 200, 0);
  println("use key [p] for sysinfo, [n] numinfo, \n[s] stresstest ( "+grid+"*"+grid+" = "+many+" ) points, [+][-] grid +-5" );
}

void draw() {
  surface.setTitle("SYS INFO "+ nf(r, 0, 1)+" FPS" );
  if ( stressenable ) stress();
  r = frameRate;
  if ( r > 30 )      stroke(0, 200, 0); 
  else               stroke(200, 0, 0);
  line(x, height-2, x, height-2-r);            // FPS graph
  x++;
  if ( x > width ) { 
    x = 0; 
    background(200, 200, 0);
  }
}

void stress() {
  push();
  for ( int i=0; i<grid; i++) {
    for ( int j=0; j<grid; j++) {
      stroke(0, 255-random(255), random(255) );
      point(5+i, 5+j);
    }
  }
  pop();
}

void sysinfo() {
  println( "__SYS INFO :");
  println( "System     : " + System.getProperty("os.name") + "  " + System.getProperty("os.version") + "  " + System.getProperty("os.arch") );
  println( "JAVA       : " + System.getProperty("java.home")  + " rev: " +javaVersionName);
  //println( System.getProperty("java.class.path") );
  //println( "\n" + isGL() + "\n" );
  println( "OPENGL     : VENDOR " + PGraphicsOpenGL.OPENGL_VENDOR+" RENDERER " + PGraphicsOpenGL.OPENGL_RENDERER+" VERSION " + PGraphicsOpenGL.OPENGL_VERSION+" GLSL_VERSION: " + PGraphicsOpenGL.GLSL_VERSION);
  println( "user.home  : " + System.getProperty("user.home") );
  println( "user.dir   : " + System.getProperty("user.dir") );
  println( "user.name  : " + System.getProperty("user.name") );
  println( "sketchPath : " + sketchPath() );
  println( "dataPath   : " + dataPath("") );
  println( "dataFile   : " + dataFile("") );
  println( "frameRate  : target "+nf(rset, 0, 1)+" actual "+nf(r, 0, 1));
  println( "canvas     : width "+width+" height "+height+" pix "+(width*height));
}

void numinfo() {
  println( "__NUM INFO :");
  println( "byte    min: "+Byte.MIN_VALUE+   "\t\t\t max: "+Byte.MAX_VALUE);
  println( "short   min: "+Short.MIN_VALUE+  "\t\t\t max: "+Short.MAX_VALUE);
  println( "int     min: "+Integer.MIN_VALUE+"\t\t max: "  +Integer.MAX_VALUE);
  println( "long    min: "+Long.MIN_VALUE+   "\t max: "    +Long.MAX_VALUE);
  println( "float   min: "+Float.MIN_VALUE+  "\t\t\t max: "+Float.MAX_VALUE);
  println( "double  min: "+Double.MIN_VALUE+ "\t\t\t max: "+Double.MAX_VALUE);
}

void keyPressed() {
  if ( key == 'p' ) sysinfo();
  if ( key == 'n' ) numinfo();
  if ( key == 's' ) stressenable = ! stressenable;
  if ( key == '+' ) {
    grid +=5;
    many = grid*grid;
    println("stresstest ( "+grid+"*"+grid+" = "+many+" ) points" );
  }
  if ( key == '-' ) {
    grid -=5;
    many = grid*grid;
    println("stresstest ( "+grid+"*"+grid+" = "+many+" ) points" );
  }
}

@neilcsmith GNOME & X11

@kll Thank you. I get

Linux 4.15.0-54-generic amd64
/opt/processing-3.5.1/java rev: 1.8.0_202

With your p-bench though, all OPENGL fields are null.

1 Like

-a- means you still use 3.5.1
-b- but the processing internal JAVA 8 works fine


OPEN GL:
ok, try again with using

size(w, h,P2D);

now Intel Graphics (that is… suboptimal and weird) shows up in OPENGL and I’m getting 60 fps vs 120 with JAVA2D.

That sounds about right. OpenGL should normally be limited to the vsync rate.