OF slow on RPi4?

Hi all!
I’ve downloaded and installed latest OF release (0.11) on my raspberry pi 4 (model b). Everything seems fine, but it seems quite slow… The simple example graphics/poligonExample show ~40FPS. If run full screen, with

ofSetupOpenGL(1024,768, OF_FULLSCREEN);

the FPS it’s only half of this (~20).

It’s ok, or something is wrong?

2 Likes

Yeah it is slow on my RPi4 too.
It seems the FPS goes under 40 when I create a 1024 x 768 window.
If I create a smaller size, it goes close to 60.

Can you open an issue on github?

also see: RPi3 + Buster Lite + oF 0.11.0 = can't run example

I suspect this might be slow cause the new driver requires an X session which makes things much slower than before. using the legacy driver and starting the application from a console without having an x session running will probably make things faster

1 Like

Ok, i’ll give it a try ASAP. If i’m correct, it should suffice this change:

USE_PI_LEGACY = 1
PROJECT_LDFLAGS += -latomic //add the flag

in project make.config, right?

Made some tests, with no success…
In detail:

#USE_PI_LEGACY = 0
in OF/libs/openFrameworksCompiled/project/linuxarmv6l/config.linuxarmv6l.default.mk
PROJECT_LDFLAGS += -latomic
in project config.make

The example compile, but nothing is shown. With GL driver this is the output:

./bin/polygonExample 
[warning] ofAppEGLWindow: init(): X11 not availble on RPI yet, using a native window instead
[notice ] ofAppEGLWindow: setupRPiNativeWindow(): screenRect: 1280x1024
[notice ] ofAppEGLWindow: setupRPiNativeWindow(): windowRect: 1024x768
[notice ] ofAppEGLWindow: createSurface(): setting up EGL Display
* failed to add service - already in use?

And with the legacy one:

