termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.26k stars 3.06k forks source link

Mesa: glxgears crashes on 32bit ARM devices #10226

Closed Yisus7u7 closed 2 years ago

Yisus7u7 commented 3 years ago

Problem description

The window comes out for a few seconds and then disappears

Screenshot_20210726-122626

Info: Android 8.0 32 bits 2GB of ram DE: lxqt WM: Openbox Using vnc

In proot it works, but in termux anything related to OpenGL does not want to work

Steps to reproduce

Expected behavior

Yisus7u7 commented 3 years ago

@suhan-paradkar

ghost commented 3 years ago

VNC doesn't have GLX extension. So forget about everything that uses GLX at least until someone manages to get it working.

Yisus7u7 commented 3 years ago

VNC doesn't have GLX extension. So forget about everything that uses GLX at least until someone manages to get it working.

I've seen people in the reddit group who do it, and it works well for them.

ghost commented 3 years ago

They probably used XSDL.

Yisus7u7 commented 3 years ago

No, is vnc:

https://www.reddit.com/r/termux/comments/on4fkp/openglglfw_gears_on_termux_x11_no_root/?utm_medium=android_app&utm_source=share

ghost commented 3 years ago

Here is an output of xdpyinfo:

There no GLX and I even has disabled it intentionally for tigervnc which uses same build options as xorg-xvfb-server.

ghost commented 3 years ago

What is on reddit is GLFW examples and not glxgears.

Yisus7u7 commented 3 years ago

The GLFW examples also happen to you

Yisus7u7 commented 3 years ago

even freeglut fails me

ghost commented 3 years ago

@Yisus7u7 I really have no idea whether freeglut works or not. These packages were added as requested and since then I didn't get any reports about whether they actually work or not.

Yisus7u7 commented 3 years ago

