Bug 437685 - Please make wayland compatible with X11 with respect to video decoding hardware acceleration in all cases
Summary: Please make wayland compatible with X11 with respect to video decoding hardwa...
Status: RESOLVED DOWNSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: 5.21.5
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-25 22:50 UTC by Marian Klein
Modified: 2021-05-28 00:37 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
hardware video decoding accelerator works on X11 for an application (3.73 MB, image/png)
2021-05-25 23:01 UTC, Marian Klein
Details
video hardware decoding not working on wayland. Everything else the same. (1.76 MB, image/png)
2021-05-25 23:21 UTC, Marian Klein
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marian Klein 2021-05-25 22:50:20 UTC
4k@60fps youtube video footage hardware decoding acceleration works for on X11/Xorg in google-chrome but it does not work for the same laptop/OS and browser binary on wayland.

See also https://gitlab.freedesktop.org/wayland/wayland/-/issues/212

SOFTWARE/OS VERSIONS: Kubuntu 21.04
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.21.4
KDE Frameworks Version: 5.80.0
Qt Version: 5.15.2
Comment 1 Marian Klein 2021-05-25 23:01:36 UTC
Created attachment 138791 [details]
hardware video decoding accelerator works on X11 for an application
Comment 2 Marian Klein 2021-05-25 23:09:30 UTC
Trying to play the same 4k video on wayland produces Kde crash handler:
#4  0x00007f02b44a841a in wl_proxy_marshal_constructor () from /lib/x86_64-linux-gnu/libwayland-client.so.0
#5  0x00007f02b452bb57 in QtWaylandClient::QWaylandDisplay::createSurface(void*) () from /lib/x86_64-linux-gnu/libQt5WaylandClient.so.5
#6  0x00007f02b4537d7a in ?? () from /lib/x86_64-linux-gnu/libQt5WaylandClient.so.5
#7  0x00007f02b453075a in QtWaylandClient::QWaylandWindow::initializeWlSurface() () from /lib/x86_64-linux-gnu/libQt5WaylandClient.so.5
#8  0x00007f02b45375ad in QtWaylandClient::QWaylandShmWindow::QWaylandShmWindow(QWindow*, QtWaylandClient::QWaylandDisplay*) () from /lib/x86_64-linux-gnu/libQt5WaylandClient.so.5
#9  0x00007f02b451ec39 in QtWaylandClient::QWaylandIntegration::createPlatformWindow(QWindow*) const () from /lib/x86_64-linux-gnu/libQt5WaylandClient.so.5
#10 0x00007f02b60421e4 in QWindowPrivate::create(bool, unsigned long long) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#11 0x00007f02b6890fa5 in QWidgetPrivate::create() () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#12 0x00007f02b68914ee in QWidget::create(unsigned long long, bool, bool) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#13 0x00007f02b689e77e in QWidgetPrivate::setVisible(bool) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x00007f02b6a5e868 in QDialog::setVisible(bool) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#15 0x000055ddb1e516e0 in ?? ()
#16 0x00007f02b55a5565 in __libc_start_main (main=0x55ddb1e50050, argc=19, argv=0x7ffc6214bd68, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffc6214bd58) at ../csu/libc-start.c:332
#17 0x000055ddb1e52a7e in _start ()
[Inferior 1 (process 2388) detached]
Comment 3 Marian Klein 2021-05-25 23:21:04 UTC
Created attachment 138792 [details]
video hardware decoding not working on wayland. Everything else the same.
Comment 4 Marian Klein 2021-05-25 23:31:00 UTC
When I tried to play 4k video footage straight after switching to wayland from X11, google-chrome crashed in /lib/x86_64-linux-gnu/libQt5WaylandClient.so.5 . When I removed ~/.config/google-chrome I could get to playing 4k footage again. Then I pressed CTRL+SHIFT+i, and I looked up media tab (via more tools) in built-in info/debug browser right section tool. For wayland you can see "Decoder name:Dav1dVideoDecoder" and "Hardware decoder: false" whereas for X11 you can see "Decoder name:VideoDecoderAccelerator" and "Hardware decoder:true".
Comment 5 Marian Klein 2021-05-25 23:37:35 UTC
The same behaviour is for both variants of google-chrome , stable and unstable:
marian@HPSpectre:~/.config$ dpkg -l | grep chrome
ii  google-chrome-stable                          90.0.4430.212-1                                                      amd64        The web browser from Google
ii  google-chrome-unstable                        92.0.4512.4-1                                                        amd64        The web browser from Google
Comment 6 Marian Klein 2021-05-25 23:50:18 UTC
marian@HPSpectre:~/.config$ vainfo
libva info: VA-API version 1.10.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_10
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.10 (libva 2.10.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 21.1.1 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointFEI
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointFEI
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointFEI
      VAProfileHEVCMain               : VAEntrypointEncSliceLP
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointEncSliceLP
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile1            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileVP9Profile3            : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointEncSlice
      VAProfileHEVCMain422_10         : VAEntrypointVLD
      VAProfileHEVCMain422_10         : VAEntrypointEncSlice
      VAProfileHEVCMain422_12         : VAEntrypointVLD
      VAProfileHEVCMain422_12         : VAEntrypointEncSlice
      VAProfileHEVCMain444            : VAEntrypointVLD
      VAProfileHEVCMain444            : VAEntrypointEncSliceLP
      VAProfileHEVCMain444_10         : VAEntrypointVLD
      VAProfileHEVCMain444_10         : VAEntrypointEncSliceLP
      VAProfileHEVCMain444_12         : VAEntrypointVLD
      VAProfileHEVCSccMain            : VAEntrypointVLD
      VAProfileHEVCSccMain            : VAEntrypointEncSliceLP
      VAProfileHEVCSccMain10          : VAEntrypointVLD
      VAProfileHEVCSccMain10          : VAEntrypointEncSliceLP
      VAProfileHEVCSccMain444         : VAEntrypointVLD
      VAProfileHEVCSccMain444         : VAEntrypointEncSliceLP
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileHEVCSccMain444_10      : VAEntrypointVLD
      VAProfileHEVCSccMain444_10      : VAEntrypointEncSliceLP
Comment 7 Nate Graham 2021-05-26 03:34:50 UTC
I'm not sure our code has anything to do with this. I think it's all in Firefox.
Comment 8 David Edmundson 2021-05-26 10:32:54 UTC
>Trying to play the same 4k video on wayland produces Kde crash handler:

Which application crashed there?
Comment 9 Marian Klein 2021-05-27 21:35:58 UTC
Hi David. 
The browser that crashed on wayland was google-chrome. (See comment 4).
When I removed ~/.config/google-chrome , the crashing stopped , but I still did not have hardware acceleration.

I got one mainstream browser working with hardware acceleration on wayland for me now. It is firefox. Even though it was crashing too in each tab when acceleration enable originally. I fixed firefox crashes by setting environment variable MOZ_DISABLE_CONTENT_SANDBOX=1
I may open another ticket for this somewhere.
Comment 10 Nate Graham 2021-05-27 23:42:14 UTC
But is there any indication that any of the issues you're facing are caused by KDE software, or could be alleviated by improvements to it? It seems from your description like the bugs are all in Firefox and Chromium, no?
Comment 11 Marian Klein 2021-05-28 00:29:01 UTC
Hi Nate.

Do firefox and google-chrome have different execution paths in their code for X11 and for wayland in respect to video hardware acceleration? If they do then it is a bad design. If they don't and they don't care/know what they are running on then swapping one for another one (wayland for X11) for the same binary should not change behaviour or start/stop crashing.

The indication is 
combination of   My Laptop +kubuntu 21.04 + google-chroome + X11  supports video decoding hardware acceleration.However the similar combination (with the same binary for google-chrome) with wayland replacing X11 is crashing or not supporting hardware acceleration. 
From the outside  I can only tell the wayland is the blame or an library wayland uses and X11 does not.
I am less concerned about google-chrome now as I got firefox video acceleration working on wayland with MOZ_DISABLE_CONTENT_SANDBOX=1

I have not tested chromium yet. Only google-chrome and firefox.
Comment 12 Nate Graham 2021-05-28 00:37:32 UTC
They absolutely do have different code paths and rendering pipelines for X11 vs Wayland, due to the deep technical differences in the way X11 and Wayland handle video, and also due to the fact that these web browsers basically chose to implement everything themselves rather than using cross-platform toolkits to do the necessary platform-specific work for them (both use GTK only for the front-end UI on Linux; the internals are all custom). So yeah, you'll need to report these quirks/bugs/crashes/etc to the developers of the browsers.