This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2028942 - Do not use DMA-BUFs for screensharing when the other side doesn't support it
Summary: Do not use DMA-BUFs for screensharing when the other side doesn't support it
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: mutter
Version: 8.5
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Jonas Ådahl
QA Contact: Michal Odehnal
URL:
Whiteboard:
Depends On:
Blocks: 2236180
TreeView+ depends on / blocked
 
Reported: 2021-12-03 19:19 UTC by Jan Grulich
Modified: 2023-09-18 07:27 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2236180 (view as bug list)
Environment:
Last Closed: 2023-09-18 07:27:31 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
GNOME Gitlab GNOME mutter merge_requests 1939 0 None None None 2021-12-03 19:29:25 UTC
Red Hat Issue Tracker   RHEL-4405 0 None Migrated None 2023-09-18 07:26:47 UTC
Red Hat Issue Tracker RHELPLAN-104745 0 None None None 2021-12-03 19:19:49 UTC

Description Jan Grulich 2021-12-03 19:19:11 UTC
Recent WebRTC has implemented proper screensharing support with DMA-BUFs and it has been already released with Chrome 96. Problem is that there are cases when DMA-BUFS is not supposed to be used, as of now it should be used only when PipeWire is new enough and both sides advertise DMA-BUFs modifiers. WebRTC doesn't advertise SPA_DATA_DmaBuf buffer type in this case and fallbacks to SPA_DATA_MemFd, however, Mutter (3.32 + related backports) in RHEL 8.5 seems to ignore that and sends SPA_DATA_DmaBuf buffers to us, which we fail to process. This results into broken screensharing.

Comment 6 Jan Grulich 2023-05-23 08:55:52 UTC
I think this might not need a fix at all, at least on Mutter side. I recently dropped support for the old DMA-BUFs (when modifiers are not announced). This was fixed with Chrome/Chromium M113 and will be backported to Firefox upstream soon. We probably just want to pick that change to our FF package instead. 

WebRTC fix: https://webrtc-review.googlesource.com/c/src/+/298700

Comment 7 Jan Grulich 2023-05-30 12:10:44 UTC
This is going to be fixed with Firefox ESR 115. Let's leave this open just to make sure it gets tested.

Fix includes backporting following WebRTC upstream change: https://webrtc-review.googlesource.com/c/src/+/298700