Oh ok :(

ghost commented 3 years ago

I just got glxgears working (sources). So it may rather depend on where you got it and how it was compiled, but not on GLX extension presence.

Yisus7u7 commented 3 years ago

Thanks

AgentA07 commented 3 years ago

@Yisus7u7 maybe because you're on arm32

Yisus7u7 commented 3 years ago

@Yisus7u7 maybe because you're on arm32

Why?

Yisus7u7 commented 3 years ago

Screenshot_20210928-114239

@xeffyr I tried the one in that repository and it doesn't work either.

AbdullahBinJahed commented 3 years ago

@Yisus7u7 maybe because you're on arm32

Why?

mesa-demos does work on aarch ... it just doesn't work on 32bit arm cpu

Yisus7u7 commented 3 years ago

@Yisus7u7 maybe because you're on arm32

Why?

mesa-demos does work on aarch ... it just doesn't work on 32bit arm cpu

I guess patches should be made for arm32

AbdullahBinJahed commented 3 years ago

@Yisus7u7 maybe because you're on arm32

Why?

mesa-demos does work on aarch ... it just doesn't work on 32bit arm cpu

Then you have to see what the problem is and create patches.

If I was smart enough to do that I would've already done that 🥴 ...

someone did help me to native compile the mesa library and I think it worked probably ... but no way to test it ...

can you give me a test program to check wheather OpenGL works or not ?

btw ... i have those scripts on my GitHub repo ... just go to Termux-Faint-Hope repo and copy the patches folder in /sdcard/ and run the myScripts/build-zink.sh or myScripts/build-mesa.sh

Yisus7u7 commented 3 years ago

@Yisus7u7 maybe because you're on arm32

Why?

mesa-demos does work on aarch ... it just doesn't work on 32bit arm cpu

Then you have to see what the problem is and create patches.

If I was smart enough to do that I would've already done that 🥴 ...

someone did help me to native compile the mesa library and I think it worked probably ... but no way to test it ...

can you give me a test program to check wheather OpenGL works or not ?

https://github.com/davidanthonygardner/glxgears

Try compiling and running that

AbdullahBinJahed commented 3 years ago

@Yisus7u7 maybe because you're on arm32

Why?

mesa-demos does work on aarch ... it just doesn't work on 32bit arm cpu

Then you have to see what the problem is and create patches.

If I was smart enough to do that I would've already done that 🥴 ... someone did help me to native compile the mesa library and I think it worked probably ... but no way to test it ... can you give me a test program to check wheather OpenGL works or not ?

https://github.com/davidanthonygardner/glxgears

Try compiling and running that

haha wth ... now even linking doesn't work ? I'll have to recompile it then check btw link for the script is is previous comment, could you check it works or not ? Screenshot_2021-09-29-05-29-06-812_com termux

Yisus7u7 commented 3 years ago

I also had that mistake once I compiled mesa...

I think bookstores are broken.

AbdullahBinJahed commented 3 years ago

I also had that mistake once I compiled mesa...

I think bookstores are broken. ah nvm ... removing ndk-multilib fixed it ... Screenshot_2021-09-29-05-37-32-411_com termux

Dawimpy commented 3 years ago

it works on proot-distro!

Dawimpy commented 3 years ago

it works on proot-distro!

maybe Termux problem?

AbdullahBinJahed commented 3 years ago

it works on proot-distro!

how exactly ? on a 32 bit arm device ? can you give me exact instructions ?

Dawimpy commented 3 years ago

it works on proot-distro!

how exactly ? on a 32 bit arm device ? can you give me exact instructions ?

no, i use arm64 but you can view this vid:

https://www.youtube.com/watch?v=PO75bU3zGm0&t=709s

AbdullahBinJahed commented 3 years ago

it works on proot-distro!

how exactly ? on a 32 bit arm device ? can you give me exact instructions ?

no, i use arm64 but you can view this vid:

https://www.youtube.com/watch?v=PO75bU3zGm0&t=709s

on arm64 OpenGL works even normally ... no need for proot-distro

Yisus7u7 commented 3 years ago

it works on proot-distro!

how exactly ? on a 32 bit arm device ? can you give me exact instructions ?

no, i use arm64 but you can view this vid: https://www.youtube.com/watch?v=PO75bU3zGm0&t=709s

on arm64 OpenGL works even normally ... no need for proot-distro

Very true, the problem is 32-bit.

Dawimpy commented 3 years ago

i'm sumitted a problem in gl4es project

let's wait for respnse.

Yisus7u7 commented 3 years ago

umm ... can i have the wallpaper link ?

https://github.com/Yisus7u7/monas_chinas_uwu_uwu

Dawimpy commented 3 years ago

@yisus7u7 do your phone has access son gl4es hardware?

ghost commented 3 years ago

termux/termux-packages#10226

Here is how I compiled glxgears (I intentionally mentioned only the .c file and not the whole repo):

~ $ curl -LO https://github.com/JoakimSoderberg/mesademos/raw/master/src/xdemos/glxgears.c
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   154  100   154    0     0   1029      0 --:--:-- --:--:-- --:--:--  1033
100 21237  100 21237    0     0  86261      0 --:--:-- --:--:-- --:--:-- 86261
~ $ clang glxgears.c -o glxgears -lGL -lX11 -lm

Running it:

~ $ export DISPLAY=:1
~ $ ./glxgears 
7265 frames in 5.0 seconds = 1452.936 FPS

P.S. I don't use custom mesa with these experimentals with gallium, zink, adreno drivers and other attempts to enable hardware acceleration. Simply installed build-essential xorgproto libx11 mesa tigervnc.

Yisus7u7 commented 3 years ago

Screenshot_20210929-081316

@xeffyr just doesn't work on arm (32-bit)

Yisus7u7 commented 3 years ago

According to this comment

https://github.com/ptitSeb/gl4es/issues/342#issuecomment-931310418

Could it be that disabling glx and mesa-dri has to do with this?

ghost commented 3 years ago

@Yisus7u7 It works on AArch64, i686 and x86_64. So nothing to do with it. But note that gl4es is broken completely, see https://github.com/termux/x11-packages/issues/442 for details.

Yisus7u7 commented 3 years ago

@Yisus7u7 It works on AArch64, i686 and x86_64. So nothing to do with it. But note that gl4es is broken completely, see termux/x11-packages#442 for details.

It's not just gl4es, glu, freeglut, glew and other openGL-related libraries not working

sukualam commented 3 years ago

I try glxgears on xwayland (use termux x11 app) and it crash too (Segmentation Fault)

I use 32 bit prefix termux bootstrap (my device actually 64 bit)

On 64 bit termux bootstrap (default) glxgears works fine in xwayland

Yisus7u7 commented 3 years ago

Then we can confirm that in arm (32-bit) OpenGL does not work

sukualam commented 3 years ago

Then we can confirm that in arm (32-bit) OpenGL does not work

Screenshot_20211007-161825_Termux_X11

btw, i just use Xephyr to make nested x server in xwayland, it somewhat bad performance, but it can software renderer and glxgears work in Termux X11 (i user 32 bit proot debian)

my command: (on termux) termux-x11 & (I login to proot debian 32 bit, then use this command) env DISPLAY=:0 Xephyr :1 -fullscreen & env DISPLAY=:1 xfce4-session

Then, run glxgears from that session...

sukualam commented 3 years ago

https://github.com/termux/termux-x11/releases

sukualam commented 3 years ago

Use termux from fdroid is fine, i also from fdroid too, its not problem... you need to install termux-x11.deb inside termux

Yisus7u7 commented 3 years ago

Then we can confirm that in arm (32-bit) OpenGL does not work

btw, i just use Xephyr to make nested x server in xwayland, it somewhat bad performance, but it can software renderer and glxgears work in Termux X11 (i user 32 bit proot debian)

my command: (on termux) termux-x11 & (I login to proot debian 32 bit, then use this command) env DISPLAY=:0 Xephyr :1 -fullscreen & env DISPLAY=:1 xfce4-session

Then, run glxgears from that session...

@xeffyr Based on this, will OpenGL in arm not be able to access any driver or library?

ghost commented 3 years ago

@Yisus7u7 x11-packages never supported any kind of hw acceleration (officially) and therefore doesn't require any driver to work. In fact, mesa here is provided to fullfill dependency needs of gtk and qt5 libs and maybe for some other packages. I don't know how deeply OpenGL is broken but on my device glxgears works as was shown previously.

Yisus7u7 commented 3 years ago

Well, I don't know if glxgears use opengl, but it still fails in arm.

ghost commented 3 years ago

glxgears use exactly OpenGL (not OpenGLES) and yes, it still fails because not fixed.

sukualam commented 3 years ago

Well, I don't know if glxgears use opengl, but it still fails in arm.

Are you in proot? If yes, you can just run Xephyr on top of Termux Wayland (Termux X11) or Xserver-xsdl.... and you can run glxgears there and some 3D software rendering too.. but performance is very low fps

sukualam commented 3 years ago

Use termux from fdroid is fine, i also from fdroid too, its not problem... you need to install termux-x11.deb inside termux

why this error ?

Screenshot_2021-10-09-06-27-15-493_com termux

Download from github action, use the latest build https://github.com/termux/termux-x11/actions

sukualam commented 3 years ago

aftef you run xephyr :1, then just

env DISPLAY=:1 glxgears

Then view it in your termux X11 app

Btw, this is for proot distro, the xephyr unavailable in termux repo

You need to inside proot (proot-distro) for this method

truboxl commented 3 years ago

I try adding TERMUX_DEBUG_BUILD=true into https://github.com/termux/x11-packages/blob/master/packages/mesa/build.sh

Rebuild, install and use gdb to get these outputs I tested this on aarch64 but installing arm32 Termux app from https://github.com/termux/termux-app/actions and it's reproducible So pretty much confirm arm32 Mesa is broken

Application version:
0.117
Packages CPU architecture:
arm
Subscribed repositories:
# sources.list
deb https://packages.termux.org/apt/termux-main/ stable main
# science-repo (sources.list.d/science.list)
deb https://packages.termux.org/apt/termux-science science stable
# x11-repo (sources.list.d/x11.list)
deb https://packages.termux.org/apt/termux-x11 x11 main
# game-repo (sources.list.d/game.list)
deb https://packages.termux.org/apt/termux-games games stable
Updatable packages:
ed/stable 1.17-4 arm [upgradable from: 1.17]
nano/stable 5.9 arm [upgradable from: 5.8]
pcre2/stable 10.38 arm [upgradable from: 10.37]
termux-tools/stable 0.141 all [upgradable from: 0.140]
Android version:
11
Kernel build information:
Linux localhost 4.4.177-22274331 termux/x11-packages#1 SMP PREEMPT Tue Sep 7 18:27:31 +07 2021 armv8l Android
Device manufacturer:
samsung
Device model:
SM-A307GN
Starting program: /data/data/com.termux/files/usr/bin/glxdemo 
[New LWP 16252]

Thread 1 "glxdemo" received signal SIGSEGV, Segmentation fault.
glShadeModel (mode=7424)
    at /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h:2981
2981    /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h: (undocumented errno 2).
Continuing.
[New LWP 16253]
[New LWP 16254]
[LWP 16254 exited]
[LWP 16253 exited]

Thread 1 "glxdemo" received signal SIGSEGV, Segmentation fault.
glShadeModel (mode=7424)
    at /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h:2981
2981    in /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h
#0  glShadeModel (mode=7424)
    at /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h:2981
        _tbl = 0x0
        _func = <optimized out>
termux/x11-packages#1  0xaaaaa97e in main (argc=<optimized out>, argv=<optimized out>)
    at /home/builder/.termux-build/mesa-demos/src/src/xdemos/glxdemo.c:120
        dpy = 0xf742fa00
        win = 2097154
Starting program: /data/data/com.termux/files/usr/bin/glinfo 

Program received signal SIGSEGV, Segmentation fault.
glDrawBuffer (mode=1028)
    at /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h:3156
3156    /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h: (undocumented errno 2).
Continuing.
[New LWP 4808]
[New LWP 4809]
[LWP 4809 exited]
[LWP 4808 exited]

Thread 1 "glinfo" received signal SIGSEGV, Segmentation fault.
glDrawBuffer (mode=1028)
    at /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h:3156
3156    in /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h
#0  glDrawBuffer (mode=1028)
    at /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h:3156
        _tbl = 0x0
        _func = <optimized out>
termux/x11-packages#1  0xf6aea19c in fgOpenWindow () from /data/data/com.termux/files/usr/lib/libglut.so
No symbol table info available.
termux/x11-packages#2  0xf6ae87b0 in fgCreateWindow () from /data/data/com.termux/files/usr/lib/libglut.so
No symbol table info available.
termux/x11-packages#3  0xf6aea236 in glutCreateWindow ()
   from /data/data/com.termux/files/usr/lib/libglut.so
No symbol table info available.
termux/x11-packages#4  0xaaaaa674 in main (argc=1, argv=0xfffef2c4)
    at /home/builder/.termux-build/mesa-demos/src/src/demos/glinfo.c:18
No locals.
Starting program: /data/data/com.termux/files/usr/bin/glxinfo 

Program received signal SIGSEGV, Segmentation fault.
glGetString (name=7936)
    at /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h:3667
3667    /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h: (undocumented errno 2).
Continuing.
[New LWP 5387]
[New LWP 5389]
[LWP 5389 exited]
[LWP 5387 exited]

Thread 1 "glxinfo" received signal SIGSEGV, Segmentation fault.
glGetString (name=7936)
    at /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h:3667
3667    in /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h
#0  glGetString (name=7936)
    at /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h:3667
        _tbl = 0x0
        _func = <optimized out>
termux/x11-packages#1  0xaaaac34e in print_screen_info (dpy=0xf742fa00, scrnum=0, opts=0xfffef258, 
    coreProfile=<optimized out>, es2Profile=0, limits=0, coreWorked=0)
    at /home/builder/.termux-build/mesa-demos/src/src/xdemos/glxinfo.c:468
        serverVersion = 0xf70766b0 <Fake_glXQueryServerString.version> "1.4 Mesa 17.3.9"
        clientVersion = 0xf70762c8 <Fake_glXGetClientString.version> "1.4 Mesa 17.3.9"
        glRenderer = <optimized out>
        displayName = <optimized out>
        glVendor = <optimized out>
        glExtensions = <optimized out>
        period = <optimized out>
        glxExtensions = 0xf6fe74fb "GLX_MESA_copy_sub_buffer GLX_MESA_pixmap_colormap GLX_MESA_release_buffers GLX_ARB_create_context GLX_ARB_get_proc_address GLX_EXT_texture_from_pixmap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_SGI"...
        glVersion = <optimized out>
        colon = <optimized out>
        extfuncs = {GetProgramivARB = <optimized out>, GetStringi = <optimized out>, 
          GetConvolutionParameteriv = <optimized out>}
        serverVendor = 0xf6fe74d9 "Brian Paul"
        serverExtensions = 0xf6fe74fb "GLX_MESA_copy_sub_buffer GLX_MESA_pixmap_colormap GLX_MESA_release_buffers GLX_ARB_create_context GLX_ARB_get_proc_address GLX_EXT_texture_from_pixmap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_SGI"...
        clientVendor = 0xf6fe74d9 "Brian Paul"
        clientExtensions = 0xf6fe74fb "GLX_MESA_copy_sub_buffer GLX_MESA_pixmap_colormap GLX_MESA_release_buffers GLX_ARB_create_context GLX_ARB_get_proc_address GLX_EXT_texture_from_pixmap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_SGI"...
        glxVersionMajor = <optimized out>
        glxVersionMinor = <optimized out>
        height = 100
        width = 100
        ctx = 0xf70b61c0
        root = <optimized out>
        oglstring = 0xaaaae58c "OpenGL"
        fbconfigs = <optimized out>
        visinfo = <optimized out>
        mask = 10250
        attr = {background_pixmap = 2863353856, background_pixel = 0, 
          border_pixmap = 1, border_pixel = 0, bit_gravity = 40, 
          win_gravity = -147447808, backing_store = 0, backing_planes = 4294898232, 
          backing_pixel = 4147188316, save_under = -69032, event_mask = 163840, 
          do_not_propagate_mask = 1, override_redirect = -148363805, 
          colormap = 2097153, cursor = 4148361728}
        win = 2097154
