mirror of
https://github.com/webrecorder/browsertrix-crawler.git
synced 2025-10-19 14:33:17 +00:00
Remove DISPLAY env var from image (#625)
To avoid a strange chromium bug: https://issues.chromium.org/issues/40209037 which causes WebGL to fail in headless mode if DISPLAY if set. Instead, just set DISPLAY directly for Xvfb, x11vnc and pass in `--display=` to browser if running in headful mode.
This commit is contained in:
parent
92ad800fe4
commit
2ab58c0ea3
5 changed files with 13 additions and 6 deletions
|
@ -6,8 +6,7 @@ FROM ${BROWSER_IMAGE_BASE}
|
||||||
# needed to add args to main build stage
|
# needed to add args to main build stage
|
||||||
ARG BROWSER_VERSION
|
ARG BROWSER_VERSION
|
||||||
|
|
||||||
ENV DISPLAY=:99 \
|
ENV GEOMETRY=1360x1020x16 \
|
||||||
GEOMETRY=1360x1020x16 \
|
|
||||||
BROWSER_VERSION=${BROWSER_VERSION} \
|
BROWSER_VERSION=${BROWSER_VERSION} \
|
||||||
BROWSER_BIN=google-chrome \
|
BROWSER_BIN=google-chrome \
|
||||||
OPENSSL_CONF=/app/openssl.conf \
|
OPENSSL_CONF=/app/openssl.conf \
|
||||||
|
|
|
@ -45,6 +45,7 @@ import {
|
||||||
ADD_LINK_FUNC,
|
ADD_LINK_FUNC,
|
||||||
BEHAVIOR_LOG_FUNC,
|
BEHAVIOR_LOG_FUNC,
|
||||||
DEFAULT_SELECTORS,
|
DEFAULT_SELECTORS,
|
||||||
|
DISPLAY,
|
||||||
} from "./util/constants.js";
|
} from "./util/constants.js";
|
||||||
|
|
||||||
import { AdBlockRules, BlockRules } from "./util/blockrules.js";
|
import { AdBlockRules, BlockRules } from "./util/blockrules.js";
|
||||||
|
@ -508,7 +509,7 @@ export class Crawler {
|
||||||
child_process.spawn(
|
child_process.spawn(
|
||||||
"Xvfb",
|
"Xvfb",
|
||||||
[
|
[
|
||||||
process.env.DISPLAY || "",
|
DISPLAY,
|
||||||
"-listen",
|
"-listen",
|
||||||
"tcp",
|
"tcp",
|
||||||
"-screen",
|
"-screen",
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { Browser } from "./util/browser.js";
|
||||||
import { initStorage } from "./util/storage.js";
|
import { initStorage } from "./util/storage.js";
|
||||||
import { CDPSession, Page, PuppeteerLifeCycleEvent } from "puppeteer-core";
|
import { CDPSession, Page, PuppeteerLifeCycleEvent } from "puppeteer-core";
|
||||||
import { getInfoString } from "./util/file_reader.js";
|
import { getInfoString } from "./util/file_reader.js";
|
||||||
|
import { DISPLAY } from "./util/constants.js";
|
||||||
|
|
||||||
const profileHTML = fs.readFileSync(
|
const profileHTML = fs.readFileSync(
|
||||||
new URL("../html/createProfile.html", import.meta.url),
|
new URL("../html/createProfile.html", import.meta.url),
|
||||||
|
@ -143,7 +144,7 @@ async function main() {
|
||||||
if (!params.headless) {
|
if (!params.headless) {
|
||||||
logger.debug("Launching XVFB");
|
logger.debug("Launching XVFB");
|
||||||
child_process.spawn("Xvfb", [
|
child_process.spawn("Xvfb", [
|
||||||
process.env.DISPLAY || "",
|
DISPLAY,
|
||||||
"-listen",
|
"-listen",
|
||||||
"tcp",
|
"tcp",
|
||||||
"-screen",
|
"-screen",
|
||||||
|
@ -169,7 +170,7 @@ async function main() {
|
||||||
"-passwd",
|
"-passwd",
|
||||||
process.env.VNC_PASS || "",
|
process.env.VNC_PASS || "",
|
||||||
"-display",
|
"-display",
|
||||||
process.env.DISPLAY || "",
|
DISPLAY,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import path from "path";
|
||||||
import { LogContext, logger } from "./logger.js";
|
import { LogContext, logger } from "./logger.js";
|
||||||
import { initStorage } from "./storage.js";
|
import { initStorage } from "./storage.js";
|
||||||
|
|
||||||
import type { ServiceWorkerOpt } from "./constants.js";
|
import { DISPLAY, type ServiceWorkerOpt } from "./constants.js";
|
||||||
|
|
||||||
import puppeteer, {
|
import puppeteer, {
|
||||||
Frame,
|
Frame,
|
||||||
|
@ -93,6 +93,10 @@ export class Browser {
|
||||||
args.push("--disable-site-isolation-trials");
|
args.push("--disable-site-isolation-trials");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!headless) {
|
||||||
|
args.push(`--display=${DISPLAY}`);
|
||||||
|
}
|
||||||
|
|
||||||
let defaultViewport = null;
|
let defaultViewport = null;
|
||||||
|
|
||||||
if (process.env.GEOMETRY) {
|
if (process.env.GEOMETRY) {
|
||||||
|
|
|
@ -33,3 +33,5 @@ export const DEFAULT_SELECTORS = [
|
||||||
isAttribute: false,
|
isAttribute: false,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const DISPLAY = ":99";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue