Bug 170814 - [MediaStream] Push capabilities across process boundary during UIProcess capture.
Summary: [MediaStream] Push capabilities across process boundary during UIProcess capt...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jer Noble
URL:
Keywords: InRadar
Depends on:
Blocks: 170846
  Show dependency treegraph
 
Reported: 2017-04-13 10:49 PDT by Jer Noble
Modified: 2020-06-01 14:55 PDT (History)
7 users (show)

See Also:


Attachments
Patch (32.60 KB, patch)
2017-04-13 11:12 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch (32.14 KB, patch)
2017-04-13 11:29 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch (33.32 KB, patch)
2017-04-13 11:37 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch for landing (33.32 KB, patch)
2017-04-13 12:14 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch for landing (33.37 KB, patch)
2017-04-13 12:30 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch for landing (33.85 KB, patch)
2017-04-13 14:48 PDT, Jer Noble
achristensen: review+
Details | Formatted Diff | Diff
Patch for landing (42.95 KB, patch)
2017-04-13 18:13 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch for landing (42.91 KB, patch)
2017-04-14 08:08 PDT, Jer Noble
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jer Noble 2017-04-13 10:49:40 PDT
[MediaSource] Push capabilities across process boundary during UIProcess capture.
Comment 1 Jer Noble 2017-04-13 11:12:17 PDT
Created attachment 306998 [details]
Patch
Comment 2 Jer Noble 2017-04-13 11:29:24 PDT
Created attachment 306999 [details]
Patch
Comment 3 Jer Noble 2017-04-13 11:37:28 PDT
Created attachment 307002 [details]
Patch
Comment 4 Eric Carlson 2017-04-13 11:39:42 PDT
Comment on attachment 307002 [details]
Patch

Looks fine to me, but a real WK2 reviewer will have to give it an official r+.
Comment 5 Jer Noble 2017-04-13 12:14:32 PDT
Created attachment 307011 [details]
Patch for landing
Comment 6 Jer Noble 2017-04-13 12:30:49 PDT
Created attachment 307012 [details]
Patch for landing
Comment 7 Jon Lee 2017-04-13 13:28:28 PDT
rdar://problem/31435730
Comment 8 Alex Christensen 2017-04-13 13:30:47 PDT
Comment on attachment 307012 [details]
Patch for landing

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

> Source/WebCore/platform/mediastream/RealtimeMediaSourceCapabilities.h:133
> +    RealtimeMediaSourceCapabilities()
> +    {
> +    }

= default;

> Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:152
> +void UserMediaCaptureManagerProxy::capabilities(uint64_t id, std::optional<WebCore::RealtimeMediaSourceCapabilities>& capabilities)

Why not just return a std::optional?

> Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:161
> +    else
> +        capabilities = std::nullopt;

Is it necessary to set capabilities to nullopt here?  If so, why isn't it done in the early return?

> Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.cpp:144
> +    mutable bool m_capabilitiesInitialized { false };
> +    mutable std::optional<RealtimeMediaSourceCapabilities> m_capabilities;

This is very strange.  std::optional keeps track of whether it is initialized.  If you need more states than that, use WTF::Expected.

> Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.cpp:250
> +    m_process.sendSync(Messages::UserMediaCaptureManagerProxy::Capabilities(id), Messages::UserMediaCaptureManagerProxy::Capabilities::Reply(capabilities), 0);

Why do we need to add another sync message?
Comment 9 Jer Noble 2017-04-13 14:16:08 PDT
(In reply to Alex Christensen from comment #8)
> Comment on attachment 307012 [details]
> Patch for landing
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=307012&action=review
> 
> > Source/WebCore/platform/mediastream/RealtimeMediaSourceCapabilities.h:133
> > +    RealtimeMediaSourceCapabilities()
> > +    {
> > +    }
> 
> = default;

Ok.

> > Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:152
> > +void UserMediaCaptureManagerProxy::capabilities(uint64_t id, std::optional<WebCore::RealtimeMediaSourceCapabilities>& capabilities)
> 
> Why not just return a std::optional?

Because that makes the message binding code super unhappy.

> > Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:161
> > +    else
> > +        capabilities = std::nullopt;
> 
> Is it necessary to set capabilities to nullopt here?  If so, why isn't it
> done in the early return?

Yes.

> > Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.cpp:144
> > +    mutable bool m_capabilitiesInitialized { false };
> > +    mutable std::optional<RealtimeMediaSourceCapabilities> m_capabilities;
> 
> This is very strange.  std::optional keeps track of whether it is
> initialized.  If you need more states than that, use WTF::Expected.


Alex and I discussed offline and I may have managed to convince him that std::optional<std::unique_ptr<Capabilities>> is OK.

> > Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.cpp:250
> > +    m_process.sendSync(Messages::UserMediaCaptureManagerProxy::Capabilities(id), Messages::UserMediaCaptureManagerProxy::Capabilities::Reply(capabilities), 0);
> 
> Why do we need to add another sync message?

Because the caller expects to receive a reply synchronously.
Comment 10 Jer Noble 2017-04-13 14:48:00 PDT
Created attachment 307028 [details]
Patch for landing
Comment 11 Jer Noble 2017-04-13 18:13:49 PDT
Created attachment 307064 [details]
Patch for landing

After discussing this with other members of the WebKit team, it became apparent that the best option was to remove the possibility of returning nullptr from RealtimeMediaSource::capabilities().
Comment 12 Jer Noble 2017-04-14 08:08:06 PDT
Created attachment 307113 [details]
Patch for landing

One last version to make the GTK bts happy.
Comment 13 WebKit Commit Bot 2017-04-14 09:04:55 PDT
Comment on attachment 307113 [details]
Patch for landing

Clearing flags on attachment: 307113

Committed r215362: <http://trac.webkit.org/changeset/215362>
Comment 14 Sam Weinig 2017-04-18 19:36:07 PDT
(In reply to Jer Noble from comment #9)
> (In reply to Alex Christensen from comment #8)
> > Comment on attachment 307012 [details]
> > Patch for landing
> > > Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.cpp:250
> > > +    m_process.sendSync(Messages::UserMediaCaptureManagerProxy::Capabilities(id), Messages::UserMediaCaptureManagerProxy::Capabilities::Reply(capabilities), 0);
> > 
> > Why do we need to add another sync message?
> 
> Because the caller expects to receive a reply synchronously.

Can you go into more detail about this? Adding more synchronous calls is something that should be taken very seriously, and all alternatives should be discussed before going forward with it. Why can't capabilities be pushed to the WebProcess proactively when the source is created?
Comment 15 Maciej Stachowiak 2020-06-01 14:55:43 PDT
Comment on attachment 307002 [details]
Patch

Unflagging and obsoleting, since there is a newer patch for landing.