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

newPage on Firefox

Open panostheod opened this issue 2 years ago • 12 comments

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

panostheod avatar Jul 19 '22 20:07 panostheod

Can you run with set PWDEBUG=1 environment variable and see if there are any obvious errors in the log?

yury-s avatar Jul 25 '22 20:07 yury-s

Nothing seems to happen.

A playwright inspector pops up but it remains "stuck" at newPage (screenshot attached).

PWD

Nothing displayed on the eclipse's console either.

panostheod avatar Jul 26 '22 20:07 panostheod

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.

yury-s avatar Jul 26 '22 20:07 yury-s

Ok so i compiled and run through CMD with the env variable set at windows environment variables.

I have the same results:

cmd

The debug output should be displayed even if no errors occur?

panostheod avatar Jul 27 '22 09:07 panostheod

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.

yury-s avatar Jul 27 '22 15:07 yury-s

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)

panostheod avatar Jul 28 '22 11:07 panostheod

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?

yury-s avatar Aug 01 '22 18:08 yury-s

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 C:\Users\theodorakakosp\AppData\Local\ms-playwright\firefox-1327\firefox\firefox.exe -no-remote -headless -profile C:\Users\THEODO1\AppData\Local\Temp\playwright_firefoxdev_profile-Qlbojj -juggler-pipe -silent 2022-08-03T13:09:01.679Z pw:browser pid=25368 2022-08-03T13:09:01.783Z pw:browser [pid=25368][err] *** You are running in headless mode. 2022-08-03T13:09:02.126Z pw:browser [pid=25368][out] 2022-08-03T13:09:02.126Z pw:browser [pid=25368][out] Juggler listening to the pipe 2022-08-03T13:09:02.249Z pw:browser [pid=25368][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-Qlbojj\search.json.mozlz4", (void 0))) 2022-08-03T13:09:02.349Z pw:browser [pid=25368][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt (t=6.30887) [GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt 2022-08-03T13:09:07.261Z pw:browser [pid=25368][out] console.error: Region.jsm: "Error fetching region" (new Error("TIMEOUT", "resource://gre/modules/Region.jsm", 772)) 2022-08-03T13:09:07.261Z pw:browser [pid=25368][out] console.error: Region.jsm: "Failed to fetch region" (new Error("TIMEOUT", "resource://gre/modules/Region.jsm", 419)) 2022-08-03T13:09:24.247Z pw:browser [pid=25368][out] console.warn: TopSitesFeed: Failed to fetch data from Contile server: NetworkError when attempting to fetch resource.

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

panostheod avatar Aug 03 '22 13:08 panostheod

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.

yury-s avatar Aug 03 '22 16:08 yury-s

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.

yury-s avatar Aug 03 '22 18:08 yury-s

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 C:\Users\theodorakakosp\AppData\Local\ms-playwright\firefox-1335\firefox\firefox.exe -no-remote -headless -profile C:\Users\THEODO~1\AppData\Local\Temp\playwright_firefoxdev_profile-Vn45V9 -juggler-pipe -silent 2022-08-04T14:16:31.940Z pw:browser pid=1564 2022-08-04T14:16:32.068Z pw:browser [pid=1564][err] *** You are running in headless mode. 2022-08-04T14:16:32.471Z pw:browser [pid=1564][out] 2022-08-04T14:16:32.471Z pw:browser [pid=1564][out] Juggler listening to the pipe 2022-08-04T14:16:32.652Z pw:browser [pid=1564][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt (t=6.5781) [GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt 2022-08-04T14:16:33.199Z pw:browser [pid=1564][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-Vn45V9\search.json.mozlz4", (void 0))) 2022-08-04T14:16:33.254Z pw:browser [pid=1564][out] console.error: SearchEngineSelector: "Received empty search configuration!" 2022-08-04T14:16:33.288Z pw:browser [pid=1564][out] console.error: SearchEngineSelector: "Received empty search configuration!" 2022-08-04T14:16:33.289Z pw:browser [pid=1564][out] console.error: SearchService: "_init: failure initializing search:" ({}) 2022-08-04T14:16:33.312Z pw:browser [pid=1564][err] JavaScript error: , line 0: uncaught exception: 2147549183 2022-08-04T14:16:33.312Z pw:browser [pid=1564][err] JavaScript error: , line 0: uncaught exception: 2147549183 2022-08-04T14:16:33.312Z pw:browser [pid=1564][err] JavaScript error: , line 0: uncaught exception: 2147549183 2022-08-04T14:16:33.312Z pw:browser [pid=1564][err] JavaScript error: , line 0: uncaught exception: 2147549183 2022-08-04T14:16:33.313Z pw:browser [pid=1564][err] JavaScript error: resource://gre/modules/SearchService.jsm, line 196: NS_ERROR_UNEXPECTED: SearchService previously failed to initialize 2022-08-04T14:16:33.328Z pw:browser [pid=1564][err] JavaScript error: , line 0: uncaught exception: 2147549183 2022-08-04T14:16:33.333Z pw:browser [pid=1564][err] JavaScript error: , line 0: uncaught exception: 2147549183 2022-08-04T14:16:33.676Z pw:browser [pid=1564][out] console.error: SearchSettings: "_write: Could not write to settings file:" (new Error("cannot write without any engine.", "resource://gre/modules/SearchSettings.jsm", 216)) 2022-08-04T14:16:33.677Z pw:browser [pid=1564][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-Vn45V9\search.json.mozlz4", (void 0))) 2022-08-04T14:16:33.677Z pw:browser [pid=1564][out] console.error: SearchService: "maybeReloadEngines failed" (new TypeError("defaultEngine is undefined", "resource://gre/modules/SearchService.jsm", 1203)) 2022-08-04T14:16:33.678Z pw:browser [pid=1564][err] JavaScript error: , line 0: uncaught exception: 2147549183 2022-08-04T14:16:33.682Z pw:browser [pid=1564][err] JavaScript error: , line 0: uncaught exception: 2147549183 2022-08-04T14:16:33.799Z pw:browser [pid=1564][err] JavaScript error: , line 0: uncaught exception: 2147549183 2022-08-04T14:16:34.684Z pw:browser [pid=1564][out] console.error: SearchSettings: "_write: Could not write to settings file:" (new Error("cannot write without any engine.", "resource://gre/modules/SearchSettings.jsm", 216))

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"}}

panostheod avatar Aug 04 '22 14:08 panostheod

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?

yury-s avatar Aug 05 '22 17:08 yury-s

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.

mxschmitt avatar Aug 15 '22 08:08 mxschmitt