我正在尝试在没有GPU的Linux服务器上导出使用WebGL渲染的图像.要做到这一点,我使用无头Chrome,但导出的图像是黑色的(例如导出的图像,截取页面的截图显示其只是黑色的画布).我希望得到一些帮助,弄清楚为什么会这样.
要导出图像,我将图像渲染到画布,通过导出数据canvas.toDataURL('image/jpeg'),然后将数据发布到服务器.我正在使用Pixi.js进行渲染,如果我使用canvas渲染器,那么一切都可以在服务器上运行; 它的WebGL渲染不起作用.值得注意的是,WebGL渲染在Macbook上的Chrome 63中运行良好.
控制Chrome我正在使用Puppeteer.我正在做的就是打开一个页面,等待一秒钟,然后再次关闭它:
puppeteer
.launch({
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
],
})
.then(browser => {
return browser.newPage().then(page => {
return page
.goto(url)
.then(() => page.waitFor(1000))
.then(() => browser.close())
.catch(err => console.error('Failed', err));
});
})
Run Code Online (Sandbox Code Playgroud)
这些是puppeteer传递给Chrome的参数:
[
'--disable-background-networking',
'--disable-background-timer-throttling',
'--disable-client-side-phishing-detection',
'--disable-default-apps',
'--disable-extensions',
'--disable-hang-monitor',
'--disable-popup-blocking',
'--disable-prompt-on-repost',
'--disable-sync',
'--disable-translate',
'--metrics-recording-only',
'--no-first-run',
'--remote-debugging-port=0',
'--safebrowsing-disable-auto-update',
'--enable-automation',
'--password-store=basic',
'--use-mock-keychain',
'--user-data-dir=/tmp/puppeteer_dev_profile-GhEAXZ',
'--headless',
'--disable-gpu',
'--hide-scrollbars',
'--mute-audio',
'--no-sandbox',
'--disable-setuid-sandbox'
]
Run Code Online (Sandbox Code Playgroud)
该作者在6月份表示无头WebGL渲染是可能的,而且这个Chromium问题似乎证实了这一点,所以我想我错过了一些东西.有没有人有任何想法我做错了什么?
我尝试了几件事:
--use-gl=swiftshader-webgl …