@threenative/runtime-native 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/scripts/xvfb.sh CHANGED
@@ -18,6 +18,8 @@ esac
18
18
 
19
19
  if ! command -v Xvfb >/dev/null 2>&1; then
20
20
  echo "scripts/xvfb.sh: Xvfb is required for headless Linux runs and is not installed." >&2
21
+ echo "scripts/xvfb.sh: install it (Debian/Ubuntu 'xvfb', Arch 'xorg-server-xvfb', Fedora" >&2
22
+ echo "scripts/xvfb.sh: 'xorg-x11-server-Xvfb'). Refusing to run blind." >&2
21
23
  exit 2
22
24
  fi
23
25
 
@@ -26,10 +28,18 @@ runtime="$(mktemp -d)"
26
28
  display_file="$runtime/display"
27
29
  : >"$display_file"
28
30
 
29
- Xvfb -displayfd 3 -screen 0 "$screen" -nolisten tcp 3>"$display_file" &
31
+ # COMPOSITE and SHAPE let a compositing manager blend on this display; without them the native
32
+ # desktop runtime cannot attach its UI overlay. Xvfb leaves both off by default.
33
+ Xvfb -displayfd 3 +extension COMPOSITE +extension SHAPE -screen 0 "$screen" -nolisten tcp 3>"$display_file" &
30
34
  xvfb_pid=$!
31
35
 
36
+ compositor_pid=""
37
+
32
38
  cleanup() {
39
+ if [ -n "$compositor_pid" ] && kill -0 "$compositor_pid" 2>/dev/null; then
40
+ kill "$compositor_pid" 2>/dev/null || true
41
+ wait "$compositor_pid" 2>/dev/null || true
42
+ fi
33
43
  if kill -0 "$xvfb_pid" 2>/dev/null; then
34
44
  kill "$xvfb_pid" 2>/dev/null || true
35
45
  wait "$xvfb_pid" 2>/dev/null || true
@@ -63,6 +73,43 @@ fi
63
73
 
64
74
  DISPLAY=":$display"
65
75
  export DISPLAY
76
+
77
+ # GitHub's Xvfb has no DRI3 device. Mesa's EGL loader reports that expected headless condition as
78
+ # warning text on stderr; the playtest runtime correctly records stderr as diagnostics, so those
79
+ # environment warnings otherwise turn a successful software-rendered run red. Keep fatal EGL
80
+ # diagnostics visible and leave an operator-provided log level untouched.
81
+ if [ -z "${EGL_LOG_LEVEL+x}" ]; then
82
+ EGL_LOG_LEVEL=fatal
83
+ export EGL_LOG_LEVEL
84
+ fi
85
+
86
+ # Nothing blends on a bare Xvfb: it has no compositing manager, and the X server will not do it
87
+ # either, so the desktop runtime refuses to attach its UI overlay to such a display. Borrow an
88
+ # installed compositor for this private display only -- `-n` keeps xcompmgr to plain blending,
89
+ # with none of the shadows or fades that would alter the pixels a run asserts on. A host with
90
+ # none installed still gets its display, and that refusal still reports the missing dependency.
91
+ for candidate in xcompmgr picom compton; do
92
+ command -v "$candidate" >/dev/null 2>&1 || continue
93
+ case "$candidate" in
94
+ xcompmgr) "$candidate" -n >/dev/null 2>&1 & ;;
95
+ *) "$candidate" >/dev/null 2>&1 & ;;
96
+ esac
97
+ compositor_pid=$!
98
+ break
99
+ done
100
+
101
+ # Owning _NET_WM_CM_S0 takes a moment, and a command that reaches the runtime first sees a display
102
+ # with no compositing manager and gets the refusal. The same quarter second the runner's TypeScript
103
+ # path waits, followed by the same liveness check: a compositor that already died is not one we can
104
+ # report as running, and the refusal then names the real state.
105
+ if [ -n "$compositor_pid" ]; then
106
+ sleep 0.25
107
+ if ! kill -0 "$compositor_pid" 2>/dev/null; then
108
+ wait "$compositor_pid" 2>/dev/null || true
109
+ compositor_pid=""
110
+ fi
111
+ fi
112
+
66
113
  "$@"
67
114
  status=$?
68
115
  exit "$status"