Bug 224353 - Initial implementation of WebChromeClient::enumerateImmersiveXRDevices() and XRDeviceProxy
Summary: Initial implementation of WebChromeClient::enumerateImmersiveXRDevices() and ...
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: Ada Chan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-04-08 18:31 PDT by Ada Chan
Modified: 2021-04-12 14:28 PDT (History)
7 users (show)

See Also:


Attachments
Patch (68.29 KB, patch)
2021-04-08 19:29 PDT, Ada Chan
dino: review+
Details | Formatted Diff | Diff
Patch (68.19 KB, patch)
2021-04-10 11:23 PDT, Ada Chan
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (68.89 KB, patch)
2021-04-12 11:51 PDT, Ada Chan
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ada Chan 2021-04-08 18:31:57 PDT
Initial implementation of WebChromeClient::enumerateImmersiveXRDevices() and XRDeviceProxy
Comment 1 Ada Chan 2021-04-08 19:29:56 PDT
Created attachment 425571 [details]
Patch
Comment 2 Tim Horton 2021-04-08 19:40:53 PDT
Comment on attachment 425571 [details]
Patch

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

Does not seem outrageous but I didn't quite finish

> Source/WebKit/Shared/WebCoreArgumentCoders.cpp:3410
> +    bool hasArray = WTF::holds_alternative<std::array<float, 16>>(projection);

Separately I wonder if we should give this std::array<float, 16> a typename

