playwright-python icon indicating copy to clipboard operation
playwright-python copied to clipboard

[BUG] Out of Memory

Open AIPythoner opened this issue 3 years ago • 8 comments

Context:

  • Playwright Version: [1.35.0]
  • Operating System: [Windows10]
  • Python version: [e.g. 3.7 x64]
  • Browser: [Chromium]
  • Extra: [any specific details about your environment]

Describe the bug The "Out of Memory" is displayed in the browser, and the entire program is permanently hung at this time. There is no effect in timeout. The result I expected was to throw a timeout error and refresh the page. like https://github.com/microsoft/playwright-python/issues/1847

Reproduce the condition Not necessarily completely accurate

  1. Windows memory is not much left
  2. Browser pages contain a large number of elements

AIPythoner avatar Jun 21 '23 03:06 AIPythoner

Do you maybe do a lot of repetitive tasks inside your context and don't re-create it over and over again?

Playwright only releases the memory when you close aka. re-create the context what we recommend for end-to-end testing between each test.

Looks like your system ran out of memory, and then Chromium ran out of memory. How much RAM does your computer have?

mxschmitt avatar Jun 21 '23 09:06 mxschmitt

Do you maybe do a lot of repetitive tasks inside your context and don't re-create it over and over again?

Playwright only releases the memory when you close aka. re-create the context what we recommend for end-to-end testing between each test.

Looks like your system ran out of memory, and then Chromium ran out of memory. How much RAM does your computer have?

Thanks for the reply.

  1. I just repeat a lot of repetitive tasks in the same context, closing the page and opening a new page to perform a new task with each task completed
  2. There is about 1-2g of free memory, a total of 12g
  3. When the browser displays "Out of Memory", the whole Python program is suspended and no exception is thrown, can this be avoided?

AIPythoner avatar Jun 25 '23 06:06 AIPythoner

Yeah Playwright is designed for end-to-end testing, there we expect the user to re-create the context over and over again. If you don't re-create, you end up in that, see also https://github.com/microsoft/playwright/issues/6319 for the upstream bug.

So you need to re-create the context, otherwise there are no possible workarounds.

mxschmitt avatar Jun 25 '23 09:06 mxschmitt

Yeah Playwright is designed for end-to-end testing, there we expect the user to re-create the context over and over again. If you don't re-create, you end up in that, see also microsoft/playwright#6319 for the upstream bug.

So you need to re-create the context, otherwise there are no possible workarounds.

I create a context at the beginning of each big task, and if it's a small task contained in a big task, it doesn't create a new context, but a new page. Each small task takes about 3-5 minutes. But none of this matters, the point is that when the browser displays "Out of Memory" appears, the following code never ends page.fill('#username', '[email protected]') # now the browser displays "Out of Memory" print('fill success') # never execute

AIPythoner avatar Jun 25 '23 09:06 AIPythoner

Oh ok, that seems different then. Are you able to share a reproduction with us? Maybe there is a memory leak on the page or inside Playwright. Having a reproduction would be essencial for us to be able to debug that. Thanks!

mxschmitt avatar Jun 25 '23 09:06 mxschmitt

Oh ok, that seems different then. Are you able to share a reproduction with us? Maybe there is a memory leak on the page or inside Playwright. Having a reproduction would be essencial for us to be able to debug that. Thanks!

  1. Open a page with many web elements
  2. Continuously automate this page for up to 5 minutes. for example fill, click, set_input_files, wait_for_selector
  3. During the second step, the software is continuously opened so that the available memory is constantly reduced

AIPythoner avatar Jun 26 '23 02:06 AIPythoner

Do you then close the page and the context after the 5 minutes?

I fear we need a reproduction which we can run locally, since its otherwise more guessing.

mxschmitt avatar Jun 26 '23 12:06 mxschmitt

Closing as per above since we need a reproduction. Please re-file with a reproduction, thanks for your understanding.

mxschmitt avatar Jul 07 '23 22:07 mxschmitt