balena-io-experimental / browser

A drop-in web browser block
98 stars 75 forks source link

Raspberry Pi 4 GPU Acceleration only partially enabled? #121

Closed sashahilton00 closed 1 day ago

sashahilton00 commented 2 years ago

Hi,

I have been testing this block out in the hopes of using if for a kiosk where hardware accelerated graphics are required. After launching the block with the following configuration:

browser:
    image: bhcr.io/balenablocks/browser-aarch64
    privileged: true
    network_mode: host
    ports:
      - '5011'
    volumes:
      - 'browser-settings:/data'

    environment:
      LAUNCH_URL: 'https://testufo.com/'
      KIOSK: 0
      SHOW_CURSOR: 1
      ENABLE_GPU: 1

The chrome://gpu page is reporting that only rasterization is hardware accelerated - canvas, compositing and video decode are all software only, and opengl/webgl are unavailable all together. Please find attached a pastebin link for the full log from chrome://gpu: https://pastebin.com/XkZbdS75

Is there something basic that I am missing? @rahul-thakoor commented on the balena forums a while back about needing to use a Pi specific build of chromium, but looking through this repo it looks as though any pi specific stuff has been removed/replaced by the generic aarch64 image. Thread is here. When trying the older, unmaintained balena blocks image hosted on Docker (balenablocks/browser:raspberrypi4-64) the hardware acceleration is fully functional. A pastebin of the chrome://gpu report when running that block is available here: https://pastebin.com/1B5TsJtz, which shows hardware acceleration working as expected.

Any thoughts on where I might be going wrong would be much appreciated.

rahul-thakoor commented 2 years ago

Hello @sashahilton00

In the current version, GPU hardware acceleration is disabled by default. You will need to set up ENABLE_GPU=1 as an environment variable for the browser service.

rahul-thakoor commented 2 years ago

You can find more details here

sashahilton00 commented 2 years ago

Hi Rahul,

I have set that environment variable to enable the GPU - the config at the top of my comment is the one that I am using.

The problem is that it only appears to enable the GPU for rasterisation - WebGL and OpenGL are both disabled

rahul-thakoor commented 2 years ago

Hi

Yes, we were originally using the following flags when enabling GPU

--enable-features=WebRTC-H264WithOpenH264FFmpeg 
--ignore-gpu-blacklist 
--enable-gpu-rasterization 
--force-gpu-rasterization 
--gpu-sandbox-failures-fatal=no 
--enable-native-gpu-memory-buffers

see here

Now, we set the following

 --enable-zero-copy
--num-raster-threads=4
--ignore-gpu-blacklist
--enable-gpu-rasterization

as set here

You can use the FLAGS var to try and find a working configuration for you.

Please note that this will overwrite the default flags we are using.

Can you please provide more details about your setup?

Thanks

sashahilton00 commented 2 years ago

I'll run some tests with the flags provided above. With regards to version and config, I'm running balenaOS 2.95.8 (development), I have vc4-kms-v3d as a dtoverlay, and "i2c_arm=on","spi=on","audio=on" as dtparams. I'll provide some logs and the boot config when I run the tests.

Marcocanc commented 2 years ago

Hey all, I'm having similar issues. Interestingly I had no issues with WebGL on RPi3. On RPi4 I can't get it to work (trying to render https://get.webgl.org/).

Chrissi2812 commented 2 years ago

This is seems to be caused by the version change in b2dd1a2067c561003b55a4bb5cd88d09df115a43. EDIT: Okay maybe it's caused by this #100 (0bc5e8933478a2c16a398a433e093c4fad09ebdf)

I have tested two versions of the browser block on a Raspberry Pi 4.

version Chrome Version WebGL
2.2.0 Chromium 92.0.4515.98 Built on Raspbian , running on Debian 10
2.4.3 Chromium 89.0.4389.114 built on Debian 10.9, running on Debian 10.6

Seems newer versions of the browser-block use a generic chromium build. And this causes issues.

Host Config ``` BALENA_HOST_CONFIG_disable_overscan 1 BALENA_HOST_CONFIG_gpu_freq 700 BALENA_HOST_CONFIG_gpu_mem 256 BALENA_HOST_CONFIG_over_voltage 4 RESIN_HOST_CONFIG_arm_64bit 1 RESIN_HOST_CONFIG_avoid_warnings 1 RESIN_HOST_CONFIG_disable_splash 1 RESIN_HOST_CONFIG_dtoverlay "vc4-fkms-v3d" RESIN_HOST_CONFIG_dtparam "i2c_arm=on","spi=on","audio=on" ```
hanyufoodles commented 1 year ago

We have this issue with the browser-aarch64 version 2.4.6.

By changing the base image from balenalib/%%BALENA_MACHINE_NAME%%-debian-node:${NODEJS_VERSION}-buster-run to balenalib/%%BALENA_MACHINE_NAME%%-node:${NODEJS_VERSION}-run, I made the hardware acceleration working.

It seems the debian buster node base image doesn't come with the GPU acceleration support for RPI v4. I hope this can help.

phil-d-wilson commented 1 day ago

If you use the browser-arm7hf version of the block, it uses the RaspberryPi specific version of chromium, which has patches to enable the GPU correctly.