./bin/polygonExample 
[warning] ofAppEGLWindow: init(): X11 not availble on RPI yet, using a native window instead
[notice ] ofAppEGLWindow: setupRPiNativeWindow(): screenRect: 1280x1024
[notice ] ofAppEGLWindow: setupRPiNativeWindow(): windowRect: 1024x768
[notice ] ofAppEGLWindow: createSurface(): setting up EGL Display
[notice ] ofAppEGLWindow: createSurface(): EGL Display correctly set 0x1
[notice ] ofAppEGLWindow: createSurface(): no current renderer selected
[notice ] ofAppEGLWindow: createSurface(): default renderer detected
[notice ] ofAppEGLWindow: createSurface(): surface created correctly
[notice ] ofAppEGLWindow: createSurface(): API bound correctly
[notice ] ofAppEGLWindow: createSurface(): -----EGL-----
[notice ] ofAppEGLWindow: createSurface(): EGL_VERSION_MAJOR = 1
[notice ] ofAppEGLWindow: createSurface(): EGL_VERSION_MINOR = 4
[notice ] ofAppEGLWindow: createSurface(): EGL_CLIENT_APIS = OpenGL_ES OpenVG
[notice ] ofAppEGLWindow: createSurface(): EGL_VENDOR = Broadcom
[notice ] ofAppEGLWindow: createSurface(): EGL_VERSION = 1.4
[notice ] ofAppEGLWindow: createSurface(): EGL_EXTENSIONS = EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_vg_parent_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_lock_surface 
[notice ] ofAppEGLWindow: createSurface(): GL_RENDERER = VideoCore IV HW
[notice ] ofAppEGLWindow: createSurface(): GL_VERSION  = OpenGL ES-CM 1.1
[notice ] ofAppEGLWindow: createSurface(): GL_VENDOR   = Broadcom
[notice ] ofAppEGLWindow: createSurface(): -------------
[notice ] ofAppEGLWindow: setupPeripherals(): peripheral setup complete
[notice ] ofAppEGLWindow: setupNativeUDev(): created udev object
[notice ] ofAppEGLWindow: setupNativeInput()
[notice ] Got device
[notice ]  - node: 
[notice ]  - sysname: input0
[notice ]  - devpath: /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3/1-1.3:1.0/0003:10C4:8105.0001/input/input0
[notice ]  - devtype: 
[notice ]  - driver: 
[notice ]  - devnum: 0
[notice ]  - ID_INPUT_KEYBOARD: 
[notice ]  - ID_INPUT_MOUSE: 1
[notice ] Got device
[notice ]  - node: /dev/input/event0
[notice ]  - sysname: event0
[notice ]  - devpath: /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3/1-1.3:1.0/0003:10C4:8105.0001/input/input0/event0
[notice ]  - devtype: 
[notice ]  - driver: 
[notice ]  - devnum: 3392
[notice ]  - ID_INPUT_KEYBOARD: 
[notice ]  - ID_INPUT_MOUSE: 1
[notice ] ofAppEGLWindow: addInput(): input device name = YSPRINGTECH USB OPTICAL MOUSE
[ error ] ofAppEGLWindow: ioctl GABS failed
[ error ] ofAppEGLWindow: ioctl GABS failed
[notice ] Got device
[notice ]  - node: /dev/input/mouse0
[notice ]  - sysname: mouse0
[notice ]  - devpath: /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3/1-1.3:1.0/0003:10C4:8105.0001/input/input0/mouse0
[notice ]  - devtype: 
[notice ]  - driver: 
[notice ]  - devnum: 3360
[notice ]  - ID_INPUT_KEYBOARD: 
[notice ]  - ID_INPUT_MOUSE: 1
[notice ] Got device
[notice ]  - node: 
[notice ]  - sysname: input1
[notice ]  - devpath: /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/0003:046D:C312.0002/input/input1
[notice ]  - devtype: 
[notice ]  - driver: 
[notice ]  - devnum: 0
[notice ]  - ID_INPUT_KEYBOARD: 1
[notice ]  - ID_INPUT_MOUSE: 
[notice ] Got device
[notice ]  - node: /dev/input/event1
[notice ]  - sysname: event1
[notice ]  - devpath: /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/0003:046D:C312.0002/input/input1/event1
[notice ]  - devtype: 
[notice ]  - driver: 
[notice ]  - devnum: 3393
[notice ]  - ID_INPUT_KEYBOARD: 1
[notice ]  - ID_INPUT_MOUSE: 
[notice ] ofAppEGLWindow: addInput(): input device name = BTC USB Multimedia Keyboard
[notice ] Got device
[notice ]  - node: 
[notice ]  - sysname: input2
[notice ]  - devpath: /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C312.0003/input/input2
[notice ]  - devtype: 
[notice ]  - driver: 
[notice ]  - devnum: 0
[notice ]  - ID_INPUT_KEYBOARD: 
[notice ]  - ID_INPUT_MOUSE: 
[notice ] Got device
[notice ]  - node: /dev/input/event2
[notice ]  - sysname: event2
[notice ]  - devpath: /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C312.0003/input/input2/event2
[notice ]  - devtype: 
[notice ]  - driver: 
[notice ]  - devnum: 3394
[notice ]  - ID_INPUT_KEYBOARD: 
[notice ]  - ID_INPUT_MOUSE: 
[notice ] Got device
[notice ]  - node: 
[notice ]  - sysname: input3
[notice ]  - devpath: /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C312.0003/input/input3
[notice ]  - devtype: 
[notice ]  - driver: 
[notice ]  - devnum: 0
[notice ]  - ID_INPUT_KEYBOARD: 
[notice ]  - ID_INPUT_MOUSE: 
[notice ] Got device
[notice ]  - node: /dev/input/event3
[notice ]  - sysname: event3
[notice ]  - devpath: /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C312.0003/input/input3/event3
[notice ]  - devtype: 
[notice ]  - driver: 
[notice ]  - devnum: 3395
[notice ]  - ID_INPUT_KEYBOARD: 
[notice ]  - ID_INPUT_MOUSE: 
[notice ] Got device
[notice ]  - node: /dev/input/mice
[notice ]  - sysname: mice
[notice ]  - devpath: /devices/virtual/input/mice
[notice ]  - devtype: 
[notice ]  - driver: 
[notice ]  - devnum: 3391
[notice ]  - ID_INPUT_KEYBOARD: 
[notice ]  - ID_INPUT_MOUSE: 
[notice ] --- Input Device List ---: 
[notice ]  - /dev/input/event0
[notice ]  - /dev/input/event1
[notice ] -------------------------: 
[notice ] ofAppEGLWindow: setupPeripherals(): native event setup complete
[notice ] ofAppEGLWindow: setWindowTitle(): not implemented
[notice ] ofAppEGLWindow: setWindowTitle(): not implemented
[notice ] ofAppEGLWindow: setWindowTitle(): not implemented
[notice ] ofAppEGLWindow: setWindowTitle(): not implemented

