Skip to content

Commit

Permalink
Added more optimization to puppeteer instances
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohamedin committed Mar 8, 2024
1 parent ba2b4f3 commit c7c56aa
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions export.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,45 @@ if (!NO_CLUSTER && cluster.isMaster)
}
else
{
const minimal_args = [
'--disable-gpu',
'--autoplay-policy=user-gesture-required',
'--disable-background-networking',
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows',
'--disable-breakpad',
'--disable-client-side-phishing-detection',
'--disable-component-update',
'--disable-default-apps',
'--disable-dev-shm-usage',
'--disable-domain-reliability',
'--disable-extensions',
'--disable-features=AudioServiceOutOfProcess',
'--disable-hang-monitor',
'--disable-ipc-flooding-protection',
'--disable-notifications',
'--disable-offer-store-unmasked-wallet-cards',
'--disable-popup-blocking',
'--disable-print-preview',
'--disable-prompt-on-repost',
'--disable-renderer-backgrounding',
'--disable-setuid-sandbox',
'--disable-speech-api',
'--disable-sync',
'--hide-scrollbars',
'--ignore-gpu-blacklist',
'--metrics-recording-only',
'--mute-audio',
'--no-default-browser-check',
'--no-first-run',
'--no-pings',
'--no-sandbox',
'--no-zygote',
'--password-store=basic',
'--use-gl=swiftshader',
'--use-mock-keychain',
];

const MAX_AREA = 20000 * 20000;
const PNG_CHUNK_IDAT = 1229209940;
const { JSDOM } = require("jsdom");
Expand Down Expand Up @@ -332,7 +371,8 @@ else
browser = await puppeteer.launch({
headless: 'chrome-headless-shell',
args: ['--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage']
args: minimal_args,
userDataDir: './puppeteer_user_data'
});
// Workaround for timeouts/zombies is to kill after 30 secs
Expand Down Expand Up @@ -510,7 +550,8 @@ else

browser = await puppeteer.launch({
headless: 'chrome-headless-shell',
args: ['--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage']
args: minimal_args,
userDataDir: './puppeteer_user_data'
});

// Workaround for timeouts/zombies is to kill after 30 secs
Expand Down

1 comment on commit c7c56aa

@davidjgraph
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. Reduces CPU load.

Please sign in to comment.