Comment 9 Jan Grulich 2023-08-24 13:02:08 UTC
(In reply to Jan Grulich from comment #7)
> This is going to be fixed with Firefox ESR 115. Let's leave this open just
> to make sure it gets tested.
> 
> Fix includes backporting following WebRTC upstream change:
> https://webrtc-review.googlesource.com/c/src/+/298700

Apparently it's not going to help.

I just patched Firefox to making sure DMABufs are not really advertised (there are not most likely advertised even in non-patched FF 115) and it still looks that Mutter enforces it and making screen sharing to fail.

Comment 10 Jan Grulich 2023-08-24 13:06:22 UTC
I believe the best would be to completely ignore DMABufs on RHEL 8 for screen sharing as the version of Mutter doesn't implement them properly (according to recent specs) and we have only PipeWire 0.3.6 which doesn't have all the required features (e.g. renegotiation).

Jonas, can we do something about that? Or any idea whether we can workaround that somehow from FF side? Because this fix otherwise needs to be backported all the way to all RHEL 8 z-streams.

Comment 11 Jonas Ådahl 2023-08-25 13:58:18 UTC
> Jonas, can we do something about that? Or any idea whether we can workaround that somehow from FF side? Because this fix otherwise needs to be backported all the way to all RHEL 8 z-streams.

We can disable it mutter side. The only potential consequence I can think of is OBS Studio getting worse performance, but I'm not sure it knows how to handle the legacy DMA buffer handling.

Comment 12 Jonas Ådahl 2023-08-25 13:58:55 UTC
The other downside is gnome-remote-desktop getting slightly worse performance on i915.

Comment 13 Jan Grulich 2023-08-28 06:37:07 UTC
(In reply to Jonas Ådahl from comment #11)
> > Jonas, can we do something about that? Or any idea whether we can workaround that somehow from FF side? Because this fix otherwise needs to be backported all the way to all RHEL 8 z-streams.
> 
> We can disable it mutter side. The only potential consequence I can think of
> is OBS Studio getting worse performance, but I'm not sure it knows how to
> handle the legacy DMA buffer handling.

OBS Studio does the same thing as WebRTC, they will announce SPA_DATA_DmaBuf support in case PipeWire 0.3.24 and newer is used or a modifier is passed (see #1). 

1) https://github.com/obsproject/obs-studio/blob/master/plugins/linux-pipewire/pipewire.c#L1043

We probably don't need to disable it, but I think the current version of Mutter (in RHEL 8) does something like:

>if (dma_buf_supported)
>  buffer_type = 1 << SPA_DATA_DmaBuf;
>else 
>  buffer_type = 1 << SPA_DATA_MemFD;

It's one or the other. If you announce both, it will be up to the client to decide whether to use SPA_DATA_DmaBuf based on their support.

Comment 14 Jan Grulich 2023-08-28 06:43:38 UTC
Looking into the rest of OBS Studio code, it doesn't seem to support SPA_DATA_MemFd, only SPA_DATA_MemPtr and I guess with Mutter it's the other way around, am I right?

Comment 15 Jan Grulich 2023-08-28 07:39:14 UTC
(In reply to Jan Grulich from comment #14)
> Looking into the rest of OBS Studio code, it doesn't seem to support
> SPA_DATA_MemFd, only SPA_DATA_MemPtr and I guess with Mutter it's the other
> way around, am I right?

Yes, looks I'm right looking into Mutter 3.32.2 we have in RHEL 8, but I might have found a bug in WebRTC. Old Mutter seems to skip this buffer type negotiation part and you just either push a MemFd or DmaBuf buffers, which is what decides what's going to be used. If this step is skipped, we in WebRTC don't even fallback to a DRM_FORMAT_MOD_INVALID used for modifier-less buffers and the modifier variable remains unset, resulting into importing DmaBufs with invalid modifier. 

I'm currently building a scratch build of Firefox to check whether this makes a difference.

Comment 16 Jonas Ådahl 2023-08-28 09:28:13 UTC
(In reply to Jan Grulich from comment #14)
> Looking into the rest of OBS Studio code, it doesn't seem to support
> SPA_DATA_MemFd, only SPA_DATA_MemPtr and I guess with Mutter it's the other
> way around, am I right?

MemFd is for accessing shared memory, and MemPtr is for accessing memory mapped by PipeWire by passing PW_STREAM_FLAG_MAP_BUFFERS to pw_stream_connect() so that should not be an issue.

> in WebRTC don't even fallback to a DRM_FORMAT_MOD_INVALID used for modifier-less buffers and the modifier variable remains unset, resulting into importing DmaBufs with invalid modifier. 

Don't you need to handle using modifierless API for allocation either way when there are no explicit modifiers negotiated? There are IIRC drivers that simply do not support using the modifier-aware API variants.

Comment 17 Jan Grulich 2023-08-28 10:21:53 UTC
(In reply to Jonas Ådahl from comment #16)
> > in WebRTC don't even fallback to a DRM_FORMAT_MOD_INVALID used for modifier-less buffers and the modifier variable remains unset, resulting into importing DmaBufs with invalid modifier. 
> 
> Don't you need to handle using modifierless API for allocation either way
> when there are no explicit modifiers negotiated? There are IIRC drivers that
> simply do not support using the modifier-aware API variants.

We handle that and looking into the logs it seems to fail on creating EGLImage (with EGL_BAD_PARAMETER). I was wrong with that assumption before and it ends up not having explicit modifier using DRM_FORMAT_MOD_INVALID to indicate that. I also tried OBS Studio and it doesn't work either. Could that be a VM limitation?

Comment 18 Jan Grulich 2023-08-28 10:37:57 UTC
OBS Studio from Flathub I've been testing doesn't seem to work because of incompatibility of PipeWire library used in the runtime and the PipeWire running on the server (RHEL 8 - which is PW 0.3.6).

Comment 19 Jonas Ådahl 2023-08-28 11:19:03 UTC
Cc:ing Wim: Seems to be some backward compatibility problems with newer libpipewire in Flatpaks working on RHEL8 hosts.

Comment 20 Jan Grulich 2023-08-28 11:46:07 UTC
Created attachment 1985650 [details]
Patch allowing to fallback to MemFd buffers

I can make it work when I use the attached Mutter patch. I believe this is a correct thing to do. Not sure if my version is correct code-wise, but the logic is from modern Mutter releases. This allows clients to pick what they actually support.

Comment 21 Jan Grulich 2023-08-28 14:07:45 UTC
Jonas, what do you think about the patch in comment 20? I have tested it in RHEL 8.4 and RHEL 8.6 and it makes Firefox to properly share a screen in a VM. You can think of it as a partial backport from recent Mutter. I can handle this bug and all the builds if you want and agree with this patch.

Comment 29 RHEL Program Management 2023-09-17 14:51:23 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 30 RHEL Program Management 2023-09-18 07:27:31 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.


Note You need to log in before you can comment on or make changes to this bug.