Same starting without X (so boot in console, if i’ve understood your suggestion), with this message:

[ error ] ofAppGLFWWindow: 65544: X11: The DISPLAY environment variable is missing
[ error ] ofAppGLFWWindow: couldn't init GLFW
[ error ] ofAppGLFWWindow: 65537: The GLFW library is not initialized
Errore di segmentazione

Hope this helps…

Thanks for this.
In your last example when you start without X it shouldn’t be running the GLFW window.
Maybe double check this line is commented out.

I’ll take a look too and see if I can get this working.
It seems that on the Pi 3 it is possible, but I never managed to get the legacy system working on the Pi 4.

One other thing it could be that is making it slower is that the GLFW window defaults to AA being enabled. It could be that the older windows didn’t have as graphically intense settings.

You can disable AA in your main.cpp like so:

    ofGLFWWindowSettings msettings;
    msettings.setSize( 1024, 768 );
    msettings.numSamples = 0; 
    auto mainWin = ofCreateWindow( msettings );

    auto app = make_shared<ofApp>();
    ofRunApp( mainWin, app );
    ofRunMainLoop();
1 Like

yes, that’s quite the case. Not sure, but i think i’ve recompiled with default options for this test. However i’m pretty sure to have tested with the USE_PI commented out even in console, without success (just another error message).
I’ll give a try without AA later.

Thanks!

Opened this issue on github:
https://github.com/openframeworks/openFrameworks/issues/6497

Thanks for your hints!

1 Like

Just tried on the RPi 4 I have and I do see a big speed difference with the default configuration when setting numSamples to 0.

  • I get 20 fps in Release for the 3DPrimitivesExample with the default main.cpp
  • I get 57-60 fps in Release for the same example with: msettings.numSamples = 0;

So at the very least its something we can document, but also maybe change the default here for RPI builds:

Also just tried the EGL Window in Release and only got 19 fps.

So at least with X Windows / Desktop: GLFW with numSamples = 0, seems to be the fastest.

Will look into the legacy approach to though.

Just to confirm that disabling AA works, and i can get ~60FPS, as expected.

Thanks for your help!

1 Like

I tried yesterday on my RPi4 with numSamples = 0 and it seemed to work OK, but drawing images or video (even just a single image), maxed the CPU instantly out to 330%. Which in turn makes the RPi get very hot very quickly.

Hi @kasparsj - welcome to the forum!

Can you try in ofApp::setup(){

adding:

ofSetFrameRate(60);

or

ofSetFrameRate(30);

and see if that makes a difference?

If it doesn’t could you share the code you are running?
For me the examples run without the PI getting hot.

1 Like

Hi @theo.
For drawing images ofSetFrameRate(30) did help, CPU usage drops from 300% to around 110%, I was testing the imageSubsectionExample.
But for playing videos, when loading with .setPixelFormat( OF_PIXELS_NATIVE ), and using programmable renderer .setGLESVersion(2) CPU usage is still 340%.
Since ofxOMXPlayer does not work with GLFW, I guess, currently there is no other option to play videos on RPi 4?

made some test:
imageSubsectionExample, as come with OF (so without numSamples=0), and “full” framerate (just ofSetVerticalSync(true)) -> max cpu 30% (just one core), ~60FPS

Maybe there’s something wrong in your config?