簡體   English   中英

應用程序在 Docker 容器內的 Wayland 上使用 EGL 崩潰

[英]Application crashes using EGL on Wayland inside a Docker container

我正在使用 Toradex 的 Apalis i.MX8QM 模塊。 我安裝了 Torizon,它是制造商維護的 Linux 操作系統。 它旨在與基於 debian 的 Docker 容器一起使用。 他們提供了一個運行 Weston (Wayland + XWayland) 的容器來渲染圖形。 在另一個容器中,我使用以下 Dockerfile 編譯了 OGRE3D 圖形引擎(源代碼: www.github.com/OGRECave/ogre ):

FROM --platform=linux/arm64 torizon/wayland-base-vivante:2 AS base
RUN apt-get -y update && apt-get install -y --no-install-recommends \
    apt-utils \
    && apt-mark hold dash && apt-get -y upgrade && apt-mark unhold dash \
    && apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*
ARG ACCEPT_FSL_EULA=1
RUN apt-get -y update && apt-get install -y --no-install-recommends \
    libwayland-client0 \
    libwayland-server0 \
    libgal-vivante1 \
    libvsc-vivante1 \
    libgbm-vivante1 \
    libegl-vivante1 \
    libgl-vivante1 \
    libglesv2-vivante1 \
    libglesv1-cm-vivante1 \
    libglslc-vivante1 \
    && apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*
# Make sure the user can access DRM and video devices
RUN usermod -a -G video,render torizon
# UP TO HERE ITS CODE PROVIDED BY TORADEX 
RUN apt-get -y update && apt-get install -y git cmake gcc g++ make libxrandr-dev libglu1-mesa-dev libzip-dev libfreeimage-dev libpoco-dev libois-dev libzzip-0-13 libzzip-dev doxygen libcgal-dev libcppunit-dev libxt-dev libxaw7-dev pkg-config gdb x11-apps nano libsdl2-2.0 libegl-vivante1-dev
USER torizon
RUN cd /home/torizon/ && git clone https://github.com/OGRECave/ogre
RUN mkdir -p /home/torizon/ogre/bld && cd /home/torizon/ogre/bld && cmake -DCMAKE_BUILD_TYPE=Debug -DOGRE_GLSUPPORT_USE_EGL=1 -DOGRE_BUILD_RENDERSYSTEM_GLES2=1 -DOGRE_BUILD_SAMPLES=1 -DOGRE_CONFIG_THREADS=0 -DOGRE_INSTALL_DOCS=0 -DOGRE_BUILD_PLUGIN_CG=0 -DOGRE_INSTALL_MEDIA=1 -DOGRE_BUILD_TOOLS=0 -DOGRE_BUILD_TESTS=0 -DOGRE_INSTALL_SAMPLES=1 ../
RUN cd /home/torizon/ogre/bld && make
USER root
RUN cd /home/torizon/ogre/bld && make install

上面的容器使用以下命令運行(可能不需要一些環境變量來真正完成這項工作):

docker run -e ACCEPT_FSL_EULA=1 -e X11_UNIX_SOCKET=/tmp/.X11-unix -e WAYLAND_DISPLAY=wayland-0 -e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR -e DISPLAY=:0 -it --rm --name=wayland-app --user=torizon -v /dev/dri:/dev/dri -v /dev/galcore:/dev/galcore -v /tmp:/tmp -v /run/:/run/ --device-cgroup-rule='c 199:* rmw' --device-cgroup-rule='c 226:* rmw' --cap-add=SYS_PTRACE --security-opt seccomp=unconfined ogre-way-base-egl-j1

當我嘗試運行 OGRE3D 編譯后編譯的第一個示例時,我得到了一些錯誤。 我用 gdb 運行它來幫助調試。 Output 如下圖所示:

torizon@0c2f3e5ed77f:~/ogre/bld/bin$ gdb SampleBrowser
GNU gdb (Debian 9.2-1) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from SampleBrowser...
(gdb) catch throw
Catchpoint 1 (throw)
(gdb) r
Starting program: /home/torizon/ogre/bld/bin/SampleBrowser
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
Creating resource group General
Creating resource group OgreInternal
Creating resource group OgreAutodetect
SceneManagerFactory for type 'DefaultSceneManager' registered.
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
MovableObjectFactory for type 'ParticleSystem' registered.
ArchiveFactory for archive type FileSystem registered.
ArchiveFactory for archive type Zip registered.
ArchiveFactory for archive type EmbeddedZip registered.
DDS codec registering
ETC codec registering
ASTC codec registering
Registering ResourceManager for type HighLevelGpuProgram
Registering ResourceManager for type Compositor
MovableObjectFactory for type 'Entity' registered.
MovableObjectFactory for type 'Light' registered.
MovableObjectFactory for type 'BillboardSet' registered.
MovableObjectFactory for type 'ManualObject' registered.
MovableObjectFactory for type 'BillboardChain' registered.
MovableObjectFactory for type 'RibbonTrail' registered.
Loading library /home/torizon/ogre/bld/lib/RenderSystem_GLES2.so.1.12.12
Installing plugin: OpenGL ES 2.0 RenderSystem
OpenGL ES 2.x Rendering Subsystem created.
[New Thread 0xffffe5601170 (LWP 22)]
[New Thread 0xffffe4e00170 (LWP 23)]

