Skip to content

Commit ac7bc50

Browse files
committed
test: block QtWebEngine import in qtdragon ui-smoke via meta_path shim
QtWebEngine browser-process init segfaults inside the qtvcp process on Ubuntu 24.04 CI even with --no-sandbox --single-process --disable-gpu. The smoke test never touches the WebWidget, so block the qtpy.QtWebEngineWidgets import via a sitecustomize meta_path finder; WebWidget already has a fallback that swaps in a plain QWidget when that import fails. No Chromium spawn, no segfault. The previous chromium-flags attempt was retracted: 'Sandboxing disabled by user.' confirmed Chromium got the flags but still crashed during init, so we are not going to win that race.
1 parent 0c62bfe commit ac7bc50

1 file changed

Lines changed: 36 additions & 5 deletions

File tree

tests/ui-smoke/qtdragon/test.sh

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818
#
1919
# qtdragon embeds a QWebEngineView (Chromium). Under offscreen + xvfb
2020
# with no GPU and no user namespaces in the CI runner sandbox,
21-
# QtWebEngine racy-crashes during browser-process spawn. Disable the
22-
# Chromium sandbox and force single-process + software rendering so
23-
# the renderer runs in the same process as Qt with no GPU thread.
21+
# QtWebEngine browser-process init segfaults even with --no-sandbox
22+
# --single-process --disable-gpu (Chromium logs "Sandboxing disabled
23+
# by user." then crashes inside the same qtvcp PID). Rather than keep
24+
# tuning Chromium flags for a widget the smoke test never touches,
25+
# we shim qtpy.QtWebEngineWidgets to raise ImportError; web_widget.py
26+
# already has a fallback path that swaps the QWebEngineView for a
27+
# plain QWidget when the import fails (its "fail safe - mostly for
28+
# designer" branch). No Chromium spawn = no crash.
2429
set -u
2530

2631
LIB_DIR="$(cd "$(dirname "$0")/../_lib" && pwd)"
@@ -34,8 +39,34 @@ sed -i 's|^LOG_FILE = qtdragon\.log$|LOG_FILE = ~/qtdragon.log|' \
3439

3540
export LINUXCNC_OPENGL_PLATFORM=offscreen
3641
export QT_QPA_PLATFORM=offscreen
37-
export QTWEBENGINE_DISABLE_SANDBOX=1
38-
export QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox --disable-gpu --disable-software-rasterizer --single-process --no-zygote"
42+
43+
# sitecustomize.py is auto-imported by Python from any sys.path entry
44+
# at interpreter startup. Drop a meta_path finder that blocks the
45+
# qtpy.QtWebEngineWidgets import so WebWidget falls back to QWidget.
46+
SHIM_DIR="$WORK_DIR/_pyshim"
47+
mkdir -p "$SHIM_DIR"
48+
cat >"$SHIM_DIR/sitecustomize.py" <<'PY'
49+
import sys
50+
from importlib.abc import MetaPathFinder, Loader
51+
from importlib.util import spec_from_loader
52+
53+
_BLOCK = {'qtpy.QtWebEngineWidgets', 'PyQt5.QtWebEngineWidgets'}
54+
55+
class _BlockLoader(Loader):
56+
def create_module(self, spec):
57+
raise ImportError('QtWebEngineWidgets blocked for ui-smoke CI')
58+
def exec_module(self, module):
59+
pass
60+
61+
class _BlockFinder(MetaPathFinder):
62+
def find_spec(self, name, path, target=None):
63+
if name in _BLOCK:
64+
return spec_from_loader(name, _BlockLoader())
65+
return None
66+
67+
sys.meta_path.insert(0, _BlockFinder())
68+
PY
69+
export PYTHONPATH="$SHIM_DIR${PYTHONPATH:+:$PYTHONPATH}"
3970

4071
exec "$LIB_DIR/run-gui.sh" "$WORK_DIR/qtdragon_metric.ini" \
4172
--run-program "$LIB_DIR/smoke.ngc" --expect-delta-mm 1,1,0

0 commit comments

Comments
 (0)