microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
65.58k stars 3.57k forks source link

[Bug]: Screenshot not recorded/shown in timeline for Webkit #32151

Open l9c opened 4 weeks ago

l9c commented 4 weeks ago

Version

1.46.0

Steps to reproduce

npm init playwright@latest playwright-test cd playwright-test npx playwright test --ui

Expected behavior

expect screenshot images shown in timeline for all browsers

Actual behavior

no screenshot images for Webkit Screenshot from 2024-08-14 17-51-09

Additional context

No response

Environment

System:
    OS: Linux 6.8 Ubuntu 24.04 LTS 24.04 LTS (Noble Numbat)
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 18.43 GB / 31.20 GB
    Container: Yes
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
    bun: 1.0.15 - ~/.bun/bin/bun
  Languages:
    Bash: 5.2.21 - /usr/bin/bash
  npmPackages:
    @playwright/test: ^1.46.0 => 1.46.0
pavelfeldman commented 4 weeks ago

Could you share the trace with us?

l9c commented 3 weeks ago

test-results.zip @pavelfeldman, thank you

pavelfeldman commented 3 weeks ago

For some reason your trace file is missing screencast images. I could not reproduce it on a 24.04 VM:

  System:
    OS: Linux 6.8 Ubuntu 24.04 LTS 24.04 LTS (Noble Numbat)
    CPU: (2) x64 Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz
    Memory: 7.11 GB / 7.75 GB
    Container: Yes
  Binaries:
    Node: 20.16.0 - ~/.nvm/versions/node/v20.16.0/bin/node
    npm: 10.8.1 - ~/.nvm/versions/node/v20.16.0/bin/npm
  Languages:
    Bash: 5.2.21 - /usr/bin/bash
  npmPackages:
    @playwright/test: ^1.46.0 => 1.46.0 

Did you install native dependencies when installing Playwright?

l9c commented 3 weeks ago

Yes, the dependencies are already installed. See the output of npx playwright install-deps below:

Installing dependencies...
Switching to root user to install dependencies...
Get:1 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]               
Get:2 http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages [294 kB]     
Get:3 http://security.ubuntu.com/ubuntu noble-security/main i386 Packages [141 kB]
Get:4 http://security.ubuntu.com/ubuntu noble-security/main Translation-en [68.1 kB]                                                            
Get:5 http://security.ubuntu.com/ubuntu noble-security/main amd64 c-n-f Metadata [3,768 B]                                                      
Get:6 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Packages [250 kB]                                                         
Get:7 http://security.ubuntu.com/ubuntu noble-security/universe i386 Packages [94.5 kB]                                                         
Get:8 http://security.ubuntu.com/ubuntu noble-security/universe amd64 c-n-f Metadata [9,412 B]                                                  
Hit:9 http://archive.ubuntu.com/ubuntu noble InRelease                                                                                          
Get:10 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]                                                                        
Get:11 http://archive.ubuntu.com/ubuntu noble-updates/main i386 Packages [172 kB]                                                               
Get:12 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [348 kB]                                                              
Get:13 http://archive.ubuntu.com/ubuntu noble-updates/main Translation-en [87.9 kB]                                                             
Get:14 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 c-n-f Metadata [5,740 B]                                                       
Get:15 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages [323 kB]                                                          
Get:16 http://archive.ubuntu.com/ubuntu noble-updates/universe i386 Packages [140 kB]                                                           
Get:17 http://archive.ubuntu.com/ubuntu noble-updates/universe Translation-en [136 kB]                                                          
Get:18 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 c-n-f Metadata [12.8 kB]                                                   
Fetched 2,338 kB in 20s (118 kB/s)                                                                                                              
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libasound2t64 is already the newest version (1.2.11-1build2).
libatk-bridge2.0-0t64 is already the newest version (2.52.0-1build1).
libatk1.0-0t64 is already the newest version (2.52.0-1build1).
libatspi2.0-0t64 is already the newest version (2.52.0-1build1).
libcairo2 is already the newest version (1.18.0-3build1).
libcups2t64 is already the newest version (2.4.7-1.2ubuntu7.2).
libdbus-1-3 is already the newest version (1.14.10-4ubuntu4).
libdrm2 is already the newest version (2.4.120-2build1).
libgbm1 is already the newest version (24.0.9-0ubuntu0.1).
libglib2.0-0t64 is already the newest version (2.80.0-6ubuntu3.1).
libnspr4 is already the newest version (2:4.35-1.1build1).
libnss3 is already the newest version (2:3.98-1build1).
libpango-1.0-0 is already the newest version (1.52.1+ds-1build1).
libx11-6 is already the newest version (2:1.8.7-1build1).
libxcb1 is already the newest version (1.15-1ubuntu2).
libxcomposite1 is already the newest version (1:0.4.5-1build3).
libxdamage1 is already the newest version (1:1.1.6-1build1).
libxext6 is already the newest version (2:1.3.4-1build2).
libxfixes3 is already the newest version (1:6.0.0-2build1).
libxkbcommon0 is already the newest version (1.6.0-1build1).
libxrandr2 is already the newest version (2:1.5.2-2build1).
xvfb is already the newest version (2:21.1.12-1ubuntu1).
fonts-noto-color-emoji is already the newest version (2.042-1).
fonts-unifont is already the newest version (1:15.1.01-1build1).
libfontconfig1 is already the newest version (2.15.0-1.1ubuntu2).
libfreetype6 is already the newest version (2.13.2+dfsg-1build3).
xfonts-cyrillic is already the newest version (1:1.0.5+nmu1).
xfonts-scalable is already the newest version (1:1.0.3-1.3).
fonts-liberation is already the newest version (1:2.1.5-3).
fonts-ipafont-gothic is already the newest version (00303-21ubuntu1).
fonts-wqy-zenhei is already the newest version (0.9.45-8).
fonts-tlwg-loma-otf is already the newest version (1:0.7.3-1).
fonts-freefont-ttf is already the newest version (20211204+svn4273-2).
libcairo-gobject2 is already the newest version (1.18.0-3build1).
libgdk-pixbuf-2.0-0 is already the newest version (2.42.10+dfsg-3ubuntu3.1).
libgtk-3-0t64 is already the newest version (3.24.41-4ubuntu1.1).
libpangocairo-1.0-0 is already the newest version (1.52.1+ds-1build1).
libx11-xcb1 is already the newest version (2:1.8.7-1build1).
libxcb-shm0 is already the newest version (1.15-1ubuntu2).
libxcursor1 is already the newest version (1:1.2.1-1build1).
libxi6 is already the newest version (2:1.8.1-1build1).
libxrender1 is already the newest version (1:0.9.10-1.1build1).
gstreamer1.0-libav is already the newest version (1.24.1-1build1).
gstreamer1.0-plugins-bad is already the newest version (1.24.2-1ubuntu4).
gstreamer1.0-plugins-base is already the newest version (1.24.2-1ubuntu0.1).
gstreamer1.0-plugins-good is already the newest version (1.24.2-1ubuntu1).
libicu74 is already the newest version (74.2-1ubuntu3).
libatomic1 is already the newest version (14-20240412-0ubuntu1).
libenchant-2-2 is already the newest version (2.3.3-2build2).
libepoxy0 is already the newest version (1.5.10-1build1).
libevent-2.1-7t64 is already the newest version (2.1.12-stable-9ubuntu2).
libflite1 is already the newest version (2.2-6build3).
libgles2 is already the newest version (1.7.0-1build1).
libgstreamer-gl1.0-0 is already the newest version (1.24.2-1ubuntu0.1).
libgstreamer-plugins-bad1.0-0 is already the newest version (1.24.2-1ubuntu4).
libgstreamer-plugins-base1.0-0 is already the newest version (1.24.2-1ubuntu0.1).
libgstreamer1.0-0 is already the newest version (1.24.2-1).
libharfbuzz-icu0 is already the newest version (8.3.0-2build2).
libharfbuzz0b is already the newest version (8.3.0-2build2).
libhyphen0 is already the newest version (2.8.8-7build3).
libjpeg-turbo8 is already the newest version (2.1.5-2ubuntu2).
liblcms2-2 is already the newest version (2.14-2build1).
libmanette-0.2-0 is already the newest version (0.2.7-1build2).
libopus0 is already the newest version (1.4-1build1).
libpng16-16t64 is already the newest version (1.6.43-5build1).
libsecret-1-0 is already the newest version (0.21.4-1build3).
libvpx9 is already the newest version (1.14.0-1ubuntu2.1).
libwayland-client0 is already the newest version (1.22.0-2.1build1).
libwayland-egl1 is already the newest version (1.22.0-2.1build1).
libwayland-server0 is already the newest version (1.22.0-2.1build1).
libwebp7 is already the newest version (1.3.2-0.4build3).
libwebpdemux2 is already the newest version (1.3.2-0.4build3).
libwoff1 is already the newest version (1.0.2-2build1).
libxml2 is already the newest version (2.9.14+dfsg-1.3ubuntu3).
libxslt1.1 is already the newest version (1.1.39-0exp1build1).
libx264-164 is already the newest version (2:0.164.3108+git31e19f9-1).
0 upgraded, 0 newly installed, 0 to remove and 42 not upgraded.
mxschmitt commented 3 weeks ago

