Bug 228056 - [GLib] Remove libportal dependency
Summary: [GLib] Remove libportal dependency
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Philippe Normand
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-07-18 04:33 PDT by Philippe Normand
Modified: 2021-07-23 03:52 PDT (History)
16 users (show)

See Also:


Attachments
Patch (33.49 KB, patch)
2021-07-18 04:54 PDT, Philippe Normand
no flags Details | Formatted Diff | Diff
Patch (33.10 KB, patch)
2021-07-18 10:23 PDT, Philippe Normand
no flags Details | Formatted Diff | Diff
Patch (32.98 KB, patch)
2021-07-20 04:26 PDT, Philippe Normand
no flags Details | Formatted Diff | Diff
Patch (33.17 KB, patch)
2021-07-22 03:56 PDT, Philippe Normand
no flags Details | Formatted Diff | Diff
Patch (33.22 KB, patch)
2021-07-22 06:55 PDT, Philippe Normand
cgarcia: review+
cgarcia: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Normand 2021-07-18 04:33:44 PDT
Let's do magic with GDBus instead.
Comment 1 Philippe Normand 2021-07-18 04:54:27 PDT
Created attachment 433748 [details]
Patch
Comment 2 Philippe Normand 2021-07-18 10:23:46 PDT
Created attachment 433751 [details]
Patch
Comment 3 Patrick Griffis 2021-07-18 12:54:26 PDT
I'm against this change. We are only going to depend on more and more portals and libportal does abstract complexity we shouldn't need to care about such as org.freedesktop.portal.Request objects which are easy to get wrong.
Comment 4 Patrick Griffis 2021-07-18 13:22:11 PDT
To be clear, I just mean we shouldn't *avoid* libportal. Not a review of the rest of the changes which appear to fix issues.
Comment 5 Philippe Normand 2021-07-19 01:29:51 PDT
I don't mind either way, we just need to agree on one approach or the other.

Two things that would be nice to have in libportal, support for embedding the mouse cursor in screencast sessions and a way to know which device type was selected by the user.
Comment 6 Carlos Garcia Campos 2021-07-19 02:30:09 PDT
Comment on attachment 433751 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=433751&action=review

There's too much sync DBus, I think, does that happen in the main thread?

> Source/WebCore/platform/mediastream/gstreamer/GStreamerCaptureDeviceManager.h:97
> +    public:

You don't need public for a struct

> Source/WebCore/platform/mediastream/gstreamer/GStreamerDisplayCaptureDeviceManager.cpp:65
> +    if (m_sessions.contains(device.persistentId())) {
> +        const auto it = m_sessions.find(device.persistentId());

Instead of constains + find you can do only find and check it != end
Comment 7 Philippe Normand 2021-07-19 05:54:20 PDT
(In reply to Carlos Garcia Campos from comment #6)
> Comment on attachment 433751 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=433751&action=review
> 
> There's too much sync DBus, I think, does that happen in the main thread?
> 

Yes. And this is a synchronous method, no way to avoid sync dbus with the current architecture.
Comment 8 Michael Catanzaro 2021-07-19 06:40:48 PDT
(In reply to Patrick Griffis from comment #4)
> To be clear, I just mean we shouldn't *avoid* libportal. Not a review of the
> rest of the changes which appear to fix issues.

If Phil doesn't want to use it for this particular portal, we can always bring it back later when we have something else that we want to use it for. I agree that we should use libportal whenever it's convenient to do so.

(In reply to Philippe Normand from comment #7)
> Yes. And this is a synchronous method, no way to avoid sync dbus with the
> current architecture.

Sync D-Bus on the main thread is awful, but sometimes it's very hard to avoid. :/
Comment 9 Philippe Normand 2021-07-20 04:18:15 PDT
Comment on attachment 433751 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=433751&action=review

>> Source/WebCore/platform/mediastream/gstreamer/GStreamerCaptureDeviceManager.h:97
>> +    public:
> 
> You don't need public for a struct

clang disagrees :)

../../Source/WebCore/platform/mediastream/gstreamer/GStreamerDisplayCaptureDeviceManager.cpp:67:24: error: 'fd' is a private member of 'WebCore::GStreamerDisplayCaptureDeviceManager::Session'
            it->value->fd, { }, constraints, device.type());
                       ^
../../Source/WebCore/platform/mediastream/gstreamer/GStreamerCaptureDeviceManager.h:101:13: note: declared private here
        int fd;
            ^
../../Source/WebCore/platform/mediastream/gstreamer/GStreamerDisplayCaptureDeviceManager.cpp:159:47: error: 'path' is a private member of 'WebCore::GStreamerDisplayCaptureDeviceManager::Session'
        "org.freedesktop.portal.Desktop", it->path.ascii().data(), "org.freedesktop.portal.Session", nullptr, nullptr));
                                              ^