termux/x11-packages#2  0xaaaac014 in main (argc=<optimized out>, argv=<optimized out>)
    at /home/builder/.termux-build/mesa-demos/src/src/xdemos/glxinfo.c:1261
        opts = {mode = Normal, findBest = 0 '\000', limits = 0 '\000', 
          singleLine = 0 '\000', displayName = 0x0, allowDirect = 1 '\001'}
        dpy = 0xf742fa00
        numScreens = 1
        scrnum = 0
        coreWorked = <optimized out>
Starting program: /data/data/com.termux/files/usr/bin/glxgears 
[New LWP 5771]

Thread 1 "glxgears" received signal SIGSEGV, Segmentation fault.
glLightfv (light=16384, pname=4611, params=0xaaaaf000 <init.pos>)
    at /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h:2862
2862    /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h: (undocumented errno 2).
Continuing.
[New LWP 5773]
[New LWP 5774]
[LWP 5774 exited]
[LWP 5773 exited]

Thread 1 "glxgears" received signal SIGSEGV, Segmentation fault.
glLightfv (light=16384, pname=4611, params=0xaaaaf000 <init.pos>)
    at /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h:2862
2862    in /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h
#0  glLightfv (light=16384, pname=4611, params=0xaaaaf000 <init.pos>)
    at /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h:2862
        _tbl = 0x0
        _func = <optimized out>
