Bug 1406

Summary: DRM/GBM Instability on Raspberry Pi 4 Model B Rev 1.1
Product: [JogAmp] Jogl Reporter: Sven Gothel <sgothel>
Component: embeddedAssignee: Sven Gothel <sgothel>
Status: RESOLVED FIXED    
Severity: blocker CC: xerxes
Priority: P4    
Version: 2.4.0   
Hardware: embedded_arm   
OS: linux   
Type: DEFECT SCM Refs:
e57de40bd0e1a318d59ca70f20a6f7d8a8921c74
Workaround: ---
Bug Depends on: 1156, 1408    
Bug Blocks:    
Attachments: log-01 (HDMI0, /dev/dri/card1, SoftGL)
log-02 (HDMI1, /dev/dri/card1/ SoftGL)
log-10 (launch via physical console)

Description Sven Gothel 2019-12-04 04:49:37 CET
Using a vanilla Raspberry Pi 4 Model B Rev 1.1
and 2019-09-26-raspbian-buster-lite.img
without updates, having installed:
<---
apt update
apt install openjdk-11-jre-headless openjdk-11-jdk-headless ant libdrm2 libgbm1 libgles2 libgles1 libegl1 libgl1-mesa-dri libxrandr2 libxcursor1 mesa-utils-extra
--->

First issue was that the proper DRM file had to be queries,
as Raspberry 4 may have two of them:
<--
/dev/dri/dri0
/dev/dri/dri0
/dev/dri/by-path/platform-fec00000.v3d-card -> ../card0
/dev/dri/by-path/platform-soc:gpu-card -> ../card1
-->

After selecting the right DRM file:

