Bug 1491186

Summary: libva fails to initalize under Xwayland "failed with unknown libva error"
Product: [Fedora] Fedora Reporter: Stuart Auchterlonie <sauchter>
Component: libvaAssignee: Nicolas Chauvet (kwizart) <kwizart>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 30CC: akarshan.biswas, fdeutsch, fedora, kwizart, pmenzel+bugzilla.redhat.com, robert.mader, robin+redhat, sassmann, sgraf, simon
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-26 18:34:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
basic reproducer none

Description Stuart Auchterlonie 2017-09-13 09:17:59 UTC
Created attachment 1325287 [details]
basic reproducer

Description of problem:

Attempting to use VAAPI (via libva) under Xwayland on F26
fails to load the vaapi libraries.

The same code running under Xorg works correctly.

Version-Release number of selected component (if applicable):

libva-1.8.3-1.fc26.x86_64
libva-intel-driver-1.8.3-2.fc26.x86_64

How reproducible:

100% - see attached reproducer

Steps to Reproduce:
1. Build reproducer
2. Run under xwayland
3.

Actual results:

Fails under wayland with
---
libva info: VA-API version 0.40.0
libva info: va_getDriverName() returns -1
libva error: va_getDriverName() failed with unknown libva error,driver_name=(null)
Failed to init VAAPI: unknown libva error
---

Expected results:

As per running under Xorg
---
libva info: VA-API version 0.40.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_40
failed to open /usr/lib64/dri/hybrid_drv_video.so
Failed to wrapper hybrid_drv_video.so
libva info: va_openDriver() returns 0
Vendor String: Intel i965 driver for Intel(R) Sandybridge Mobile - 1.8.3
---

Additional info:

The same code runs as expected on a similar system which is still
running F25.
---
libva info: VA-API version 0.39.4
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
Vendor String: Intel i965 driver for Intel(R) Haswell Mobile - 1.7.3
---

Comment 1 Nicolas Chauvet (kwizart) 2017-09-13 09:37:21 UTC
Can you try to install /usr/lib64/dri/hybrid_drv_video.so from fedora ?
Please also report the issue upstream https://github.com/01org/libva

Comment 2 Nicolas Chauvet (kwizart) 2017-09-13 09:48:27 UTC
Could be already reported https://github.com/01org/libva/issues/79

Comment 3 Nicolas Chauvet (kwizart) 2017-09-13 09:51:38 UTC
One test you could do is to rebuild the f26+ packages to f25 in order to verify that the problem isn't with an interaction with a more recent xwayland.

Comment 4 Stuart Auchterlonie 2017-09-13 10:21:04 UTC
No change with libva-intel-hybrid-driver-1.0.2-4.fc26.x86_64
installed.

Rebuild this for f25?
https://koji.fedoraproject.org/koji/buildinfo?buildID=917871

Comment 5 Stuart Auchterlonie 2017-09-13 10:22:44 UTC
Really i mean https://koji.fedoraproject.org/koji/buildinfo?buildID=917858

Comment 6 Stuart Auchterlonie 2017-09-13 10:29:04 UTC
Works with libva-1.8.3-1.fc25.x86_64

---
libva info: VA-API version 0.40.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
Vendor String: Intel i965 driver for Intel(R) Haswell Mobile - 1.7.3
---

Regards
Stuart