../../Source/WebCore/platform/mediastream/gstreamer/GStreamerCaptureDeviceManager.h:102:16: note: declared private here
        String path;
               ^
Comment 10 Philippe Normand 2021-07-20 04:26:15 PDT
Created attachment 433868 [details]
Patch
Comment 11 Carlos Garcia Campos 2021-07-21 05:17:03 PDT
Comment on attachment 433868 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=433868&action=review

> Source/WebCore/platform/mediastream/gstreamer/GStreamerDisplayCaptureDeviceManager.cpp:147
> +    fd = g_unix_fd_list_get(fdList.get(), fdOut, nullptr);

Where is this fd closed?

> Source/WebCore/platform/mediastream/gstreamer/GStreamerDisplayCaptureDeviceManager.cpp:156
> +    auto it = m_sessions.take(persistentID);

Take doesn't return an iterator, this is session. I guess we should close the fd here, or in the Session destructor and it will be closed here too when out of scope.
Comment 12 Philippe Normand 2021-07-22 03:56:39 PDT
Created attachment 434004 [details]
Patch
Comment 13 Carlos Garcia Campos 2021-07-22 04:54:49 PDT
Comment on attachment 434004 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=434004&action=review

> Source/WebCore/platform/mediastream/gstreamer/GStreamerCaptureDeviceManager.h:96
> +        WTF_MAKE_FAST_ALLOCATED;

Why did you remove the macro for structs? Can we also make this non copyable? It this is copied we would end up closing the fd twice
Comment 14 Philippe Normand 2021-07-22 05:26:34 PDT
I messed up the patch, I'll re-upload one. Sorry!
Comment 15 Philippe Normand 2021-07-22 06:55:09 PDT
Created attachment 434008 [details]
Patch
Comment 16 Carlos Garcia Campos 2021-07-23 02:22:24 PDT
Comment on attachment 434008 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=434008&action=review

> Source/WebCore/platform/mediastream/gstreamer/GStreamerDisplayCaptureDeviceManager.cpp:72
> +    m_proxy = adoptGRef(g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
> +        static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES), nullptr,
> +        "org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop", "org.freedesktop.portal.ScreenCast", nullptr, nullptr));

Sorry that I didn't notice this in previous reviews but we should handle errors here.

> Source/WebCore/platform/mediastream/gstreamer/GStreamerDisplayCaptureDeviceManager.cpp:83
> +    GUniqueOutPtr<GError> error;
> +    auto result = adoptGRef(g_dbus_proxy_call_sync(m_proxy.get(), "CreateSession", g_variant_new("(a{sv})", &options),
> +        G_DBUS_CALL_FLAGS_NONE, s_dbusCallTimeout.millisecondsAs<int>(), nullptr, &error.outPtr()));

This error here isn't handled either.

> Source/WebCore/platform/mediastream/gstreamer/GStreamerDisplayCaptureDeviceManager.cpp:159
> +    auto proxy = adoptGRef(g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
> +        static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES), nullptr,
> +        "org.freedesktop.portal.Desktop", session->path.ascii().data(), "org.freedesktop.portal.Session", nullptr, nullptr));

And here proxy could null too if g_dbus_proxy_new_for_bus_sync fails
Comment 17 Philippe Normand 2021-07-23 03:51:49 PDT
Committed r280239 (239909@main): <https://commits.webkit.org/239909@main>
Comment 18 Radar WebKit Bug Importer 2021-07-23 03:52:16 PDT
<rdar://problem/81011828>