octaltree / playwright-rust

Playwright port to Rust
298 stars 31 forks source link

Startup error with Firefox #39

Open lune-stone opened 1 year ago

lune-stone commented 1 year ago

I'm not sure of what changed to introduce this issue, and it may just be my own box.

Firefox started throwing this error on startup: "Gah. Your tab just crashed." The same code was working this last week.

Error: ErrorResponded(ErrorMessage { name: "Error", message: "Page closed", stack: "Error: Page closed\n    at FFSession.<anonymous> (/home/user/.cache/ms-playwright/playwright-rust/driver/package/lib/server/firefox/ffPage.js:97:31)\n    at Object.onceWrapper (events.js:420:28)\n    at FFSession.emit (events.js:314:20)\n    at /home/user/.cache/ms-playwright/playwright-rust/driver/package/lib/server/firefox/ffConnection.js:175:43" })

playwright-rust: 0.0.20 playwright binary: ms-playwright/firefox-1250 firefox: 89.0b6 os: arch linux

Chromium appears to work, but sadly is not an option for my use case.

I've tried deleting the playwright cache and re-downloading but the issue remains.

When I tried the dev branch it failed with Error: Arc(Serde(Error("missing field `utils`", line: 0, column: 0))).

lune-stone commented 1 year ago

I switched to java to see if the issue was present there as well. Using com.microsoft.playwright:playwright:1.11.0 which packages the same firefox-1250 I also get the same error:

Exception in thread "main" com.microsoft.playwright.PlaywrightException: Error {
  message='Page closed
  name='Error
  stack='Error: Page closed
    at FFSession.<anonymous> (/tmp/playwright-java-7927751948996216760/package/lib/server/firefox/ffPage.js:97:31)
    at Object.onceWrapper (events.js:420:28)
    at FFSession.emit (events.js:314:20)
    at /tmp/playwright-java-7927751948996216760/package/lib/server/firefox/ffConnection.js:175:43
}
    at com.microsoft.playwright.impl.WaitableResult.get(WaitableResult.java:54)
    ...
    at com.microsoft.playwright.impl.BrowserImpl.newPage(BrowserImpl.java:180)
    at com.microsoft.playwright.Browser.newPage(Browser.java:617)
    at org.example.Main.main(Main.java:10)

Updating to 1.14.0/firefox-1281 or higher gets past the error. So it is likely this will be resolved when the dev branch gets merged.

octaltree commented 1 year ago

master and dev branches are not compatible. The dev branch is in active development, so please use the one released as 0.0.20.

I want to know what it means firefox-1250 doesn't work with java client, please try here.

rm -r /tmp/build-playwright-rust ~/.cache/ms-playwright/playwright-rust/driver
git clone https://github.com/octaltree/playwright-rust
cd playwright-rust
make test

Also, any minimal code that doesn't work is welcome.

lune-stone commented 1 year ago

output from make test (after removing tmp & cloning)

running 7 tests
test chromium_selectors ... ok
test firefox_devices ... ok
test connect_over_cdp ... ok
test firefox_selectors ... FAILED
test chromium_devices ... ok
test firefox_page ... FAILED
test chromium_page ... ok

failures:

---- firefox_selectors stdout ----
thread 'firefox_selectors' panicked at 'called `Result::unwrap()` on an `Err` value: ErrorResponded(ErrorMessage { name: "Error", message: "Page closed", stack: "Error: Page closed\n    at FFSession.<anonymous> (/home/user/.cache/ms-playwright/playwright-rust/driver/package/lib/server/firefox/ffPage.js:97:31)\n    at Object.onceWrapper (events.js:420:28)\n    at FFSession.emit (events.js:314:20)\n    at /home/user/.cache/ms-playwright/playwright-rust/driver/package/lib/server/firefox/ffConnection.js:175:43" })', tests/selectors/mod.rs:30:36
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- firefox_page stdout ----
[tests/browser/mod.rs:41] &version = "89.0b6"
thread 'firefox_page' panicked at 'called `Result::unwrap()` on an `Err` value: ErrorResponded(ErrorMessage { name: "Error", message: "Page closed\n=========================== logs ===========================\n<launching> /home/user/.cache/ms-playwright/firefox-1250/firefox/firefox -no-remote -headless -profile ./target -juggler-pipe about:blank\n<launched> pid=18449\n[pid=18449][err] *** You are running in headless mode.\n[pid=18449][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libEGL initialize failed (t=0.164924) [GFX1-]: glxtest: libEGL initialize failed\n[pid=18449][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libEGL initialize failed (t=0.164924) |[1][GFX1-]: glxtest: X error, error_code=8, request_code=150, minor_code=5 (t=0.16496) [GFX1-]: glxtest: X error, error_code=8, request_code=150, minor_code=5\n[pid=18449][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libEGL initialize failed (t=0.164924) |[1][GFX1-]: glxtest: X error, error_code=8, request_code=150, minor_code=5 (t=0.16496) |[2][GFX1-]: glxtest: process failed (exited with status 1) (t=0.164998) [GFX1-]: glxtest: process failed (exited with status 1)\n[pid=18449][out] \n[pid=18449][out] Juggler listening to the pipe\n============================================================\nNote: use DEBUG=pw:api environment variable to capture Playwright logs.", stack: "Error: Page closed\n=========================== logs ===========================\n<launching> /home/user/.cache/ms-playwright/firefox-1250/firefox/firefox -no-remote -headless -profile ./target -juggler-pipe about:blank\n<launched> pid=18449\n[pid=18449][err] *** You are running in headless mode.\n[pid=18449][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libEGL initialize failed (t=0.164924) [GFX1-]: glxtest: libEGL initialize failed\n[pid=18449][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libEGL initialize failed (t=0.164924) |[1][GFX1-]: glxtest: X error, error_code=8, request_code=150, minor_code=5 (t=0.16496) [GFX1-]: glxtest: X error, error_code=8, request_code=150, minor_code=5\n[pid=18449][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libEGL initialize failed (t=0.164924) |[1][GFX1-]: glxtest: X error, error_code=8, request_code=150, minor_code=5 (t=0.16496) |[2][GFX1-]: glxtest: process failed (exited with status 1) (t=0.164998) [GFX1-]: glxtest: process failed (exited with status 1)\n[pid=18449][out] \n[pid=18449][out] Juggler listening to the pipe\n============================================================\nNote: use DEBUG=pw:api environment variable to capture Playwright logs.\n    at FFSession.<anonymous> (/home/user/.cache/ms-playwright/playwright-rust/driver/package/lib/server/firefox/ffPage.js:97:31)\n    at Object.onceWrapper (events.js:420:28)\n    at FFSession.emit (events.js:314:20)\n    at /home/user/.cache/ms-playwright/playwright-rust/driver/package/lib/server/firefox/ffConnection.js:175:43" })', tests/browser_context/mod.rs:74:10

failures:
    firefox_page
    firefox_selectors

test result: FAILED. 5 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 5.87s

error: test failed, to rerun pass `--test test`
make: *** [Makefile:23: test] Error 101

The code I've been testing with is

$ cat src/main.rs 
use playwright::Playwright;

#[tokio::main]
async fn main() -> Result<(), playwright::Error> {
    let playwright = Playwright::initialize().await?;
    playwright.prepare()?;
    let firefox = playwright.firefox();
    let browser = firefox.launcher().headless(false).launch().await?;
    let context = browser.context_builder().build().await?;
    let page = context.new_page().await?;
    page.goto_builder("http://playwright.dev").goto().await?;
    let title: String = page.title().await?;
    println!("{}", title);
    Ok(())
}

I want to know what it means firefox-1250 doesn't work with java client

firefox-1250 is the version that 0.0.20 uses as seen by

$ ls ~/.cache/ms-playwright/ | grep firefox
firefox-1250

I wanted to know if this issue was part of this rust port, or a general issue with firefox-1250 so I wrote the same test code using playwright-java

import com.microsoft.playwright.*;

public class Main {
    public static void main(String[] args) {
        try (Playwright playwright = Playwright.create()) {
            Browser browser = playwright.firefox().launch(new BrowserType.LaunchOptions().setHeadless(false));
            Page page = browser.newPage();
            page.navigate("http://playwright.dev");
            System.out.println(page.title());
        }
    }
}

and when using an older playwright-java version (1.11.0) that matches the firefox version (firefox-1250) the same issue occurs (see my previous comment for output), but with newer version (playwright-java & firefox) the issue goes away. This leads me to believe that once playwright-rust updates the dependency it will start working again. I would also guess that this issue is specific to my own os setup, but I haven't tried to confirm that.

lune-stone commented 1 year ago

I tested this again with the 1.25 branch and it worked without issues this time. I'm aware it's a work in progress, but at least it gives me a work around without having to write a replacement myself.