Comment 7 Nicolas Chauvet (kwizart) 2017-09-13 10:33:56 UTC
(In reply to Stuart Auchterlonie from comment #6)
> Works with libva-1.8.3-1.fc25.x86_64
Same with the libva-intel-driver ? (from RPM Fusion)

Comment 8 Stuart Auchterlonie 2017-09-13 10:51:00 UTC
That works too

---
libva info: VA-API version 0.40.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_40
libva info: va_openDriver() returns 0
Vendor String: Intel i965 driver for Intel(R) Haswell Mobile - 1.8.3
---

# rpm -qa | grep libva
libva-1.8.3-1.fc25.x86_64
libva-debuginfo-1.8.3-1.fc25.x86_64
libva-utils-1.8.3-1.fc25.x86_64
libva-intel-driver-1.8.3-1.fc25.x86_64
libva-devel-1.8.3-1.fc25.x86_64

Comment 9 Stuart Auchterlonie 2017-09-13 10:55:01 UTC
For reference, vainfo does run correctly on f26 under wayland.
No idea what it does differently.

---
$ vainfo 
libva info: VA-API version 0.40.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_40
/usr/lib64/dri/hybrid_drv_video.so init failed
Failed to wrapper hybrid_drv_video.so
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.40 (libva )
vainfo: Driver version: Intel i965 driver for Intel(R) Sandybridge Mobile - 1.8.3
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264StereoHigh         :	VAEntrypointVLD
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc
---

Comment 10 Robin Burchell 2017-09-30 19:30:40 UTC
I think I'm facing the same problem here, first noticed that Steam's hardware decoding wasn't working under a Wayland session, and pretty quickly had it nailed down as being an Xwayland issue. I can confirm that Stuart's original example also fails for me (whereas vainfo-for-Wayland works just fine).

Looking into the details, va_getDriverName defers to va_x11.c's va_DisplayContextGetDriverName. This then fails to detect anything at all (which leads to va_getDriverName() returns -1).

One can attempt to force a driver, e.g: export LIBVA_DRIVER_NAME=i965. This then fails in a different way:

	libva info: VA-API version 0.40.0
	libva info: va_getDriverName() returns -1
	libva info: User requested driver 'i965'
	libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
	libva info: Found init function __vaDriverInit_0_40
	libva error: /usr/lib64/dri/i965_drv_video.so init failed
	libva info: va_openDriver() returns -1
	Failed to init VAAPI: unknown libva error

Setting a breakpoint in __vaDriverInit_0_40, we see that the actual failure is in i965_Init returning something other than VA_STATUS_SUCCESS. This leads us to intel_driver_init, which (helpfully) has a VA_INTEL_DEBUG environment variable. Setting that gives us the cause for the init failure:

	libva info: VA-API version 0.40.0
	libva info: va_getDriverName() returns -1
	libva info: User requested driver 'i965'
	libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
	libva info: Found init function __vaDriverInit_0_40
	g_intel_debug_option_flags:1
	main: intel_driver.c:113: intel_driver_init: Assertion `((((struct drm_state *)(ctx)->drm_state)->auth_type == (VA_DRM_AUTH_DRI1)) || (((struct drm_state *)(ctx)->drm_state)->auth_type == (VA_DRM_AUTH_DRI2)) || (((struct drm_state *)(ctx)->drm_state)->auth_type == (VA_DRM_AUTH_CUSTOM)))' failed.

Looking at the same process under Wayland, we see that va_getDriverName ends up in va_wayland_drm.c's va_DisplayContextGetDriverName, which calls VA_DRM_GetDriverName (successfully; so no need for LIBVA_DRIVER_NAME). For whatever reason, __vaDriverInit_0_40 succeeds (the assertions don't fail this time).

This is as far as I've gotten thus far.

Comment 11 Robin Burchell 2017-09-30 19:43:52 UTC
Some more spelunking leads me to: https://github.com/01org/libva/issues/79 -- which I think is the real cause, then.

Comment 12 Nicolas Chauvet (kwizart) 2018-01-26 18:09:41 UTC
If anyone is able to test on f28 (with libva-2.0.0), this might have improved...

Comment 13 Stuart Auchterlonie 2018-02-01 10:22:20 UTC
Nicolas,

This hasn't changed at this time, however I believe this is because
https://github.com/intel/libva/pull/180 has not yet been merged.

Once it has we will need to enable the code with `--enable-dri3`


Regards
Stuart

Comment 14 Fedora End Of Life 2018-05-03 08:31:37 UTC
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '26'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 26 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 15 Fedora End Of Life 2018-05-29 12:47:51 UTC
Fedora 26 changed to end-of-life (EOL) status on 2018-05-29. Fedora 26
is no longer maintained, which means that it will not receive any
further security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 16 Robert Mader 2018-06-18 18:11:28 UTC
Can this please get reopened for fedora 28? It's not yet resolved. The upstream bug, as indicated above, seems to be https://github.com/intel/libva/pull/180

Comment 17 Stuart Auchterlonie 2018-06-27 08:11:15 UTC
Still occurs on Fedora 28, reopening

Comment 18 Stefan Assmann 2018-08-15 12:42:59 UTC
Ran into the supposedly the same issue when trying to use chromium with libva. (Skylake Lenovo P50)

$ chromium-browser 
libva error: /usr/lib64/dri/i965_drv_video.so init failed
[2294:2294:0815/143015.407035:ERROR:vaapi_wrapper.cc(323)] vaInitialize failed: unknown libva error

Running the reproducer attached in the initial description.
$ ./main 
libva info: VA-API version 1.1.0
libva info: va_getDriverName() returns -1
libva info: User requested driver 'i965'
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_1
libva error: /usr/lib64/dri/i965_drv_video.so init failed
libva info: va_openDriver() returns -1
Failed to init VAAPI: unknown libva error

$ rpm -qa |grep libva
libva-devel-2.1.0-1.fc28.x86_64
libva-utils-2.1.0-1.fc28.x86_64
libva-intel-hybrid-driver-1.0.2-13.fc28.x86_64
libva-2.1.0-1.fc28.x86_64
libva-intel-driver-2.1.0-2.fc28.x86_64

Running vainfo shows no issues.
$ vainfo 
libva info: VA-API version 1.1.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'i965'
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_1
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.1 (libva 2.1.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Skylake - 2.1.0

Comment 19 Nicolas Chauvet (kwizart) 2018-08-15 12:57:22 UTC
(In reply to Stefan Assmann from comment #18)
> Ran into the supposedly the same issue when trying to use chromium with
> libva. (Skylake Lenovo P50)
> 
> $ chromium-browser 
> libva error: /usr/lib64/dri/i965_drv_video.so init failed
> [2294:2294:0815/143015.407035:ERROR:vaapi_wrapper.cc(323)] vaInitialize
> failed: unknown libva error
Interesting! Any WIP scratch build ?

This issue will remains for intel even if there is a libva backport to support dri3. But others mesa drivers might benefit from it...

Comment 20 Stefan Assmann 2018-08-15 13:04:56 UTC
(In reply to Nicolas Chauvet (kwizart) from comment #19)
> Interesting! Any WIP scratch build ?
> 
> This issue will remains for intel even if there is a libva backport to
> support dri3. But others mesa drivers might benefit from it...

Nothing official afaik.
I'm using chromium from this copr repo
https://copr.fedorainfracloud.org/coprs/hellbangerkarna/Chromium-Vaapi/

Do you think it's the same issue or just a similar error message?
Btw I'm using Xorg, not Wayland.

Comment 21 Ben Cotton 2019-05-02 19:51:44 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 22 Christian Stadelmann 2019-05-09 21:12:58 UTC
With libva-2.4.1-1.fc30.x86_64 and libva-2.4.1-1.fc30.x86_64:

$ vainfo
libva info: VA-API version 1.4.1
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

Comment 23 Simon Farnsworth 2019-05-09 22:33:04 UTC
(In reply to Christian Stadelmann from comment #22)
> With libva-2.4.1-1.fc30.x86_64 and libva-2.4.1-1.fc30.x86_64:
> 
> $ vainfo
> libva info: VA-API version 1.4.1
> libva info: va_getDriverName() returns 0
> libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
> libva info: va_openDriver() returns -1
> vaInitialize failed with error code -1 (unknown libva error),exit

That says that you haven't installed the driver for i965, and is unrelated to this bug. The driver you need is not packaged in Fedora itself due to the usual fun around codec patents; install it from a third party repo (like RPM Fusion), and it should work.

Comment 24 Christian Stadelmann 2019-05-10 16:41:51 UTC
(In reply to Simon Farnsworth from comment #23)
> That says that you haven't installed the driver for i965, and is unrelated
> to this bug. The driver you need is not packaged in Fedora itself due to the
> usual fun around codec patents; install it from a third party repo (like RPM
> Fusion), and it should work.

You're right about that. Thanks for the help and sorry for the noise…

Comment 25 Ben Cotton 2020-04-30 20:16:55 UTC
This message is a reminder that Fedora 30 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 30 on 2020-05-26.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '30'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 30 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 26 Ben Cotton 2020-05-26 18:34:32 UTC
Fedora 30 changed to end-of-life (EOL) status on 2020-05-26. Fedora 30 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.