DRM/GBM initialization has been passed, as well as OpenGL:
<----
GearsES2 init 0x1ec2012 on Thread[main-Animator#00,5,main]
Chosen GLCapabilities: GLCaps[egl cfg 0x11, vid 0x34325258: rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 16/0/0, dbl, mono  , sw, GLProfile[GLES3/GLES3.sw], on-scr[.], [0x4d: GL, GLES1, GLES2, GLES3, VG]]
INIT GL IS: jogamp.opengl.es3.GLES3Impl
Swap Interval  1
GL Profile     GLProfile[GLES3/GLES3.sw]
GL Version     3.0 (ES profile, arb, compat[ES2, ES3], FBO, software) - OpenGL ES 3.0 Mesa 19.2.0-rc1 [GL 3.0.0, vendor 19.2.0 (Mesa 19.2.0-rc1)]
Quirks         [GLES3ViaEGLES2Config, No10BitColorCompOffscreen]
Impl. class    jogamp.opengl.es3.GLES3Impl
GL_VENDOR      VMware, Inc.
GL_RENDERER    llvmpipe (LLVM 8.0, 128 bits)
GL_VERSION     OpenGL ES 3.0 Mesa 19.2.0-rc1
GLSL           true, has-compiler-func: true, version: OpenGL ES GLSL ES 3.00 / 3.0.0
GL FBO: basic true, full true
GL_EXTENSIONS  85
GLX_EXTENSIONS 24
--->

Unlike Bug 1405, the Animator thread does not cause a freeze.
However the following issues have been observed (incomplete):
- PointerIcon change may cause lookup (key 'c')
- PointerIcon visibility may cause lookup (key 'i')

- Rendering artifacts within animation. 
  It doesn't seem to be simple tearing, but a portion of the 'gears' pixels is changing/different in the other framebuffer likely:
    - all the time
    - at the very same position, same region on screen

- .. ?
Comment 1 Sven Gothel 2019-12-04 04:55:07 CET
e57de40bd0e1a318d59ca70f20a6f7d8a8921c74
Bug 1406: DRMUtil: Probe DRM device whether it has resources attached (and is the desired one)
Comment 2 Sven Gothel 2019-12-04 05:00:42 CET
(In reply to Sven Gothel from comment #0)
> GearsES2 init 0x1ec2012 on Thread[main-Animator#00,5,main]
> Chosen GLCapabilities: GLCaps[egl cfg 0x11, vid 0x34325258: rgba 8/8/8/0,
> opaque, accum-rgba 0/0/0/0, dp/st/ms 16/0/0, dbl, mono  , sw,
> GLProfile[GLES3/GLES3.sw], on-scr[.], [0x4d: GL, GLES1, GLES2, GLES3, VG]]
> INIT GL IS: jogamp.opengl.es3.GLES3Impl
> Swap Interval  1
> GL Profile     GLProfile[GLES3/GLES3.sw]
> GL Version     3.0 (ES profile, arb, compat[ES2, ES3], FBO, software) -
> OpenGL ES 3.0 Mesa 19.2.0-rc1 [GL 3.0.0, vendor 19.2.0 (Mesa 19.2.0-rc1)]
> Quirks         [GLES3ViaEGLES2Config, No10BitColorCompOffscreen]
> Impl. class    jogamp.opengl.es3.GLES3Impl
> GL_VENDOR      VMware, Inc.
> GL_RENDERER    llvmpipe (LLVM 8.0, 128 bits)
> GL_VERSION     OpenGL ES 3.0 Mesa 19.2.0-rc1
> GLSL           true, has-compiler-func: true, version: OpenGL ES GLSL ES
> 3.00 / 3.0.0
> GL FBO: basic true, full true
> GL_EXTENSIONS  85
> GLX_EXTENSIONS 24

^^^ this test is using the SOFTWARE OpenGL driver, oops!

Notable, /dev/dri/dri1 has been used here - related???

Also: eglinfo:

Configurations:
     bf lv colorbuffer dp st  ms    vis   cav bi  renderable  supported
  id sz  l  r  g  b  a th cl ns b    id   eat nd gl es es2 vg surfaces 
---------------------------------------------------------------------
0x01 32  0 10 10 10  2  0  0  0 0 0x30334241--         y  y  y     win
0x02 32  0 10 10 10  2 16  0  0 0 0x30334241--         y  y  y     win
0x03 32  0 10 10 10  2 24  0  0 0 0x30334241--         y  y  y     win
0x04 32  0 10 10 10  2 24  8  0 0 0x30334241--         y  y  y     win
0x05 32  0 10 10 10  2  0  0  4 1 0x30334241--         y  y  y     win
0x06 32  0 10 10 10  2 16  0  4 1 0x30334241--         y  y  y     win
0x07 32  0 10 10 10  2 24  0  4 1 0x30334241--         y  y  y     win
0x08 32  0 10 10 10  2 24  8  4 1 0x30334241--         y  y  y     win
0x09 32  0  8  8  8  8  0  0  0 0 0x34325241--         y  y  y     win
0x0a 32  0  8  8  8  8 16  0  0 0 0x34325241--         y  y  y     win
0x0b 32  0  8  8  8  8 24  0  0 0 0x34325241--         y  y  y     win
0x0c 32  0  8  8  8  8 24  8  0 0 0x34325241--         y  y  y     win
0x0d 32  0  8  8  8  8  0  0  4 1 0x34325241--         y  y  y     win
0x0e 32  0  8  8  8  8 16  0  4 1 0x34325241--         y  y  y     win
0x0f 32  0  8  8  8  8 24  0  4 1 0x34325241--         y  y  y     win
0x10 32  0  8  8  8  8 24  8  4 1 0x34325241--         y  y  y     win
0x11 24  0  8  8  8  0  0  0  0 0 0x34325258--         y  y  y     win
0x12 24  0  8  8  8  0 16  0  0 0 0x34325258--         y  y  y     win
0x13 24  0  8  8  8  0 24  0  0 0 0x34325258--         y  y  y     win

i.e. 0x11 config differs, has no depth buffer!
Comment 3 Sven Gothel 2019-12-04 05:12:39 CET
(In reply to Sven Gothel from comment #2)

Software GL Driver
Notable, /dev/dri/dri1 has been used here - related???
Monitor connected on HDMI0 - next to the USB power port
(See https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up/4)
(Attached log-01)

/boot/config.txt:

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
dtoverlay=vc4-fkms-v3d
Comment 4 Sven Gothel 2019-12-04 05:13:29 CET
Created attachment 830 [details]
log-01 (HDMI0, /dev/dri/card1, SoftGL)
Comment 5 Sven Gothel 2019-12-04 05:16:27 CET
Created attachment 831 [details]
log-02 (HDMI1, /dev/dri/card1/ SoftGL)
Comment 6 Sven Gothel 2019-12-04 05:18:47 CET
(In reply to Sven Gothel from comment #5)
> Created attachment 831 [details]
> log-02 (HDMI1, /dev/dri/card1/ SoftGL)

Now attached on HDMI1, result is also software GL 
and also choosing /dev/dri/card1 (platform-soc:gpu-card)
using fake-KMS.

Flickering: Occurs only when mouse moves in the upper half region
of the screen. Not plain tearing.
Comment 7 Sven Gothel 2019-12-04 05:25:52 CET
Vanilla 2019-09-26-raspbian-buster-lite.img installation:

(This is also the same setup for Bug 1405)

Kernel Linux raspi03 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux

ii  raspberrypi-kernel             1.20190925-1                armhf        Raspberry Pi bootloader

ii  rpi-eeprom-images              1.3-1                       all          Raspberry Pi 4 boot EEPROM images

ii  firmware-brcm80211             1:20190114-1+rpt2           all          Binary firmware for Broadcom/Cypress 802.11 wireless cards

ii  rpi-update                     20140705                    all          Raspberry Pi firmware updating tool

ii  libegl-mesa0:armhf             19.2.0~rc1-1~bpo10+1~rpt3   armhf        free implementation of the EGL API -- Mesa vendor library

ii  libgl1-mesa-dri:armhf          19.2.0~rc1-1~bpo10+1~rpt3   armhf        free implementation of the OpenGL API -- DRI modules

ii  libglapi-mesa:armhf            19.2.0~rc1-1~bpo10+1~rpt3   armhf        free implementation of the GL API -- shared library

ii  libglu1-mesa:armhf             9.0.0-2.1                   armhf        Mesa OpenGL utility library (GLU)

ii  libglx-mesa0:armhf             19.2.0~rc1-1~bpo10+1~rpt3   armhf        free implementation of the OpenGL API -- GLX vendor library

ii  libgles1:armhf                 1.1.0-1                     armhf        Vendor neutral GL dispatch library -- GLESv1 support

ii  libgles2:armhf                 1.1.0-1                     armhf        Vendor neutral GL dispatch library -- GLESv2 support

ii  libraspberrypi0                1.20190925-1                armhf        EGL/GLES/OpenVG/etc. libraries for the Raspberry Pi's VideoCore IV
Comment 8 Sven Gothel 2019-12-04 05:28:40 CET
(In reply to Sven Gothel from comment #7)

ii  libraspberrypi-bin             1.20190925-1                armhf        Miscellaneous Raspberry Pi utilities

ii  raspberrypi-bootloader         1.20190925-1                armhf        Raspberry Pi bootloader

ii  raspberrypi-kernel             1.20190925-1                armhf        Raspberry Pi bootloader

ii  raspberrypi-net-mods           1.3.0                       all          Network configuration for the Raspberry Pi UI

ii  raspberrypi-sys-mods           20190730                    armhf        System tweaks for the Raspberry Pi

ii  raspi-config                   20190917                    all          Raspberry Pi configuration tool

ii  rpi-eeprom                     1.3-1                       all          Raspberry Pi 4 boot EEPROM updater

ii  rpi-eeprom-images              1.3-1                       all          Raspberry Pi 4 boot EEPROM images

ii  rpi-update                     20140705                    all          Raspberry Pi firmware updating tool
Comment 9 Sven Gothel 2019-12-04 05:49:28 CET
Note: All tests were performed via ssh-login, turns out it does make a difference here!

After running same test via physical console on the device,
the hardware GL profile has been chosen 
and the same freeze as in Bug 1405 occurs!

(See log-10)
Comment 10 Sven Gothel 2019-12-04 05:50:14 CET
Created attachment 832 [details]
log-10 (launch via physical console)
Comment 11 Sven Gothel 2019-12-04 05:51:36 CET
(In reply to Sven Gothel from comment #10)
> Created attachment 832 [details]
> log-10 (launch via physical console)

GearsES2 init 0x398b7c on Thread[main-Animator#00,5,main]
Chosen GLCapabilities: GLCaps[egl cfg 0x12, vid 0x34325258: rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 16/0/0, dbl, mono  , hw, GLProfile[GLES3
/GLES3.hw], on-scr[.], [0x4d: GL, GLES1, GLES2, GLES3, VG]]
INIT GL IS: jogamp.opengl.es3.GLES3Impl
Swap Interval  1
GL Profile     GLProfile[GLES3/GLES3.hw]
GL Version     3.0 (ES profile, arb, compat[ES2, ES3], FBO, hardware) - OpenGL ES 3.0 Mesa 19.2.0-rc1 [GL 3.0.0, vendor 19.2.0 (Mesa 19.2.0-rc1)]
Quirks         [No10BitColorCompOffscreen]
Impl. class    jogamp.opengl.es3.GLES3Impl
GL_VENDOR      Broadcom
GL_RENDERER    V3D 4.2
GL_VERSION     OpenGL ES 3.0 Mesa 19.2.0-rc1
GLSL           true, has-compiler-func: true, version: OpenGL ES GLSL ES 3.00 / 3.0.0
GL FBO: basic true, full true
GL_EXTENSIONS  65
GLX_EXTENSIONS 27
Comment 12 Sven Gothel 2019-12-04 06:37:27 CET
(In reply to Sven Gothel from comment #9)
> Note: All tests were performed via ssh-login, turns out it does make a
> difference here!
> 
> After running same test via physical console on the device,
> the hardware GL profile has been chosen 
> and the same freeze as in Bug 1405 occurs!
> 
> (See log-10)

Funny: Being on physical console and doing 'chvt 7 ; java ..'
we end up with Software GL. 
Therefor some TTY magic variable has a sideeffect on the EGL/GL implementation.
Booo! ;-)
Comment 13 Sven Gothel 2019-12-04 15:38:07 CET
Instability issue also occurs w/o VSYNC waiting,
only fetching nextBO while freeing lastBO 
in NEWT native code @ swapSurface.

But it lasts longer.

Instability seems to disappear or lessens w/o keyboard tracker.

True tearing is now visible.
Comment 14 Sven Gothel 2019-12-05 07:53:05 CET
Fixed, see Bug 1408 comment 7