Skip to content

Troubleshooting Launch Issues on Raspberry Pi

HiroYokoyama edited this page Dec 6, 2025 · 3 revisions

Troubleshooting Launch Issues on Raspberry Pi

This guide addresses issues where moleditpy crashes immediately upon launch or fails to display the window when running on Raspberry Pi (Raspberry Pi OS).

Symptoms

When launching the application, it crashes with the following error logs in the terminal:

  1. X Window System Error:
    X Error of failed request: BadWindow (invalid Window parameter)
    Major opcode of failed request: 12 (X_ConfigureWindow)
    
  2. OpenGL / Shader Compilation Error:
    vtkShaderProgram ... error: syntax error, unexpected NEW_IDENTIFIER
    attempt to add attribute without a program for attribute ndCoordIn
    Couldn't build the shader program for resolving msaa.
    

Cause

The issue stems from compatibility conflicts between the Raspberry Pi graphics driver (VC4/V3D) and the visualization libraries (VTK/Qt).

  1. OpenGL Version Mismatch: The application requests Anti-Aliasing (MSAA) features requiring sampler2DMS (GLSL 1.50+). The default Raspberry Pi driver may not expose this version, causing shader compilation to fail.
  2. Window System (Wayland vs. X11): On Raspberry Pi OS (Bookworm and later), which uses Wayland by default, Qt may encounter race conditions when interacting with XWayland, leading to the BadWindow error.

Solution

You can resolve these issues by setting specific environment variables before launching the application.

Method 1: Temporary (Command Line)

Run the following commands in your terminal to set the variables and launch the app:

export QT_QPA_PLATFORM=xcb
export MESA_GL_VERSION_OVERRIDE=3.2
export MESA_GLSL_VERSION_OVERRIDE=150
moleditpy
  • QT_QPA_PLATFORM=xcb: Forces Qt to use the X11 backend instead of Wayland.
  • MESA_GL_...: Overrides the reported OpenGL version to 3.2 (GLSL 1.50), allowing the driver to attempt compiling the required shaders.

Method 2: Startup Script (Recommended)

To avoid typing these commands every time, create a shell script (e.g., run_moleditpy.sh).

  1. Create the file:
    nano run_moleditpy.sh
  2. Paste the following content:
    #!/bin/bash
    export QT_QPA_PLATFORM=xcb
    export MESA_GL_VERSION_OVERRIDE=3.2
    export MESA_GLSL_VERSION_OVERRIDE=150
    moleditpy
  3. Make it executable and run:
    chmod +x run_moleditpy.sh
    ./run_moleditpy.sh

Note for Developers

If you are modifying the source code, you can fix the root cause of the shader error by disabling Multi-Sampling (MSAA). This removes the need for the MESA_... environment overrides, as the complex shaders will not be generated.

Python (VTK) Example:

# Disable multisampling on the render window
render_window.SetMultiSamples(0)

Note: The QT_QPA_PLATFORM=xcb variable may still be required depending on the specific OS version and Qt environment.


Clone this wiki locally