I have a docker image with opencv installed via apt. When I run my program it crashes when opening an opencv window with cv2.namedWindow(WINDOW_NAME, cv2.WINDOW_NORMAL) resulting in the following error:
(python3:218): Gdk-ERROR **: 15:41:23.282: The program 'python3' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadAccess (attempt to access private resource denied)'.
(Details: serial 287 error_code 10 request_code 130 (MIT-SHM) minor_code 1)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the GDK_SYNCHRONIZE environment
variable to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
When I run the program again it works without problems. However, every time I start the docker new again I get this error on the first try. Further tries usually work without problems.
This didn’t solve the problem, but it has lead me to realise the error is not necessarily originating from the cv2.namedWindow(WINDOW_NAME, cv2.WINDOW_NORMAL) command. Rather, the error appears only when the image is shown with: cv2.waitKey(100).
So if this is not an opencv problem, where should I ask about this?
Alright, so I installed gedit which uses GTK and it has the same problem. It crashes the first time it is run with the GDK BadAccess Error. So I guess the problem lies with the GDK installation and docker.