Jan Grulich

DMA-BUF support in WebRTC

It will be almost three years since we landed initial support for screensharing on Wayland with the use of PipeWire in the WebRTC project. This enabled screensharing support in both major Linux browsers. Last year I implemented support for window sharing, added support for PipeWire 0.3 and added support for DMA-BUF and MemFD buffer types. Problem was, as it turned out, the DMA-BUF support was not implemented in a correct way.

The original implementation was using mmap() to get the buffer content. This worked correctly for current Intel GPUs, but was terrifically slow on e.g. AMD GPUs. Proper solution is to use OpenGL context to get the content from buffer. However, there were many implementations using mmap() already, including WebRTC and we needed a way how to properly communicate between the server and the client that when the client advertises DMA-BUF support, it means it doesn’t use mmap() and goes through OpenGL context instead.

Here are some issues if you want to read about the details:

This all resulted into a completely different way how the communication between the consumer and the producer should happen in order to use DMA buffers for way faster and smoother screensharing support. Both sides are now required to query the list of all supported modifiers and add this as a new stream parameter, including flags that the modifiers are mandatory parameter, rest of stream parameters are kept as before so we can keep using other types in case DMA-BUFs are not supported by the producer. Once both sides matches their expectations, we can query whether the stream includes modifiers, based on that we know we can use DMA buffers, which we now properly open using OpenGL context, while we kept mmap() for MemFd buffer types as fallback. This will result into faster screensharing support in your web browsers.

Last but not least, I made screensharing even faster, regardless of buffer type we use. Originally when we received buffer from PipeWire, we copied it to a local variable so we can apply cropping and adjust the position and only after that we copied this adjusted content into a DesktopFrame, which each DesktopCapturer (a class representing screensharing implementation) is supposed to return and let it be displayed by the browser. That means we performed two copy operations for each frame. I improved this implementation and now we copy the PW buffer content directly to a desktop frame which we can return directly so one copy operation less than before. I didn’t do some exact measures, but simply running htop and comparing usage of top 5 processes when sharing a 4k screen I got:

  • Original result: 66%, 64%, 26% 23%, 10%
  • Updated result: 41%, 39%, 19%, 17%, 12%

I also have some other improvements on my TODO list, all of them should bring some additional optimizations and improvements. I will keep you informed once I have news to share with you.

Both changes have been merged into WebRTC, that means it should be in Chrome/Chromium 96 (released during November 2021).

Calendar plasmoid

I finished my third plasmoid as part of my bachelors thesis. I hope it’s a little bit better than my previous plasmoids and I tried to make it as good equivalent to default KDE calendar plasmoid. Unlike the default KDE calendar plasmoid this plasmoid has separated agenda. You can choose how many weeks you want to display in agenda or choose various colors for various calendars or choose color for all parts of agenda widget.

The second part is “month view” where you can see days with events and display events in selected day. In settings you can choose colors for various cells.

In the end you can add event or edit existing event via default incidence editor. As my previous plasmoids it’s designed to use Akonadi-google resources so if you want to use all collections you will have to add -DALL_COLLECTIONS=true to cmake command.

I hope that someone will like it. If you find some bugs or you have some tips to improvements please let me know.

You can get it from my KDE git repository

Google contacts plasmoid

I changed some things in my Contacts plasmoid and I don’t know what could I improve on them so I decided to publish it on my blog. It’s my first plasmoid of my bachelor’s thesis and also my first plasmoid experience. I just chose it because it was the simplest part of my bachelor’s thesis and this plasmoid cannot do much. You can simply use it for quickly searching phone numbers or emails of your contacts. You can also edit your contacts or write them email by clicking on their email address. This plasmoid is designed to use Akonadi-google for your Google contacts but it could work with all Akonadi contacts collections. If you want to use all collections you will have to add -DALL_COLLECTIONS=true to cmake command.

Screenshot

I hope that someone will find this useful. If you find some bugs or you have some tips to improvements please let me know.

You can get it from my KDE git repository.

Bye.

Google tasks plasmoid

I just finished my second google plasmoid which is part of my bachelor’s thesis. It’s a plasmoid for displaying your tasks from your google account and you need for that Akonadi-google resources. I tried to make this plasmoid useful. It is not only for displaying your task but you can mark tasks as completed or simply add new tasks and you also can edit your existing tasks. If you don’t like default colors for tasks or tasks order, you can simply change it from appearance properties of this plasmoid.

Some screenshots:

You can get it from my KDE git repository where you can find my first google contact plasmoid.

If you like this plasmoid I will be happy and I will be also happy if you tell me about some bugs.

Bye 🙂

Scroll To Top