Would it possible to share the output of env with us? (feel free to redact personal information from it)

l9c commented 3 weeks ago

Would it possible to share the output of env with us? (feel free to redact personal information from it)

@mxschmitt Certainly, here is the env output.

SHELL=/bin/bash
SESSION_MANAGER=local/Hostname:@/tmp/.ICE-unix/4179,unix/Hostname:/tmp/.ICE-unix/4179
QT_ACCESSIBILITY=1
PYENV_SHELL=bash
XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg
XDG_MENU_PREFIX=gnome-
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
CONDA_EXE=/home/***/miniconda3/bin/conda
_CE_M=
GOFLAGS= -mod=
TERMINAL_EMULATOR=JetBrains-JediTerm
GTK2_MODULES=overlay-scrollbar
MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path
LC_ADDRESS=en_US.UTF-8
LC_NAME=en_US.UTF-8
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
MEMORY_PRESSURE_WRITE=******
TERM_SESSION_ID=0d6dc4c4-4994-4056-b998-***
XMODIFIERS=@im=ibus
DESKTOP_SESSION=gnome
LC_MONETARY=en_US.UTF-8
GTK_MODULES=gail:atk-bridge
PWD=/home/***/playwright-test
PYENV_VIRTUALENV_INIT=1
XDG_SESSION_DESKTOP=gnome
LOGNAME=***
QT_QPA_PLATFORMTHEME=appmenu-qt5
XDG_SESSION_TYPE=x11
GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
SYSTEMD_EXEC_PID=4224
XAUTHORITY=/run/user/1000/gdm/Xauthority
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
WINDOWPATH=2
HOME=/home/***
USERNAME=***
IM_CONFIG_PHASE=1
LANG=en_US.UTF-8
LC_PAPER=en_US.UTF-8
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.crdownload=00;90:*.dpkg-dist=00;90:*.dpkg-new=00;90:*.dpkg-old=00;90:*.dpkg-tmp=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:*.swp=00;90:*.tmp=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:
XDG_CURRENT_DESKTOP=GNOME
MEMORY_PRESSURE_WATCH=/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/session.slice/org.gnome.Shell@x11.service/memory.pressure
INVOCATION_ID=5fe753ab40524f0***
MANAGERPID=3707
_INTELLIJ_FORCE_SET_GOFLAGS= -mod=
GJS_DEBUG_OUTPUT=stderr
NVM_DIR=/home/***/.nvm
LESSCLOSE=/usr/bin/lesspipe %s %s
XDG_SESSION_CLASS=user
ANDROID_HOME=/home/***/Downloads/android_sdk/
TERM=xterm-256color
LC_IDENTIFICATION=en_US.UTF-8
_CE_CONDA=
DEFAULTS_PATH=/usr/share/gconf/gnome.default.path
LESSOPEN=| /usr/bin/lesspipe %s
USER=***
CONDA_SHLVL=0
DISPLAY=:1
GSK_RENDERER=gl
SHLVL=1
NVM_CD_FLAGS=
GSM_SKIP_SSH_AGENT_WORKAROUND=true
LC_TELEPHONE=en_US.UTF-8
QT_IM_MODULE=ibus
LC_MEASUREMENT=en_US.UTF-8
_INTELLIJ_FORCE_SET_GO111MODULE=on
CONDA_PYTHON_EXE=/home/***/miniconda3/bin/python
XDG_RUNTIME_DIR=/run/user/1000
GO111MODULE=on
DEBUGINFOD_URLS=https://debuginfod.ubuntu.com
LC_TIME=en_US.UTF-8
BUN_INSTALL=/home/***/.bun
FIG_JETBRAINS_SHELL_INTEGRATION=1
JOURNAL_STREAM=8:26446
GTK3_MODULES=xapp-gtk3-module
XDG_DATA_DIRS=/usr/share/gnome:/home/***/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
PATH=/home/***/.bun/bin:/home/***/.nvm/versions/node/v20.9.0/bin:/home/***/.pyenv/plugins/pyenv-virtualenv/shims:/home/***/.pyenv/shims:/home/***/.pyenv/bin:/home/***/miniconda3/condabin:/home/***/bin:/home/***/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/***/playwright-test/node_modules/.bin:/home/***/Downloads/android_sdk//tools
GDMSESSION=gnome
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
NVM_BIN=/home/***/.nvm/versions/node/v20.9.0/bin
GIO_LAUNCHED_DESKTOP_FILE_PID=6376
GIO_LAUNCHED_DESKTOP_FILE=/home/***/.local/share/applications/jetbrains-idea.desktop
LC_NUMERIC=en_US.UTF-8
_=/usr/bin/env

