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

[BUG] FF - launchPersistentContext #3230

Closed
ruslanx3m opened this issue Jul 30, 2020 · 3 comments
Closed

[BUG] FF - launchPersistentContext #3230

ruslanx3m opened this issue Jul 30, 2020 · 3 comments

Comments

@ruslanx3m
Copy link

ruslanx3m commented Jul 30, 2020

Снимок экрана (82)
Context:

  • Playwright Version: [1.2.1]
  • Operating System: [Windows]
  • Node version: [12]
  • Browser: [Firefox]

Codet

const { firefox } = require("playwright");
const path = require("path");
const fs = require("fs-extra");

(async () => {
    const ff_profile = path.join(__dirname, '/profile');
    await fs.ensureDir(ff_profile);

    const browserContext = await firefox.launchPersistentContext(ff_profile, {
        headless: false,     
        viewport: null
    });
    
    const page = await browserContext.newPage();
    await page.goto('http://example.com');

    await page.waitForTimeout(10000);
    await browserContext.close();
})();

Describe the bug

Hi, with Firefox browser, this code is opening 2 browsers window, if I use const page = await browserContext.newPage(), or is opening 1 browser if is use const page = browserContext.pages()[0], but in my case page.close will close browser .. so every opened page is a new Browser ...

.. normal 180MB, but this code use 340MB (await browserContext..pages()[0] vs await browserContext.newPage()) ... why newPage (tab) open new browser window ?

firefox.launchPersistentContext - open 1 browser window (is normal)
browserContext.newPage() - open another browser window (is not normal, must open 1 tab in this browser)

so its memory leak .. but if I open 10 tests or more my pc memory will end

ps: aslushnikov, if you say "Is it purely aesthetics" ... will never use playwright (many bugs and all is 'purely aesthetics' how you like to answer, is bad answer to user feedback).

@pavelfeldman
Copy link
Member

It is not entirely clear what you'd like to see changed. Would you like newPage to open a new tab instead of a new window? could you share more about your testing scenario and on why you'd like to use persistent context?

When you say memory leak, do you mean that you open something, close something and it does not return memory to the OS?

@ruslanx3m
Copy link
Author

My needs is: firefox, use cache ... create 1 browser context, open page - close page, open - close ... but what I have: 1 broser window - just for fun (cant understand what for is) and 1 browser window with my test (page) ... every browser window get get system memory ... so if use browserContext.pages()[0] (open 1 browser window) use 170MB, then browserContext.newPage() take 320MB (1 url loaded) ... so more RAM and more CPU use then is opening 2 browser window instead 1 ... why you not check code to see ... 1 more bug : if I close page with await page.close(}); it will stop at close (promise not resolved)... I only can close page with: await page.close({ runBeforeUnload: true }); .... 1 more bug: then load cookies, if cookie object contain 'expires: -1' -> cookie will not add ... and many more bugs ... I cant finish my test .. every time found a bug ... if I use chromium with persistent context - can not use cache ...

@yury-s
Copy link
Member

yury-s commented Jul 31, 2020

@ruslanx3m Is your concern that each new page creates a new process that would eat up another ~160Mb of RAM?

This is because Playwright enforces separate separate Content process for each Page. We do it for better isolation of the tests in different pages. The same would happen if you open two tabs/windows from different domains in stock Firefox browser - each will have its own content process (in the stock browser though if two pages are from the same origin they will likely share same Content process which would result in smaller browser memory footprint overall). As far as I can tell when Page is closed all its memory is reclaimed as the content process exits, does it match your observations?

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

4 participants