Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get process of a running browser #315

Open
shobu13 opened this issue Oct 27, 2022 · 3 comments
Open

get process of a running browser #315

shobu13 opened this issue Oct 27, 2022 · 3 comments

Comments

@shobu13
Copy link

shobu13 commented Oct 27, 2022

I need to monitor energy consumption of a browser (for exemple chromium) testing multiples pages of the database. I want to use django to runnings my tests concurently using playwright to automate the browser testing (i've already use it a little using the JS api), but the tool i use to monitor energy consumption watch a cgroup where the runing process of the browser need to be added. For this purpose, i've checked on the internet if it's possible to get the PID of a browser using PW and it's seem possible using

  const browserServer = await playwright.chromium.launchServer()
  const pid = await browserServer.process().pid
  console.log(pid)

https://stackoverflow.com/questions/62376437/get-pid-of-a-browser-launched-with-playwright

But i don't found a way to retrieve this information in playwright-go due to the fact that pw.Chromium don't have a function LauchServer and i've don't found an equivalent.

@Zunaira518
Copy link

Zunaira518 commented May 2, 2024

@mxschmitt Is there any resolution for this?
I'm encountering the same problem where Chrome launches for every API call. Despite using a defer() function on closure for page, context, and browser, it still results in zombie processes that consume all the memory over time. It would be helpful to have a function that returns the process IDs of the browsers started by Playwright, or an alternative solution to manage this issue.

> root@saviynt-inspector-main-43-test-c4b8b5d66-lfzp2:/app# ps -eaf
> UID          PID    PPID  C STIME TTY          TIME CMD
> root           1       0  0 14:09 ?        00:00:05 /app/saviynt-inspector
> root          22       1  0 14:09 ?        00:00:00 /bin/sh /root/.cache/ms-playwright-go/1.40.1/playwright.sh run-driver
> root          25      22  0 14:09 ?        00:01:07 /root/.cache/ms-playwright-go/1.40.1/node /root/.cache/ms-playwright-go/1.40.1/package/lib/cli/cli.js run-driver
> root         105       1  0 14:09 ?        00:00:00 [chrome] <defunct>
> root         106       1  0 14:09 ?        00:00:00 [chrome] <defunct>
> root         239       1  0 14:09 ?        00:00:00 [chrome] <defunct>
> root         240       1  0 14:09 ?        00:00:00 [chrome] <defunct>
> root         377       1  0 14:10 ?        00:00:00 [chrome] <defunct>
> root         378       1  0 14:10 ?        00:00:00 [chrome] <defunct>
> root         509       1  0 14:10 ?        00:00:00 [chrome] <defunct>
> root         510       1  0 14:10 ?        00:00:00 [chrome] <defunct>
> root         642       1  0 14:11 ?        00:00:00 [chrome] <defunct>
> root         643       1  0 14:11 ?        00:00:00 [chrome] <defunct>
> root         772       1  0 14:11 ?        00:00:00 [chrome] <defunct>
> root         773       1  0 14:11 ?        00:00:00 [chrome] <defunct>

@mxschmitt
Copy link
Member

@Zunaira518 are you running inside Docker? Make sure to use --init as per the Docker best practises. This is usually the reason why defunct processes are staying there.

@Zunaira518
Copy link

@mxschmitt Adding --init fixed the issue. Thankyou for quick reply :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants