Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion frontend/src/components/NoVNCViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,18 @@ function fpWebglRuntimeLabel(profile: Record<string, any>): string {
const health = profile?.runtimeHealth
const checks = health?.checks || {}
if (checks['webgl.contextAvailable'] === false) return 'unavailable'
if (checks['webgl2.contextAvailable'] === false) return 'webgl2-unavailable'
if (checks['webgl.contextAvailable'] === true) {
const mode = health?.expected?.webglRuntime?.resolved
return mode === 'swiftshader' ? 'fallback-swiftshader' : 'available'
const suffix = checks['webgl2.contextAvailable'] === true ? '+webgl2' : ''
return mode === 'swiftshader' ? `fallback-swiftshader${suffix}` : `${mode || 'available'}${suffix}`
}
return '-'
}

function fpWebglRuntimeOk(profile: Record<string, any>): boolean {
return profile?.runtimeHealth?.checks?.['webgl.contextAvailable'] === true
&& profile?.runtimeHealth?.checks?.['webgl2.contextAvailable'] !== false
}

function fpWarnings(profile: Record<string, any>): string[] {
Expand Down
9 changes: 8 additions & 1 deletion services/selenium-chrome/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@ RUN sed -i 's|http://archive.ubuntu.com/ubuntu/|http://mirrors.aliyun.com/ubuntu
&& apt-get -o Acquire::Retries=5 update \
&& apt-get -o Acquire::Retries=5 install -y --no-install-recommends \
xdotool xclip python3-websocket \
libegl-mesa0 libegl1 \
libegl-mesa0 libegl1 libgles2 libgl1-mesa-dri \
fonts-croscore fonts-crosextra-carlito fonts-crosextra-caladea \
fonts-noto-cjk \
fontconfig \
&& rm -rf /var/lib/apt/lists/*
RUN set -eux; \
for libdir in /usr/lib/aarch64-linux-gnu /usr/lib/x86_64-linux-gnu /usr/lib/arm-linux-gnueabihf; do \
if [ -d "$libdir" ] && [ ! -e "$libdir/libGLESv2.so.2" ] && [ -e /usr/lib/chromium/libGLESv2.so ]; then \
ln -s /usr/lib/chromium/libGLESv2.so "$libdir/libGLESv2.so.2"; \
fi; \
done; \
ldconfig
COPY fonts-local.conf /etc/fonts/local.conf
COPY browser-fontconfig.conf /opt/browser-fontconfig/fonts.conf
RUN mkdir -p /tmp/browser-fontconfig-cache && chmod 1777 /tmp/browser-fontconfig-cache \
Expand Down
10 changes: 8 additions & 2 deletions services/selenium-chrome/cdp-fingerprint-agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,14 @@ def _health_expression(self) -> str:
}});
}}
}}catch(e){{}}
var glVendor='',glRenderer='',glContextAvailable=false;
var glVendor='',glRenderer='',glContextAvailable=false,gl2ContextAvailable=false;
try{{
var canvas=document.createElement('canvas');
var gl=canvas.getContext('webgl')||canvas.getContext('experimental-webgl')||canvas.getContext('webgl2');
var gl2=canvas.getContext('webgl2');
var gl=gl2||canvas.getContext('webgl')||canvas.getContext('experimental-webgl');
if(gl){{
glContextAvailable=true;
gl2ContextAvailable=!!gl2;
var dbg=gl.getExtension('WEBGL_debug_renderer_info');
glVendor=dbg?gl.getParameter(dbg.UNMASKED_VENDOR_WEBGL):gl.getParameter(gl.VENDOR);
glRenderer=dbg?gl.getParameter(dbg.UNMASKED_RENDERER_WEBGL):gl.getParameter(gl.RENDERER);
Expand All @@ -520,6 +522,7 @@ def _health_expression(self) -> str:
uaDataPlatform:uadPlatform,
highEntropy:high,
webglContextAvailable:glContextAvailable,
webgl2ContextAvailable:gl2ContextAvailable,
webglVendor:glVendor,
webglRenderer:glRenderer,
timezone:tz,
Expand Down Expand Up @@ -576,6 +579,7 @@ def _check_health(
checks["navigator.platform"] = observed.get("platform") == expected["navigatorPlatform"]
checks["navigator.userAgentData.platform"] = observed.get("uaDataPlatform") == expected["uaCHPlatform"]
checks["webgl.contextAvailable"] = bool(observed.get("webglContextAvailable"))
checks["webgl2.contextAvailable"] = bool(observed.get("webgl2ContextAvailable"))
checks["webgl.rendererSpoofMatched"] = (
bool(observed.get("webglContextAvailable"))
and observed.get("webglRenderer") == expected["webglRenderer"]
Expand All @@ -598,6 +602,8 @@ def _check_health(
if not ok:
if key == "webgl.contextAvailable":
warnings.append(f"webgl_runtime_unavailable during {reason}")
elif key == "webgl2.contextAvailable":
warnings.append(f"webgl2_runtime_unavailable during {reason}")
elif key == "webgl.rendererSpoofMatched":
if checks.get("webgl.contextAvailable"):
warnings.append(f"webgl_spoof_mismatch during {reason}")
Expand Down
35 changes: 28 additions & 7 deletions services/selenium-chrome/start-browser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,44 @@ if [ -z "$CHROME_BIN" ]; then
fi
CHROME_REAL_VERSION=$("$CHROME_BIN" --version 2>/dev/null | grep -oP '[\d.]+' | head -1)
CHROME_REAL_MAJOR=${CHROME_REAL_VERSION%%.*}
CHROME_VERSION_TEXT=$("$CHROME_BIN" --version 2>/dev/null || true)
KERNEL_ARCH=$(uname -m 2>/dev/null || echo "")
REQUESTED_GL_MODE="${BROWSER_GL_MODE:-auto}"
GL_MODE="$REQUESTED_GL_MODE"
GL_ARGS=("--enable-webgl")
GL_ARGS=("--enable-webgl" "--enable-webgl2")
case "$GL_MODE" in
auto|"")
GL_MODE="swiftshader"
if echo "$CHROME_VERSION_TEXT" | grep -qi "chromium" && echo "$KERNEL_ARCH" | grep -Eq "aarch64|arm64"; then
GL_MODE="angle-swiftshader"
else
GL_MODE="swiftshader"
fi
;;
native|swiftshader)
native|egl|swiftshader|angle|angle-swiftshader)
;;
*)
echo "WARN: unsupported BROWSER_GL_MODE=$REQUESTED_GL_MODE, falling back to auto" >&2
GL_MODE="swiftshader"
if echo "$CHROME_VERSION_TEXT" | grep -qi "chromium" && echo "$KERNEL_ARCH" | grep -Eq "aarch64|arm64"; then
GL_MODE="angle-swiftshader"
else
GL_MODE="swiftshader"
fi
;;
esac
case "$GL_MODE" in
egl)
GL_ARGS+=("--ignore-gpu-blocklist" "--use-gl=egl" "--use-cmd-decoder=validating" "--disable-gpu-rasterization")
;;
angle)
GL_ARGS+=("--ignore-gpu-blocklist" "--use-gl=angle" "--use-cmd-decoder=validating" "--disable-gpu-rasterization")
;;
angle-swiftshader)
GL_ARGS+=("--ignore-gpu-blocklist" "--use-gl=angle" "--use-angle=swiftshader" "--enable-unsafe-swiftshader" "--use-cmd-decoder=validating" "--disable-gpu-rasterization")
;;
swiftshader)
GL_ARGS+=("--ignore-gpu-blocklist" "--use-gl=swiftshader" "--enable-unsafe-swiftshader" "--use-cmd-decoder=validating" "--disable-gpu-rasterization")
;;
esac
if [ "$GL_MODE" = "swiftshader" ]; then
GL_ARGS+=("--ignore-gpu-blocklist" "--use-gl=swiftshader" "--enable-unsafe-swiftshader")
fi
/usr/bin/python3 - <<PY 2>/dev/null || true
import json
from pathlib import Path
Expand Down