Comments (11)
Use this dockerfile
FROM node:14.16.0-buster-slim
RUN apt-get update \
&& apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 \
libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \
libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation \
libappindicator1 libnss3 lsb-release xdg-utils wget x11vnc x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic \
x11-apps gnupg procps ffmpeg xvfb \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
#Do something you want here
RUN yarn install
#Create virtual screen with custom resolution and run your app
CMD xvfb-run --server-args="-screen 0 1920x1080x24" node "index.js"
Also send --no-sandbox
options to launch function:
const browser = await launch({
defaultViewport: {
width: 1920,
height: 1080
},
args: ['--no-sandbox']
});
from puppeteer-stream.
so this library is not working in docker at all or there is some specific scenario for this? Also can someone send the working docker file.
from puppeteer-stream.
I am using the latest version of this library in docker without issues (except super high CPU from chrome processes - which I am still trying to resolve).
Maybe you're launching chromium instead of chrome?
I have to explicitly usegoogle-chrome
in the launch options.await launch({ executablePath: 'google-chrome', //... your other options });Since you don't need chromium, you can set
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
in your Dockerfile so that it's not installed when installing puppeteer.
It should not matter,but for some reason,chromium didn't work in my case. Chrome did.Hey @nivhsay . Would you be able to give an example of how your Dockerfile looks like?
@shokymk, nothing special in the Dockerfile.
I had to omit proprietary things from it but nothing that should affect the use of this package.
FROM node:18.16-buster
RUN apt-get update \
&& apt-get install -y xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 \
libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \
libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation \
libappindicator1 libnss3 lsb-release xdg-utils x11vnc x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic \
x11-apps gnupg procps libpcre3 libpcre3-dev zlib1g-dev \
fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf fonts-noto-color-emoji \
libgbm1 libu2f-udev libvulkan1 libxss1 --no-install-recommends
COPY ./google-chrome/stable-114.deb /tmp/google-chrome.deb
RUN dpkg -i /tmp/google-chrome.deb
RUN rm /tmp/google-chrome.deb
RUN rm -rf /var/lib/apt/lists/*
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENTRYPOINT ["yarn", "start:prod"]
from puppeteer-stream.
Ok thank you for your bug report I’ll have a look
from puppeteer-stream.
It seems like I can't reproduce the issue, apparently chrome in docker can't capture tabs?
from puppeteer-stream.
I am using the latest version of this library in docker without issues (except super high CPU from chrome processes - which I am still trying to resolve).
Maybe you're launching chromium instead of chrome?
I have to explicitly use google-chrome
in the launch options.
await launch({
executablePath: 'google-chrome',
//... your other options
});
Since you don't need chromium, you can set ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
in your Dockerfile so that it's not installed when installing puppeteer.
It should not matter,but for some reason,chromium didn't work in my case. Chrome did.
from puppeteer-stream.
I am using the latest version of this library in docker without issues (except super high CPU from chrome processes - which I am still trying to resolve).
Maybe you're launching chromium instead of chrome?
I have to explicitly use
google-chrome
in the launch options.await launch({ executablePath: 'google-chrome', //... your other options });Since you don't need chromium, you can set
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
in your Dockerfile so that it's not installed when installing puppeteer.It should not matter,but for some reason,chromium didn't work in my case. Chrome did.
Hey @nivhsay . Would you be able to give an example of how your Dockerfile looks like?
from puppeteer-stream.
Hi @nivhsay Have you been able to identify how to reduce the CPU usage?
from puppeteer-stream.
Hi @nivhsay Have you been able to identify how to reduce the CPU usage?
@yashkhandelwal05, probably the usage of GPUs with the container.
Without GPU, all recording/transcoding is done on the CPU.
Did not try it yet.
from puppeteer-stream.
It looks like you're encountering an "UnhandledPromiseRejectionWarning" in a Node.js application that uses Puppeteer, a library for controlling headless Chrome or Chromium browsers. The warning message indicates that a promise was rejected but not properly handled.
The specific error message you provided, "TypeError: Cannot read property 'capture' of undefined," suggests that there's an issue with the code trying to access the 'capture' property of an undefined object.
Here's what you can do to address this issue:
Check Your Code: Look at the line number mentioned in the error message (line 27 of background.js in the extension). Check if you are trying to access the 'capture' property of an object that might be undefined. Make sure that you're initializing and using the object correctly.
Error Handling: Wrap the problematic part of your code in a try-catch block to handle any errors that might occur during the promise execution. This will prevent unhandled promise rejections and help you capture and handle errors gracefully.
try {
// Your code that might be causing the error
} catch (error) {
console.error("An error occurred:", error);
}
Promise Rejection Handling: If you're using asynchronous operations that return promises (like Puppeteer functions), make sure you're using await with them and handling promise rejections with try-catch or .catch() to avoid unhandled promise rejections.
try {
const result = await someAsyncFunction();
// Handle the result
} catch (error) {
console.error("An error occurred:", error);
}
Deprecation Warning: The warning message also mentions that unhandled promise rejections are deprecated, and they could terminate the Node.js process in the future. To prevent this, make sure you handle all promise rejections properly using the methods mentioned above.
Update Dependencies: Sometimes, these issues could be due to bugs in older versions of libraries. Make sure you're using the latest versions of Puppeteer and other relevant dependencies.
If you're still facing issues after trying these steps, it might help to provide more context or code snippets related to the error so that I can offer more specific assistance.
from puppeteer-stream.
I'm not sure if this is still an issue here, but to me it worked flawlessly. Here is my Dockerfile:
FROM node:20.11.0
RUN apt update && apt install -y chromium xvfb
RUN npm i -g typescript
WORKDIR /app
# we first copy the package.json file, so if that doesn't change
# there's no need to run "npm i" every single time we build
# the container
COPY package.json .
COPY package-lock.json .
RUN npm i
# eventually, everything else
COPY . .
RUN tsc
CMD xvfb-run --server-args="-screen 0 1024x768x24" node src
And here the code to make it work:
import puppeteer from 'puppeteer';
import { launch as launchBrowser, getStream as getPuppeteerStream } from 'puppeteer-stream';
import { Browser, Page } from 'puppeteer-stream/node_modules/puppeteer-core';
// ...
// initialize the browser
let browser: Browser;
(async () => {
browser = await launchBrowser({
defaultViewport: {
width: 1920,
height: 1080,
},
headless: false,
executablePath: puppeteer.executablePath(),
args: ['--no-sandbox'],
});
})();
// ...
from puppeteer-stream.
Related Issues (20)
- Chrome 115 issues? HOT 2
- What parameters should I configure to improve my video?
- Shutdown is taking more than 5 seconds HOT 7
- [QUESTION] How can I record only part of a page? HOT 1
- Allow configuring websocket port
- Recorder giving empty file
- Recorder giving an empty video file
- A solution for non-seekable video files. HOT 1
- Electron build fails to access stream extension workaround
- Want to run two recordings simultaneously HOT 4
- Advice for taking the last 10s of audio without FFMPEG or re-encoding HOT 1
- Option to specify the websocket port
- Using FFMPEG give an error HOT 1
- Close browser causes Protocol error HOT 6
- Wrong resolution in FFMPEG from the Pipe HOT 1
- Process hangs after recording finished
- Are transparent videos possible?
- videoConstraints Not works HOT 3
- [feature request] streaming part of the webpage
- Use it with an existing HTTP server.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from puppeteer-stream.