Skip to content

Instantly share code, notes, and snippets.

@craigmulligan
Created May 27, 2016 17:39
Show Gist options
  • Save craigmulligan/7687388f4bb27f6d7aa6f3ec260e1e60 to your computer and use it in GitHub Desktop.
Save craigmulligan/7687388f4bb27f6d7aa6f3ec260e1e60 to your computer and use it in GitHub Desktop.
instructions on working around the docker-EGL bug.

EGL Bug/Screen freezes when using GPU-accelerated features

Symptoms

Screen freezes when trying to run a GPU-accelerated application, this can include 2D accelerated applications or video playback as well as obviously 3D applications. Generally the app runs without error but as soon as it tries to show video/render something in 3D/etc. the image freezes and often all inputs appear to freeze too. Sometimes a few frames of playback/rendering will be displayed before the freeze occurs, but not always.

Treatment

We've created a workaround for the underlying bug which causes this - in short, userland processes that use the GPU communicate with it ultimately via a messaging system called VCHIQ - this uses Process IDs (PIDs) to uniquely identify each 'service' associated with a given userland process, however under a PID namespace (which is established when a docker container is running), the PIDs as far as the kernel is concerned vs. as far as the container-run userland process is concerned vary, meaning that the messages do not get routed correctly. The fix adjusts the raspberry pi userland tools to use VCHIQ's own API for determining the global identifier and using that instead of the container namespaced one. The patched branch of the userland tools is kept at https://github.com/resin-io-playground/userland/tree/client-id, and cross-compiled binaries for the patched version are kept at https://github.com/resin-io-playground/userland/releases (direct link - https://github.com/resin-io-playground/userland/releases/download/v0.1/userland-rpi.tar.xz) To install the patched binaries, simply expand them into the /opt/vc directory inside the container after the libraspberrypi-dev package is installed (this package overwrites the /opt/vc directory so we want to avoid our patched version getting removed by adding the patched versions after it does this.) One way to do this is to add the following near the end of the Dockerfile:

WORKDIR /opt/vc
RUN wget https://github.com/resin-io-playground/userland/releases/download/v0.1/userland-rpi.tar.xz
RUN tar xf userland-rpi.tar.xz

Adding another WORKDIR afterwards if the CMD of the Dockerfile needs to run in a directory that isn't /opt/vc. NOTE: We are working on a fix to base images to automatically force use of our patched versions if the user tries to install libraspberrypi-dev which will make these instructions redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment