playwright-java
playwright-java copied to clipboard
newPage on Firefox
Hello, I am new to playwright and i am trying the following simple example:
public class MozillaHeadlessExample {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.firefox().launch();
BrowserContext context = browser.newContext();
Page page = context.newPage();
System.out.println("Done!");
}
}
}
The code above is "stuck" at context.newPage(); and the print line is never executed.
I 've tried running the test on headless mode with the same results.
A similar code using chromium() instead of firefox() is working properly.
I am using: java 8 playwright 1.23.0 Windows 10
Can you run with set PWDEBUG=1
environment variable and see if there are any obvious errors in the log?
Nothing seems to happen.
A playwright inspector pops up but it remains "stuck" at newPage (screenshot attached).
Nothing displayed on the eclipse's console either.
Nothing displayed on the eclipse's console either.
The env variable is probably not set correctly, otherwise you should see some debug output since the browser did start. Try running from console outside of eclipse.
Ok so i compiled and run through CMD with the env variable set at windows environment variables.
I have the same results:
The debug output should be displayed even if no errors occur?
I'm sorry don't know why I suggested PWDEBUG, I meant running the test with set DEBUG=pw:browser
, it should dump the browser error log.
Ok so i got the following log:
2022-07-28T11:27:08.360Z pw:browser <launching> C:\Users\theodorakakosp\AppData\Local\ms-playwright\firefox-1327\firefox\firefox.exe -no-remote -wait-for-browser -foreground -profile C:\Users\THEODO1\AppData\Local\Temp\playwright_firefoxdev_profile-RzZmUu -juggler-pipe -silent
2022-07-28T11:27:08.366Z pw:browser <launched> pid=12832
2022-07-28T11:27:08.901Z pw:browser [pid=12832][out]
2022-07-28T11:27:08.901Z pw:browser [pid=12832][out] Juggler listening to the pipe
2022-07-28T11:27:09.035Z pw:browser [pid=12832][out] console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at C:\\Users\\THEODO1\\AppData\\Local\\Temp\\playwright_firefoxdev_profile-RzZmUu\\search.json.mozlz4", (void 0)))
2022-07-28T11:27:09.126Z pw:browser [pid=12832][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: DCLayerTree(no device) (t=7.22381) [GFX1-]: DCLayerTree(no device)
2022-07-28T11:27:09.126Z pw:browser [pid=12832][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: DCLayerTree(no device) (t=7.22381) |[1][GFX1-]: Failed to connect WebRenderBridgeChild. (t=7.22381) [GFX1-]: Failed to connect WebRenderBridgeChild.
2022-07-28T11:27:09.127Z pw:browser [pid=12832][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: DCLayerTree(no device) (t=7.22381) |[1][GFX1-]: Failed to connect WebRenderBridgeChild. (t=7.22381) |[2][GFX1-]: Fallback WR to SW-WR + D3D11 (t=7.22381) [GFX1-]: Fallback WR to SW-WR + D3D11
2022-07-28T11:27:10.037Z pw:browser <launching> C:\Users\theodorakakosp\AppData\Local\ms-playwright\chromium-1012\chrome-win\chrome.exe --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --no-sandbox --app=data:text/html, --window-size=600,600 --window-position=1020,10 --test-type= --user-data-dir=C:\Users\THEODO~1\AppData\Local\Temp\playwright_chromiumdev_profile-iBjlWa --remote-debugging-pipe about:blank
2022-07-28T11:27:10.045Z pw:browser <launched> pid=22184
2022-07-28T11:27:10.161Z pw:browser [pid=22184][err] C:\Users\theodorakakosp\AppData\Local\ms-playwright\chromium-1012\chrome-win\chrome.exe: invalid option -- `-u'
2022-07-28T11:27:10.161Z pw:browser [pid=22184][err] Try 'chrome.exe --help' for more information.
2022-07-28T11:27:10.220Z pw:browser [pid=22184][err] [0728/142710.222:ERROR:registration_protocol_win.cc(135)] TransactNamedPipe: The pipe has been ended. (0x6D)
2022-07-28T11:27:12.721Z pw:browser [pid=22184][err] [22184:11792:0728/142712.724:ERROR:device_event_log_impl.cc(214)] [14:27:12.724] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
2022-07-28T11:27:12.722Z pw:browser [pid=22184][err] [22184:11792:0728/142712.725:ERROR:device_event_log_impl.cc(214)] [14:27:12.725] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
The error log indicates that you are launching two browsers, the second one is chrome which is the one used for inspector UI. Can you run without inspector so that only firefox is launched and see if the problem persists.
The code above is "stuck" at context.newPage(); and the print line is never executed.
It might be that the firefox launch is hanging, we've such problem in the past and there were a few patches addressing it. Can you run with DEBUG=pw:api
or record a trace to help us understand which line is actually failing?
I removed the inspector UI option and retried with the DEBUG=pw:browser
, i had the following log:
2022-08-03T13:09:01.672Z pw:browser
I also tried the DEBUG=pw:api
and had the following:
2022-08-03T13:07:55.399Z pw:api => BrowserType.launch started 2022-08-03T13:07:57.569Z pw:api <= BrowserType.launch succeeded 2022-08-03T13:07:57.573Z pw:api => Browser.newContext started 2022-08-03T13:07:57.586Z pw:api <= Browser.newContext succeeded 2022-08-03T13:07:57.590Z pw:api => BrowserContext.newPage started
This doesn't tell us much unfortunately. Does it reproduce in headed mode? Also if you can collect traces with DEBUG=pw:browser,pw:protocol
it might give us some insight.
Can you try running with playwright 1.24.1 and see if it reproduces there? We had some bug fixes around firefox newPage code in the recent release which may be relevant.
Tried with the 1.24.1, didn't make a difference.
Yes the problem occurs in headed mode as well.
Logs with pw:browser
:
2022-08-04T14:16:31.933Z pw:browser
Logs with pw:protocol
:
2022-08-04T14:18:16.153Z pw:protocol SEND ► {"id":1,"method":"Browser.enable","params":{"attachToDefaultContext":false}}
2022-08-04T14:18:16.154Z pw:protocol SEND ► {"id":2,"method":"Browser.getInfo"}
2022-08-04T14:18:16.164Z pw:protocol ◀ RECV {"id":1}
2022-08-04T14:18:16.164Z pw:protocol ◀ RECV {"id":2,"result":{"version":"Firefox/102.0","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0"}}
2022-08-04T14:18:16.174Z pw:protocol SEND ► {"id":3,"method":"Browser.createBrowserContext","params":{"removeOnDetach":true}}
2022-08-04T14:18:16.187Z pw:protocol ◀ RECV {"id":3,"result":{"browserContextId":"f3d96683-9e03-42be-bad5-2f717ff1750a"}}
2022-08-04T14:18:16.189Z pw:protocol SEND ► {"id":4,"method":"Browser.setDownloadOptions","params":{"browserContextId":"f3d96683-9e03-42be-bad5-2f717ff1750a","downloadOptions":{"behavior":"saveToDisk","downloadsDir":"C:\Users\THEODO1\AppData\Local\Temp\playwright-artifacts-hYTJqE"}}}
2022-08-04T14:18:16.189Z pw:protocol SEND ► {"id":5,"method":"Browser.setDefaultViewport","params":{"browserContextId":"f3d96683-9e03-42be-bad5-2f717ff1750a","viewport":{"viewportSize":{"width":1280,"height":720},"deviceScaleFactor":1}}}
2022-08-04T14:18:16.189Z pw:protocol SEND ► {"id":6,"method":"Browser.setColorScheme","params":{"browserContextId":"f3d96683-9e03-42be-bad5-2f717ff1750a","colorScheme":"light"}}
2022-08-04T14:18:16.189Z pw:protocol SEND ► {"id":7,"method":"Browser.setReducedMotion","params":{"browserContextId":"f3d96683-9e03-42be-bad5-2f717ff1750a","reducedMotion":"no-preference"}}
2022-08-04T14:18:16.189Z pw:protocol SEND ► {"id":8,"method":"Browser.setForcedColors","params":{"browserContextId":"f3d96683-9e03-42be-bad5-2f717ff1750a","forcedColors":"none"}}
2022-08-04T14:18:16.209Z pw:protocol ◀ RECV {"id":4}
2022-08-04T14:18:16.209Z pw:protocol ◀ RECV {"id":5}
2022-08-04T14:18:16.209Z pw:protocol ◀ RECV {"id":6}
2022-08-04T14:18:16.209Z pw:protocol ◀ RECV {"id":7}
2022-08-04T14:18:16.210Z pw:protocol ◀ RECV {"id":8}
2022-08-04T14:18:16.219Z pw:protocol SEND ► {"id":9,"method":"Browser.newPage","params":{"browserContextId":"f3d96683-9e03-42be-bad5-2f717ff1750a"}}
2022-08-04T14:18:16.686Z pw:protocol ◀ RECV {"method":"Browser.attachedToTarget","params":{"sessionId":"8a46cbea-9329-4a86-9064-3208f6d0c4e7","targetInfo":{"targetId":"b37029db-5bf7-4411-8b1e-c09d37cf4554","type":"page","browserContextId":"f3d96683-9e03-42be-bad5-2f717ff1750a"}}}
2022-08-04T14:18:16.688Z pw:protocol SEND ► {"method":"Page.setInitScripts","params":{"scripts":[{"script":"","worldName":"playwright_utility_world"}]},"id":10,"sessionId":"8a46cbea-9329-4a86-9064-3208f6d0c4e7"}
2022-08-04T14:18:16.856Z pw:protocol ◀ RECV {"id":9,"result":{"targetId":"b37029db-5bf7-4411-8b1e-c09d37cf4554"}}
Thanks for sharing the logs, I wanted to look at the combined logs when running with DEBUG=pw:browser,pw:protocol
to basically see if there are any errors after the newPage
command returns.
Could you try running C:\Users\theodorakakosp\AppData\Local\ms-playwright\firefox-1335\firefox\firefox.exe
without playwright and see if it works at all?
Closing as part of the triage process since it seemed stale. Please create a new issue with a detailed reproducible or feature request if you still face issues.