> Source/WebKit/Shared/WebCoreArgumentCoders.cpp:3441
> +        for (size_t i = 0; i < 16; ++i) {

...and if there's a way to extract this length from it, or otherwise not have to hard code this 16 here..

> Source/WebKit/Shared/WebCoreArgumentCoders.cpp:3539
> +#endif // ENABLE(WEBXR)

Remind me why these are all here instead of down in WebCore with their types? I feel like you had a reason in one case, but the rest of these all seem pretty trivial?
Comment 3 Dean Jackson 2021-04-08 19:57:40 PDT
Comment on attachment 425571 [details]
Patch

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

> Source/WebKit/Shared/Cocoa/XRDeviceProxy.h:31
> +#include <WebCore/PlatformXR.h>

Maybe include WeakPtr.h too? You're getting it from somewhere but that might not always be the case with unified builds. Although maybe that's silly since the same applies for Vector, Ref and Optional.

> Source/WebKit/Shared/Cocoa/XRDeviceProxy.mm:56
> +    if (m_trackingAndRenderingClient)
> +        m_trackingAndRenderingClient->sessionDidEnd();

I'm surprised this isn't done via an accessor.

> Source/WebKit/Shared/WebCoreArgumentCoders.cpp:3451
> +    return { nullptr };

Is that different from a nullopt?

> Source/WebKit/UIProcess/Cocoa/PlatformXRCoordinator.h:45
> +    // Session creation/termination

Nit: End comment with .

> Source/WebKit/UIProcess/Cocoa/PlatformXRCoordinator.h:46
> +    using OnSessionEndCallback = WTF::Function<void(XRDeviceIdentifier)>;

No need for WTF::

> Source/WebKit/UIProcess/Cocoa/PlatformXRCoordinator.h:50
> +    // Session display loop

Ditto.

> Source/WebKit/UIProcess/Cocoa/PlatformXRSystem.h:52
> +    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;

I think this can be final.

> Source/WebKit/UIProcess/Cocoa/PlatformXRSystem.mm:92
> +    if (PlatformXRCoordinator* xrCoordinator = PlatformXRSystem::xrCoordinator())

auto*

> Source/WebKit/UIProcess/Cocoa/PlatformXRSystem.mm:98
> +    if (PlatformXRCoordinator* xrCoordinator = PlatformXRSystem::xrCoordinator())

auto*

> Source/WebKit/WebProcess/cocoa/PlatformXRSystemProxy.mm:61
> +            RefPtr<XRDeviceProxy> device = deviceByIdentifier(deviceInfo.identifier);

auto device = 

You could also do this in the if test statement if you like.

> Source/WebKit/WebProcess/cocoa/PlatformXRSystemProxy.mm:89
> +    RefPtr<XRDeviceProxy> device = deviceByIdentifier(deviceIdentifier);

auto device =

Could also be in the if statement test.

> Source/WebKit/WebProcess/cocoa/PlatformXRSystemProxy.mm:97
> +        XRDeviceProxy* deviceProxy = static_cast<XRDeviceProxy*>(device.ptr());

auto* deviceProxy =
Comment 4 Ada Chan 2021-04-10 10:52:25 PDT
(In reply to Tim Horton from comment #2)
> Comment on attachment 425571 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=425571&action=review
> 
> Does not seem outrageous but I didn't quite finish
> 
> > Source/WebKit/Shared/WebCoreArgumentCoders.cpp:3410
> > +    bool hasArray = WTF::holds_alternative<std::array<float, 16>>(projection);
> 
> Separately I wonder if we should give this std::array<float, 16> a typename
> 
> > Source/WebKit/Shared/WebCoreArgumentCoders.cpp:3441
> > +        for (size_t i = 0; i < 16; ++i) {
> 
> ...and if there's a way to extract this length from it, or otherwise not
> have to hard code this 16 here..

I give this a typename and define a constant for its length.

> 
> > Source/WebKit/Shared/WebCoreArgumentCoders.cpp:3539
> > +#endif // ENABLE(WEBXR)
> 
> Remind me why these are all here instead of down in WebCore with their
> types? I feel like you had a reason in one case, but the rest of these all
> seem pretty trivial?

Yep, I'll move these down to WebCore.
Comment 5 Ada Chan 2021-04-10 11:00:14 PDT
(In reply to Dean Jackson from comment #3)
> Comment on attachment 425571 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=425571&action=review
> 
> > Source/WebKit/Shared/Cocoa/XRDeviceProxy.h:31
> > +#include <WebCore/PlatformXR.h>
> 
> Maybe include WeakPtr.h too? You're getting it from somewhere but that might
> not always be the case with unified builds. Although maybe that's silly
> since the same applies for Vector, Ref and Optional.

I'll include them all just in case.

> 
> > Source/WebKit/Shared/Cocoa/XRDeviceProxy.mm:56
> > +    if (m_trackingAndRenderingClient)
> > +        m_trackingAndRenderingClient->sessionDidEnd();
> 
> I'm surprised this isn't done via an accessor.

Will add an accessor.

> 
> > Source/WebKit/Shared/WebCoreArgumentCoders.cpp:3451
> > +    return { nullptr };
> 
> Is that different from a nullopt?

PlatformXR::Device::FrameData::Projection is a Variant where std::nullptr_t is one of the possible types. I'm not sure if the original author considered using an Optional here. We can consider this in a future patch.

> 
> > Source/WebKit/UIProcess/Cocoa/PlatformXRCoordinator.h:45
> > +    // Session creation/termination
> 
> Nit: End comment with .

Updated.

> 
> > Source/WebKit/UIProcess/Cocoa/PlatformXRCoordinator.h:46
> > +    using OnSessionEndCallback = WTF::Function<void(XRDeviceIdentifier)>;
> 
> No need for WTF::

Updated.

> 
> > Source/WebKit/UIProcess/Cocoa/PlatformXRCoordinator.h:50
> > +    // Session display loop
> 
> Ditto.

Updated.

> 
> > Source/WebKit/UIProcess/Cocoa/PlatformXRSystem.h:52
> > +    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
> 
> I think this can be final.

Fixed.

> 
> > Source/WebKit/UIProcess/Cocoa/PlatformXRSystem.mm:92
> > +    if (PlatformXRCoordinator* xrCoordinator = PlatformXRSystem::xrCoordinator())
> 
> auto*
> 
> > Source/WebKit/UIProcess/Cocoa/PlatformXRSystem.mm:98
> > +    if (PlatformXRCoordinator* xrCoordinator = PlatformXRSystem::xrCoordinator())
> 
> auto*
> 
> > Source/WebKit/WebProcess/cocoa/PlatformXRSystemProxy.mm:61
> > +            RefPtr<XRDeviceProxy> device = deviceByIdentifier(deviceInfo.identifier);
> 
> auto device = 
> 
> You could also do this in the if test statement if you like.
> 
> > Source/WebKit/WebProcess/cocoa/PlatformXRSystemProxy.mm:89
> > +    RefPtr<XRDeviceProxy> device = deviceByIdentifier(deviceIdentifier);
> 
> auto device =
> 
> Could also be in the if statement test.
> 
> > Source/WebKit/WebProcess/cocoa/PlatformXRSystemProxy.mm:97
> > +        XRDeviceProxy* deviceProxy = static_cast<XRDeviceProxy*>(device.ptr());
> 
> auto* deviceProxy =

Updated the above with auto and if test statement.

Thanks for all the feedback, Dean and Tim!
Comment 6 Ada Chan 2021-04-10 11:23:53 PDT
Created attachment 425688 [details]
Patch
Comment 7 EWS 2021-04-12 10:47:48 PDT
Patch 425688 does not build
Comment 8 Ada Chan 2021-04-12 11:51:39 PDT
Created attachment 425768 [details]
Patch
Comment 9 EWS 2021-04-12 12:38:41 PDT
Committed r275835 (236404@main): <https://commits.webkit.org/236404@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 425768 [details].
Comment 10 Radar WebKit Bug Importer 2021-04-12 12:39:13 PDT
<rdar://problem/76552456>