[Linux][Vulkan Video] Decoded video is green with direct-export on Radeon 680M
Categories
(Core :: Audio/Video: Playback, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox161 | --- | fixed |
People
(Reporter: DaisyTheFoxxo, Assigned: tboiko)
References
(Blocks 2 open bugs)
Details
Attachments
(7 files, 2 external files)
This is a clone of https://bugzilla.mozilla.org/show_bug.cgi?id=2083226 because the bug there still happens to me and I don't have the permission to comment on it because it's closed
OS: CachyOS
GPU: Radeon 680M (amdgpu kernel module)
How to reproduce:
Enable media.hardware-video-decoding-vulkan.enabled, media.hardware-video-decoding-vulkan.force-enabled, and media.hardware-video-decoding-vulkan.direct-export.enabled
Play the attached video
Bug happens regardless of if media.hardware-video-decoding-vulkan.prefer-system-ffmpeg is enabled or not
This was originally reported on Ladybird issue #12902, so I'm attaching a recording of the bug for reference here. I suggested reporting it here, since I figured that direct export shipping on all hardware vendors is on the roadmap. From a cursory look, it seems like the failure worked around by forcing Vulkan decoding is simply an NVIDIA whitelist, rather than this and/or other issues being known on AMD GPUs?
Comment 2•20 days ago
|
||
| gecko-triage | ||
Thanks for the sample and the recording.
Analysis
This is a different symptom from bug 2083226. That bug gave a solid green frame. Here, the recording shows green blocks that follow motion, and some regions decode with correct colors. This pattern points to bad H.264 reference pictures, not to a wrong dma-buf layout.
H.264 always uses the system FFmpeg, because the bundled ffvpx has no H.264 decoder. This explains why prefer-system-ffmpeg has no effect. For a libavcodec older than 63.8.101, the direct-export path in FFmpegVideoDecoder.cpp can drop VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR from images that libavcodec still uses as references. This is the probable cause, but code reading alone found it. The Firefox build and the FFmpeg version on your system will show if this path applies.
Tymur, could you please look at this? The question is the direct-export path on RDNA2 with a system libavcodec older than 63.8.101. The follow-up from bug 2083226 changes this path.
This bug blocks bug 2053144 (Vulkan video decoding on Linux) and bug 1766429 (Linux playback).
Next steps
Please capture a profile:
- Open
about:logging. - On the Logging presets tab, choose the "Media playback" preset.
- Under Logging output, select "Logging to the Firefox Profiler".
- Click Start Logging.
- Reload the page. Then do the steps that show the problem.
- Click Stop Logging. The profile opens in the Firefox Profiler.
- Click Upload Local Profile. This is the share button.
- Copy the share URL. Add it to this bug.
The instruction video shows these steps.
Please also add this information to the bug:
- Open
about:support, click "Copy text to clipboard", and paste it into a comment. - Run
pacman -Q ffmpeg mesain a terminal, and paste the output. - Set
media.hardware-video-decoding-vulkan.direct-export.enabledto false, and play the same video. Tell us if the picture is correct.
If you'd like to provide feedback on this comment, please use the π or π reaction.
| Assignee | ||
Comment 3•20 days ago
•
|
||
What versions of Firefox, FFmpeg, and RADV did you use? Could you try playing a video on YouTube (in this case, AV1/VP9 and ffvpx will be used, for other codecs, the system FFmpeg will be used regardless) and tell us if you see the corruption there - if yes, provide the link to the youtube video)?
Please, also provide the original input video (the one you shared is gray) and the Mozilla logs.
| Reporter | ||
Comment 4•20 days ago
|
||
| Reporter | ||
Comment 5•20 days ago
|
||
https://share.firefox.dev/47VlQ0d
Version: Nightly from October 21st ("https://ftp.mozilla.org/pub/firefox/nightly/2026/10/2026-10-21-20-53-24-mozilla-central/", file "firefox-160.0a1.en-US.linux-x86_64.tar.xz")
The YouTube video does show the artifacts on 720p60
pacman -Q ffmpeg mesa:
ffmpeg 2:9.0.2-2.1
mesa 3:26.2.4-1```
Setting `media.hardware-video-decoding-vulkan.direct-export.enabled` to `false` does remove the artifacts
| Reporter | ||
Comment 6•20 days ago
|
||
| Reporter | ||
Comment 7•20 days ago
|
||
Please, also provide the original input video
The original video is a direct download of https://www.youtube.com/watch?v=S6YyVlCW6Vg via youtube-dl
I wont share that directly because I care about the creator's work. Though, the bug happens on almost all YouTube videos at 720p60 specifically
| Assignee | ||
Comment 8•20 days ago
•
|
||
The YouTube video does show the artifacts on 720p60
What about other resolutions? This will help isolate the issue. I suspect this bug is something different, in the referenced bug, there were severe distortions appearing as solid green areas (completely green frames)
| Reporter | ||
Comment 9•20 days ago
|
||
What about other resolutions?
From my testing, it only happens on 720p60 on regular videos and whatever resolution YouTube uses for shorts. For me, all shorts I've watched contained the same artifacts
| Assignee | ||
Comment 10•20 days ago
•
|
||
Could you please try 1080p, 1440p, 2160p videos on Youtube, will it work for you? (just to be sure, If I understood correctly, you said that issue affected only 720p resolution, right?)
Also, please set media.hardware-video-decoding-vulkan.prefer-system-ffmpeg.enabled to false
| Reporter | ||
Comment 11•20 days ago
|
||
Could you please try 1080p, 1440p, 2160p videos on Youtube, will it work for you?
Here is me testing all resolutions from 144p to 2160p
Seems it also appears on 144p as well. My earlier claim that its 720p60 is half incorrect as 60 fps isn't required
| Reporter | ||
Comment 12•20 days ago
|
||
Also, please set
media.hardware-video-decoding-vulkan.prefer-system-ffmpeg.enabledto false
I did that just before I sent the video in the comment above. It seems to have no affect on the results for me
| Assignee | ||
Comment 13•20 days ago
•
|
||
Alright, that helps, thank you.
So the issue affects only specific resolutions (e.g. 144p, 720p) on RADV, DISTINCT path specific - thereβs likely still some discrepancy. I will take a look at it but probably not this week.
Comment 14•19 days ago
|
||
| gecko-triage | ||
Thanks for the versions, the about:support and the recordings. Tymur plans to look at this bug (comment 13).
Analysis
The probable cause is in ChooseVulkanPixelFormatFromContext in FFmpegVideoDecoder.cpp. For a libavcodec older than 63.8.101, Firefox sets outputIsDpb = !mDriverDistinctDpb. Then it writes hwfc->usage without VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR.
RADV on the Radeon 680M reports both COINCIDE and DISTINCT. In that case, a libavcodec older than 63.8.101 uses the output image as the reference picture. Thus each reference picture is an image without DPB usage. The system FFmpeg 9.0.2 from comment 5 is probably in this version range, because the FFmpeg 9.0.1 in ffvpx is libavcodec 63.1.101.
The recordings match this cause. In attachment 9667298 [details], a green band covers the bottom rows of the picture. The luma in the band is correct, and only the chroma is missing. The top edge of the band has macroblock steps, and green blocks follow the motion. This pattern comes from motion compensation with bad references, not from a wrong export layout.
This behavior started with the part 3 change of bug 2083226, in ChooseVulkanPixelFormatFromContext, which landed on 2026-10-19. Before that change, the same setup showed solid green frames. Thus this is not a regression of a setup that worked. Code reading found this cause, and no log confirms it yet. A run with the Vulkan validation layer can confirm it: the layer should report reference pictures without DPB usage.
H.264 always uses the system FFmpeg, because ffvpx has no H.264 decoder. This explains why prefer-system-ffmpeg has no effect.
The profile in comment 5 uses a newer profile format that our tools cannot read yet. This is a gap in our tools, and the analysis above does not use the profile.
Fix direction
- Take
outputIsDpbfrom thehwfc->usagethat libavcodec sets, for every libavcodec version. - When the output image has DPB usage and the driver reports DISTINCT, skip direct export.
- In that case, use the copy path and log the reason.
- Detect ffvpx with
FFVPX_VERSION, not with the libavcodec version number.
The last step is necessary because ffvpx reports 63.1.101 but already has the DISTINCT logic.
This bug blocks bug 2053144 (Vulkan video decoding on Linux) and bug 1766429 (Linux playback).
If you'd like to provide feedback on this comment, please use the π or π reaction.
| Assignee | ||
Comment 15•19 days ago
•
|
||
[:media-triaging-bot], the above findings and fix direction are not relevant to this bug. Please read comment #13.
| Assignee | ||
Comment 16•17 days ago
•
|
||
I could not reproduce the corruption locally with the attached sample (βA small video that produces the artifactsβ) or either YouTube video (all resolutions were clean, including 144p, 720p):
Environment: Ubuntu 26.04.1, Wayland with GNOME/Mutter, Radeon RX 9070 GRE (RDNA4/GFX1201), local RADV Mesa 26.3.0-devel (b888682cba), also tried system radeonsi Mesa 26.0.8, Firefox checkout efd2d1e6.
| Assignee | ||
Comment 17•17 days ago
|
||
[:hanabishi], could you please tell us if you see this kind of corruption at your side?
Comment 18•17 days ago
|
||
Yes, I see it. Exactly as described, only with direct export on certain resolutions. VP9 is especially nasty here.
| Assignee | ||
Comment 19•17 days ago
•
|
||
Maybe Benjamin could take a look. I don't have the required setup (no repro on RDNA4)
Comment 20•17 days ago
|
||
Just for sanity check, ensure that Vulkan is actually enabled. It requires to be force-enabled here.
| Assignee | ||
Comment 21•17 days ago
|
||
media.hardware-video-decoding-vulkan.enabled, force-enabled, and direct-export.enabled are all true
| Assignee | ||
Updated•16 days ago
|
Comment 22•16 days ago
|
||
This should be fixed by https://code.ffmpeg.org/FFmpeg/FFmpeg/commit/b7e835e06913e4374a4567003fe8c75cebfffb98.
The issue is libavcodec is creating the DPB images with a DRM format modifier list which isn't supported by the hardware. This is invalid by spec (since RADV doesn't report VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT for the DPB images. I'll look into a workaround in RADV to ignore the modifier list passed for DPB images in the meanwhile (no promises because it's hacky).
| Assignee | ||
Comment 23•16 days ago
•
|
||
Thank you for your answer. Sorry, one more quick question:
I am still curious why I can't reproduce this on RDNA4 with ffvpx (which precedes this commit), and why only specific resolutions (e.g., 144p and 720p - see video example in comment #11) are affected on RDNA2 and RDNA3? Could it be something similar to https://docs.mesa3d.org/relnotes/26.2.1.html#bug-fixes?
Also, in Firefox, this DPB usage flag was removed for GPUs that report distinct usage (which helped fix Bug 2083226), these usages are then passed to libavcodec:
https://github.com/mozilla-firefox/firefox/blob/0f76fed7aea1f77db85afbf5a895754d8ad971d7/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp#L487
https://github.com/mozilla-firefox/firefox/blob/0f76fed7aea1f77db85afbf5a895754d8ad971d7/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp#L535
https://github.com/mozilla-firefox/firefox/blob/0f76fed7aea1f77db85afbf5a895754d8ad971d7/dom/media/platforms/ffmpeg/FFmpegVulkanVideoDecoder.cpp#L666
| Assignee | ||
Updated•16 days ago
|
| Assignee | ||
Comment 24•16 days ago
|
||
[:hanabishi], could you try please if the latest FFmpeg master helps you to fix the issue?
Comment 25•16 days ago
|
||
Here's the RADV workaround: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/45669. It may be worth trying that as well.
(In reply to Tymur Boiko from comment #23)
I am still curious why I can't reproduce this on RDNA4 with ffvpx (which precedes this commit) [...]
VCN5 (the video decoder IP on your RDNA4 card) supports more swizzle modes for the DPB (in fact it can almost support COINCIDE).
and why only specific resolutions (e.g., 144p and 720p - see video example in comment #11) are affected on RDNA2 and RDNA3?
I have not 100% confirmed this but from my observations I believe it is because the modifier requires a larger alignment than the tiling mode that HW wants to use, that can make the chroma plane have a different pitch than what the FW/HW expected. That mis-alignment only happens for certain resolutions as you see.
Could it be something similar to https://docs.mesa3d.org/relnotes/26.2.1.html#bug-fixes?
No those corruptions do not look like this (and it is a firmware issue that would affect both direct-export enabled/disabled).
Comment 26•16 days ago
|
||
(In reply to Tymur Boiko from comment #24)
[:hanabishi], could you try please if the latest FFmpeg master helps you to fix the issue?
Can't tell, direct export doesn't work with system ffmpeg for me. (Falls back to SW.)
(In reply to Benjamin Cheng from comment #25)
Here's the RADV workaround: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/45669. It may be worth trying that as well.
Yes, this patch fixes the problem for me.
| Assignee | ||
Comment 27•16 days ago
|
||
Great, thank you. We may also need to backport the above FFmpeg commit to ffvpx.
| Assignee | ||
Comment 28•16 days ago
|
||
Backport FFmpeg b7e835e06913: "Drivers needn't support modifier tiling
for DPB-only usage, and radv doesn't, so the pool broke
VUID-VkImageCreateInfo-pNext-06811."
Fixes direct-export video corruption at certain resolutions, including
144p and 720p, on AMD RDNA2 and RDNA3 GPUs.
Updated•16 days ago
|
Comment 29•15 days ago
|
||
Comment 30•15 days ago
|
||
| bugherder | ||
| Reporter | ||
Comment 31•14 days ago
|
||
I found another instance where the same bug happens. I'm on the October 29th nightly build. While the bug on the original video was fixed, 720p on a livestream (https://www.youtube.com/watch?v=KsCJwkyvw_s) produced the same artifacts.
| Reporter | ||
Updated•14 days ago
|
| Reporter | ||
Comment 32•14 days ago
|
||
| Assignee | ||
Comment 33•14 days ago
•
|
||
Please check "Stats for nerds" on YouTube to see which codec is being used.
On the Firefox side, this issue can only be resolved for FFVPX (AV1 + VP9). Other codecs rely on system FFmpeg, meaning the fix must be applied either in your FFmpeg build (see comment #22) or in RADV (see comment #25), as noted above.
| Reporter | ||
Comment 34•14 days ago
|
||
Please, check Stats for Nerds on Youtube to see which codec was used
avc1.4D4020 (298) / mp4a.40.2 (140)
Comment 35•14 days ago
|
||
avc1 is H264, it uses system ffmpeg. It should be fixed in ffmpeg 9.1 release.
Comment 36•14 days ago
•
|
||
That's probably the fault of the stream using H.264 and running on system FFmpeg, which would carry the problematic code. Direct export should probably be blocked when it calls out to the affected versions.
Edit: Commented too late again!
| Assignee | ||
Comment 37•14 days ago
•
|
||
You could try the RADV build from comment #26 to see if it helps, but I noticed the PR was closed unmerged.
Otherwise, I don't think we should disable this across all AMD GPUs for system FFmpeg builds predating the upstream fix - everything works on RDNA4, and only specific resolutions are impacted on RDNA2 and RDNA3. In the end, this isn't a Firefox bug.
We could, however, block the specific resolutions observed to fail (144p, 720p) on pre-RDNA4 GPUs. Technically, though, to avoid the erroneous path altogether, direct export should be disabled on RADV when using FFmpeg builds predating the commit (except for FFVPX, where the fix was backported).
Updated•14 days ago
|
| Assignee | ||
Comment 38•14 days ago
|
||
Older system FFmpeg copies output DRM modifiers into its internal DPB
pool, which can cause video corruption on RADV at certain resolutions.
H.264 and HEVC use system FFmpeg and are not covered by the ffvpx backport.
Use the cached AMD vendor ID to block direct export when runtime
libavcodec is older than 63.20.101, the first upstream version bump after
the fix in b7e835e06913. Keep Vulkan decoding through the copy path.
Patched ffvpx and newer system FFmpeg remain eligible for direct export.
Combine this restriction with the existing NVIDIA forced-block-linear
restriction in a local directExportBlocked decision.
Comment 39•10 days ago
|
||
Comment 40•10 days ago
|
||
| bugherder | ||
Updated•14 hours ago
|
Description
•