termux/x11-packages#1  0xaaaab8d8 in init ()
    at /home/builder/.termux-build/mesa-demos/src/src/xdemos/glxgears.c:398
        pos = {5, 5, 10, 0}
        red = {0.800000012, 0.100000001, 0, 1}
        green = {0, 0.800000012, 0.200000003, 1}
        blue = {0.200000003, 0.200000003, 1, 1}
termux/x11-packages#2  0xaaaab4c4 in main (argc=<optimized out>, argv=<optimized out>)
    at /home/builder/.termux-build/mesa-demos/src/src/xdemos/glxgears.c:790
        winWidth = <optimized out>
        winHeight = <optimized out>
        x = <optimized out>
        y = <optimized out>
        i = <optimized out>
        printInfo = 0 '\000'
        dpyName = <optimized out>
        dpy = 0xf742fa00
        visId = <optimized out>
        ctx = 0xf70f21c0
        win = 2097154
#0  glLightfv (light=16384, pname=4611, params=0xaaaaf000 <init.pos>)
    at /home/builder/.termux-build/mesa/src/src/mapi/glapi/glapi_mapi_tmp.h:2862
        _tbl = 0x0
        _func = <optimized out>
termux/x11-packages#1  0xaaaab8d8 in init ()
    at /home/builder/.termux-build/mesa-demos/src/src/xdemos/glxgears.c:398
        pos = {5, 5, 10, 0}
        red = {0.800000012, 0.100000001, 0, 1}
        green = {0, 0.800000012, 0.200000003, 1}
        blue = {0.200000003, 0.200000003, 1, 1}
termux/x11-packages#2  0xaaaab4c4 in main (argc=<optimized out>, argv=<optimized out>)
    at /home/builder/.termux-build/mesa-demos/src/src/xdemos/glxgears.c:790
        winWidth = <optimized out>
        winHeight = <optimized out>
        x = <optimized out>
        y = <optimized out>
        i = <optimized out>
        printInfo = 0 '\000'
        dpyName = <optimized out>
        dpy = 0xf742fa00
        visId = <optimized out>
        ctx = 0xf70f21c0
        win = 2097154

Not sure how useful are these logs. Might be a red herring.