Skip to content

Commit 4b12132

Browse files
committed
core: fix rare "QtWebEngine OpenGL" initialization race condition in containers
Problem: Encountered a one-time crash with the error [1]. This occurred once in dozens of executions when running inside a Linux container. The same container image worked fine before and after, indicating a timing-sensitive race condition rather than a configuration issue. Root Cause: "QtWebEngine" (Chromium-based) performs complex GPU/OpenGL initialization involving multiple process forks and GPU driver queries. In containerized environments, these operations can occasionally race, causing the GL version query to fail during the brief window when the graphics context is not fully initialized. Solution: Added Chromium flags via "QTWEBENGINE_CHROMIUM_FLAGS" to simplify initialization and reduce timing dependencies: - "--disable-gpu-sandbox": removes GPU process sandboxing complexity (reduces initialization races without disabling GPU acceleration) - "--no-zygote": disables zygote template process, simplifying process creation - "--disable-software-rasterizer": prevents mid-initialization fallback during GL queries These flags are standard practice for Chromium in containerized environments (Docker, CI/CD) and do not impact performance or functionality. GPU hardware acceleration remains fully enabled. Uses "os.environ.setdefault()" to respect user-defined environment variables, ensuring backward compatibility. Impact: No performance impact, should prevent the race condition from occurring again. [1] "GL_SHADING_LANGUAGE_VERSION query failed with empty output. Unable to query GL version" Co-authored-by: Cursor AI Signed-off-by: Pavel Bar <pbar@redhat.com>
1 parent e3a292e commit 4b12132

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

app.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
__version__ = "1.0.1"
55

66
import io
7+
import os
78
import sys
89
import argparse
910
from datetime import datetime
@@ -1183,6 +1184,15 @@ def progress(self):
11831184

11841185
args = parser.parse_args()
11851186

1187+
# Configure QtWebEngine for robust operation in containerized environments.
1188+
# These Chromium flags reduce race conditions during OpenGL initialization
1189+
# without disabling GPU acceleration or affecting other Qt components.
1190+
os.environ.setdefault('QTWEBENGINE_CHROMIUM_FLAGS',
1191+
'--disable-gpu-sandbox ' # Reduces GPU sandbox initialization races (no perf impact)
1192+
'--no-zygote ' # Simplifies process initialization (reduces race conditions)
1193+
'--disable-software-rasterizer' # Prevents mid-initialization fallback during GL queries
1194+
)
1195+
11861196
# Enable automatic high DPI scaling
11871197
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
11881198
# Enable crisp rendering on high DPI displays

0 commit comments

Comments
 (0)