Spaces:
Sleeping
Sleeping
Vedavyas1235 commited on
Commit ·
5bd41fd
1
Parent(s): 448fd43
Dynamically inject --disable-gpu to browser args if no GPU is found
Browse files
index.js
CHANGED
|
@@ -148,18 +148,23 @@ app.post('/api/render', async (req, res) => {
|
|
| 148 |
async function renderFrameChunk(workerId, startFrame, endFrame) {
|
| 149 |
let browser;
|
| 150 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
browser = await puppeteer.launch({
|
| 152 |
executablePath: process.env.PUPPETEER_EXECUTABLE_PATH || undefined,
|
| 153 |
headless: 'new',
|
| 154 |
protocolTimeout: 3600000,
|
| 155 |
-
args:
|
| 156 |
-
'--no-sandbox',
|
| 157 |
-
'--disable-setuid-sandbox',
|
| 158 |
-
'--disable-dev-shm-usage',
|
| 159 |
-
'--disable-web-security',
|
| 160 |
-
'--disable-features=IsolateOrigins,site-per-process',
|
| 161 |
-
'--js-flags="--max-old-space-size=4096"'
|
| 162 |
-
]
|
| 163 |
});
|
| 164 |
const page = await browser.newPage();
|
| 165 |
await page.setViewport({ width, height, deviceScaleFactor: finalScale });
|
|
|
|
| 148 |
async function renderFrameChunk(workerId, startFrame, endFrame) {
|
| 149 |
let browser;
|
| 150 |
try {
|
| 151 |
+
const puppeteerArgs = [
|
| 152 |
+
'--no-sandbox',
|
| 153 |
+
'--disable-setuid-sandbox',
|
| 154 |
+
'--disable-dev-shm-usage',
|
| 155 |
+
'--disable-web-security',
|
| 156 |
+
'--disable-features=IsolateOrigins,site-per-process',
|
| 157 |
+
'--js-flags="--max-old-space-size=4096"'
|
| 158 |
+
];
|
| 159 |
+
if (!SERVER_HAS_GPU) {
|
| 160 |
+
puppeteerArgs.push('--disable-gpu');
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
browser = await puppeteer.launch({
|
| 164 |
executablePath: process.env.PUPPETEER_EXECUTABLE_PATH || undefined,
|
| 165 |
headless: 'new',
|
| 166 |
protocolTimeout: 3600000,
|
| 167 |
+
args: puppeteerArgs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
});
|
| 169 |
const page = await browser.newPage();
|
| 170 |
await page.setViewport({ width, height, deviceScaleFactor: finalScale });
|