grafana / xk6-browser

k6 module that adds support for browser automation and end-to-end web testing via the Chrome Devtools Protocol
https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/browser/
GNU Affero General Public License v3.0
342 stars 42 forks source link

Browser and test freeze in headless mode #1388

Closed volnyansky closed 1 week ago

volnyansky commented 3 months ago

Brief summary

Browser stop react on request and freezes test after ~ 100s of inactivity ( k6.sleep)

xk6-browser version

1.5.1

OS

mac os 14.5

Chrome version

128.0.6540.0

Docker version and image (if applicable)

No response

Steps to reproduce the problem

I use k6 browser to perform stress tests of complex web app: video/audio streaming, web workers, and web sockets. I noticed if I run sleep for more then 100 sec browser freezes: client disconnects from the backend and if I try to call page/browser methods , then the test freezes it keeps running until I stop it. If I use chromium with UI, then the bug is not reproduced.

I've fixed it by overriding chromium headless param with --headless=new (spied it in pupitter) . Here is the my setup: ` export K6_BROWSER_IGNORE_DEFAULT_ARGS=disable-features,headless

export K6_BROWSER_LOG=debug

K6_BROWSER_ARGS="disable-features=Translate,AcceptCHFrame,MediaRouter,OptimizationHints,ProcessPerSiteUpToMainFrameThreshold,IsolateSandboxedIframes,no-sandbox,disable-setuid-sandbox,allow-file-access=1,use-fake-device-for-media-stream=1,use-fake-ui-for-media-stream=1,use-file-for-fake-video-capture=./assets/video-001.mjpeg,use-file-for-fake-audio-capture=./assets/audio-001.wav"

if [ "$K6_BROWSER_HEADLESS" = true ]; then K6_BROWSER_ARGS="headless=new,window-size=1920x1080,$K6_BROWSER_ARGS" fi export K6_BROWSER_ARGS=$K6_BROWSER_ARGS`

Expected behaviour

The browser doesn't freeze test.

Actual behaviour

The browser freezes the test.

volnyansky commented 3 months ago

Read more about new headless https://developer.chrome.com/docs/chromium/new-headless

inancgumus commented 1 week ago

Closed in favor of #948.