Thread 1 "SampleBrowser" received signal SIGSEGV, Segmentation fault.
0x0000fffff6e6dbd0 in pthread_mutex_lock () from /lib/aarch64-linux-gnu/libpthread.so.0
(gdb) bt
#0  0x0000fffff6e6dbd0 in pthread_mutex_lock () from /lib/aarch64-linux-gnu/libpthread.so.0
#1  0x0000fffff69432f0 in wl_proxy_create_wrapper () from /usr/lib/aarch64-linux-gnu/libwayland-client.so.0
#2  0x0000fffff6ba1b50 in ?? () from /usr/lib/aarch64-linux-gnu/libEGL.so.1
#3  0x0000fffff6b94534 in eglInitialize () from /usr/lib/aarch64-linux-gnu/libEGL.so.1
#4  0x0000fffff6c7d694 in Ogre::EGLSupport::getGLDisplay (this=0xaaaaaab17b90) at /home/torizon/ogre/RenderSystems/GLSupport/src/EGL/OgreEGLSupport.cpp:65
#5  0x0000fffff6c618c4 in Ogre::X11EGLSupport::getGLDisplay (this=0xaaaaaab17b90) at /home/torizon/ogre/RenderSystems/GLSupport/src/EGL/X11/OgreX11EGLSupport.cpp:280
#6  0x0000fffff6c60ba4 in Ogre::X11EGLSupport::X11EGLSupport (this=0xaaaaaab17b90, profile=4) at /home/torizon/ogre/RenderSystems/GLSupport/src/EGL/X11/OgreX11EGLSupport.cpp:51
#7  0x0000fffff6c60b44 in Ogre::getGLSupport (profile=4) at /home/torizon/ogre/RenderSystems/GLSupport/src/EGL/X11/OgreX11EGLSupport.cpp:45
#8  0x0000fffff6c3d1c4 in Ogre::GLES2RenderSystem::GLES2RenderSystem (this=0xaaaaaab17180) at /home/torizon/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp:178
#9  0x0000fffff6c3cb18 in Ogre::GLES2Plugin::install (this=0xaaaaaab17100) at /home/torizon/ogre/RenderSystems/GLES2/src/OgreGLES2Plugin.cpp:48
#10 0x0000fffff79c026c in Ogre::Root::installPlugin (this=0xaaaaaab00b20, plugin=0xaaaaaab17100) at /home/torizon/ogre/OgreMain/src/OgreRoot.cpp:1188
#11 0x0000fffff6c28bc4 in Ogre::dllStartPlugin () at /home/torizon/ogre/RenderSystems/GLES2/src/OgreGLES2EngineDll.cpp:41
#12 0x0000fffff79c064c in Ogre::Root::loadPlugin (this=0xaaaaaab00b20, pluginName="/home/torizon/ogre/bld/lib/RenderSystem_GLES2") at /home/torizon/ogre/OgreMain/src/OgreRoot.cpp:1237
#13 0x0000fffff79bf2c4 in Ogre::Root::loadPlugins (this=0xaaaaaab00b20, pluginsfile="./plugins.cfg") at /home/torizon/ogre/OgreMain/src/OgreRoot.cpp:973
#14 0x0000fffff79bc9ac in Ogre::Root::Root (this=0xaaaaaab00b20, pluginFileName="./plugins.cfg", configFileName="./ogre.cfg", logFileName="./ogre.log")
    at /home/torizon/ogre/OgreMain/src/OgreRoot.cpp:227
#15 0x0000fffff7f76d3c in OgreBites::ApplicationContextBase::createRoot (this=0xfffffffff238) at /home/torizon/ogre/Components/Bites/src/OgreApplicationContextBase.cpp:191
#16 0x0000fffff7f7663c in OgreBites::ApplicationContextBase::initApp (this=0xfffffffff238) at /home/torizon/ogre/Components/Bites/src/OgreApplicationContextBase.cpp:55
#17 0x0000aaaaaaab6b28 in OgreBites::SampleContext::go (this=0xfffffffff238, initialSample=0x0) at /home/torizon/ogre/Samples/Common/include/SampleContext.h:143
#18 0x0000aaaaaaab44e4 in main (argc=1, argv=0xfffffffff648) at /home/torizon/ogre/Samples/Browser/src/main.cpp:89

正如我們所見,它在 pthread_mutex_lock() 處崩潰,從 libwayland-client 調用。

就在調用 eglInitialize() 之前(正好在行代碼中),arguments 值為:

(gdb) step
65              if (eglInitialize(mGLDisplay, &mEGLMajor, &mEGLMinor) == EGL_FALSE)
(gdb) print mGLDisplay
$3 = (EGLDisplay) 0xaaaaaab16180
(gdb) print *mEGLMajor
Cannot access memory at address 0x0
(gdb) print mEGLMajor
$4 = 0
(gdb) print mEGLMinor
$5 = 0