Thanks

mxschmitt commented 3 weeks ago

Could you try export XDG_SESSION_TYPE=wayland and try to re-run it?

l9c commented 3 weeks ago

Could you try export XDG_SESSION_TYPE=wayland and try to re-run it?

@mxschmitt Just tried this, and it doesn't work. I also tried relogging with the "Ubuntu on Wayland" option, but no luck.

l9c commented 3 weeks ago

An additional finding: When testing for click in WebKit (headless), it always times out. I believe it is related to screenshot/rendering issue described earlier.

test('link click', async ({ page }) => {
  await page.goto('https://example.com/');
  const moreLink = await page.getByText('More information');
  await expect(moreLink).toBeVisible();
  await moreLink.click(); //<== this always times out
  await expect(page.getByText('IANA-managed Reserved Domains')).toBeVisible();
});

webkit errors tab:

Test timeout of 30000ms exceeded.
@example.spec.ts:8
Error: locator.click: Test timeout of 30000ms exceeded.
Call log:
  - waiting for getByText('More information')
  -   locator resolved to <a href="https://www.iana.org/domains/example">More information...</a>
  - attempting click action
  -   waiting for element to be visible, enabled and stable
l9c commented 2 weeks ago

I found a workaround after some research. It's export LIBGL_ALWAYS_SOFTWARE=true that forces CPU rendering, as described in the Mesa documentation at https://docs.mesa3d.org/envvars.html#envvar-LIBGL_ALWAYS_SOFTWARE.

It seems that libEGL loaded a device that's incompatible with Webkit WPE in headless mode. According to the libEGL source code, available at https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-24.0.9/src/vulkan/device-select-layer/device_select_layer.c?ref_type=tags#L492-526, it prefers GPU devices for rendering.

However, this preference is not appropriate for headless browser testing. Therefore, I recommend adding export LIBGL_ALWAYS_SOFTWARE=true before MiniBrowser execution unless GPU rendering flags are explicitly passed.

These are the commands and debug logs before and after applying LIBGL_ALWAYS_SOFTWARE=true:

export DRI_PRIME_DEBUG=1
DEBUG=pw:browser npx playwright test --ui
pw:browser [pid=43940][err] selectable devices: +79ms
pw:browser [pid=43940][err]   GPU 0: 10de:1c8c "NVIDIA GeForce GTX 1050 Ti" discrete GPU 0000:01:00.0 +0ms
pw:browser [pid=43940][err]   GPU 1: 8086:3e9b "Intel(R) UHD Graphics 630 (CFL GT2)" integrated GPU 0000:00:02.0 +0ms
pw:browser [pid=43940][err]   GPU 2: 10005:0 "llvmpipe (LLVM 17.0.6, 256 bits)" CPU 0000:00:00.0 +0ms
pw:browser [pid=43940][err] device-select: device_select_find_xcb_pci_default selected 1 +0ms
...
export DRI_PRIME_DEBUG=1
export LIBGL_ALWAYS_SOFTWARE=true
DEBUG=pw:browser npx playwright test --ui
pw:browser [pid=45369][err] libEGL debug: Native platform type: x11 (build-time configuration) +13ms
pw:browser [pid=45369][err] libEGL debug: Found 'LIBGL_ALWAYS_SOFTWARE' set, will use a CPU renderer +1ms
pw:browser [pid=45369][err] libEGL debug: MESA-LOADER: dlopen(/usr/lib/x86_64-linux-gnu/dri/swrast_dri.so) +23ms
...