fix(stl-cad): 재부팅 직후 DISPLAY가 비면 Xwayland를 찾아 OpenSCAD GLX 렌더 — 도면 생성 실패 해소

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
kimandClaude Sonnet 5.5 committed 2026-10-10 11:43:38 +09:00
1 parent ccf462e30d
commit a8fd78fa69
1 file changed
+11 -1
+11 -1
View File
@@ -109,7 +109,17 @@ export function runOpenscad(args: string[], timeoutMs = 60_000): Promise<{ ok: t
return new Promise((resolve) => {
// 헤드리스 서버라 DISPLAY가 없음 — Qt를 offscreen 플랫폼으로 강제해야 렌더가 된다
// (xvfb-run은 설치돼있지 않고, 이 환경변수만으로 충분한 걸 확인함, 2026-09-20).
const env = { ...process.env, QT_QPA_PLATFORM: 'offscreen' };
const env: NodeJS.ProcessEnv = { ...process.env, QT_QPA_PLATFORM: 'offscreen' };
// OpenSCAD 2021 PNG 렌더는 GLX(X 서버)가 필수다. 재부팅 직후 게이트웨이가 GNOME 세션보다 먼저
// 떠서 DISPLAY가 비면 "Can't create OpenGL OffscreenView"로 도면 생성이 전부 실패한다(2026-10-10).
if (!env.DISPLAY) {
try {
const dir = `/run/user/${process.getuid ? process.getuid() : 1000}`;
const auth = fs.readdirSync(dir).filter(f => f.startsWith('.mutter-Xwaylandauth.'))
.map(f => ({ f, t: fs.statSync(path.join(dir, f)).mtimeMs })).sort((a, b) => b.t - a.t)[0];
if (auth && fs.existsSync('/tmp/.X11-unix/X0')) { env.DISPLAY = ':0'; env.XAUTHORITY = path.join(dir, auth.f); }
} catch { /* 세션 없음 — 그대로 시도 */ }
}
const proc = spawn(OPENSCAD_BIN, args, { stdio: ['ignore', 'pipe', 'pipe'], env });
let stderr = '';
proc.stderr?.on('data', (d: Buffer) => { stderr += d.toString('utf8'); if (stderr.length > 4000) stderr = stderr.slice(-4000); });