我在互聯網上搜索,但找不到任何適合我情況的解決方案,我不知道如何繼續嘗試解決這個問題。

任何信息表示贊賞。

我嘗試使用我們的 Visual Studio 代碼擴展來重現構建 Ogre 的問題,因此情況可能會有些不同(我使用了交叉復雜性,並且有一個容器要構建,一個容器來運行應用程序)。 首先,我更改了構建配置以刪除一些渲染器,這有助於使依賴關系更簡單。 這些是我在 cmake 中的定義:

    "OGRE_GLSUPPORT_USE_EGL":1,
    "OGRE_BUILD_RENDERSYSTEM_GL":0,
    "OGRE_BUILD_RENDERSYSTEM_GL3PLUS":0,
    "OGRE_BUILD_RENDERSYSTEM_TINY":0,
    "OGRE_BUILD_RENDERSYSTEM_GLES2":1,
    "OGRE_BUILD_SAMPLES":1,
    "OGRE_CONFIG_THREADS": 0,
    "OGRE_INSTALL_DOCS":0,
    "OGRE_BUILD_PLUGIN_CG":0,
    "OGRE_INSTALL_MEDIA":1,
    "OGRE_BUILD_TOOLS":0,
    "OGRE_BUILD_TESTS":0,
    "OGRE_INSTALL_SAMPLES":1

我還添加了一個安裝后命令,用於將安裝路徑從我的本地文件夾修復到我在設備上使用的路徑 (/ogre)。 在 CMakeList.txt 的末尾,我添加了:

install (SCRIPT "${CMAKE_SOURCE_DIR}/PostInstall.cmake")

這是 PostInstall.cmake:

message("Post install script")

execute_process(COMMAND bash "-c" "sed -i s+/workspaces/ogre/appconfig_0/work/ogre+/ogre+g ${CMAKE_INSTALL_PREFIX}/share/OGRE/*.cfg"
    )

對於構建,我使用這個 dockerfile:

FROM torizon/debian-cross-toolchain-arm64:2-bullseye

RUN HOLD_PKGS='libdrm-common libdrm-amdgpu1:arm64 libdrm2:arm64' \
    && apt-get -y update \
    && apt-get -y upgrade \
    && for P in $HOLD_PKGS ; do \
    echo ${P}=$(apt-cache show $P | sed -r -e '/^Version:/!d' -e 's/.* //' -e '/toradex/d' -e 'q') ; \
    done | xargs -r apt-get install -y --no-install-recommends \
    && apt-mark hold $HOLD_PKGS \
    && apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*

# commands that should be run before installing packages (ex: to add a feed or keys)


# your regular RUN statements here
# Install required packages
RUN apt-get -q -y update \
    && apt-get -q -y install gdb-multiarch procps rsync openssh-client\
    libwayland-dev:arm64 \
    libgbm-vivante1-dev:arm64 libegl-vivante1-dev:arm64 libglesv2-vivante1-dev:arm64 libxrandr-dev:arm64  libzip-dev:arm64 libfreeimage-dev:arm64 libpoco-dev:arm64 libois-dev:arm64 libzzip-dev:arm64 doxygen libcgal-dev:arm64 libcppunit-dev:arm64 libxt-dev:arm64 libxaw7-dev:arm64\
    \
    && rm -rf /var/lib/apt/lists/*

(您可以添加命令來克隆代碼、應用更改並構建它)

這是我用來運行應用程序的 dockerfile:

FROM --platform=linux/arm64 torizon/wayland-base:2
          
# Make sure we don't get notifications we can't answer during building.
ENV DEBIAN_FRONTEND="noninteractive"

ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/ogre/lib OGRE_PLUGIN_DIR=/ogre/lib/OGRE

# commands that should be run before installing packages (ex: to add a feed or keys)


# your regular RUN statements here
# Install required packages
RUN if [ ! -z "libxt6 libxaw7 libzzip-0-13 libxrandr2" ]; then \
    apt-get -q -y update \
    && apt-get -q -y install libxt6 libxaw7 libzzip-0-13 libxrandr2 \
    && rm -rf /var/lib/apt/lists/* ; \
    fi

# commands that should be run after all packages have been installed (RUN/COPY/ADD)



COPY work/ogre /ogre


USER torizon

WORKDIR /ogre

# commands that will run on the target (ENTRYPOINT or CMD)
CMD /ogre/bin/SampleBrowser 

通過這種方式,我能夠運行應用程序而不會崩潰。 鼠標 cursor 存在問題,在 openGL 表面上時不可見。 我使用 Verdin iMX8MM 因為我沒有 Apalis IMX8 可用的 ATM,但平台應該是相似的(用於 GPU 的 imx8 和 vivante 驅動程序)。

如果您想嘗試使用我們的 IDE 擴展來構建它,我可以將我的更改分享到 ogre master 分支,但調試這個問題時我發現我們自己的擴展中存在問題,我們需要幾周時間才能發布更新。 抱歉這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM