Bug 182999

Summary: [WebVR][OpenVR] Retrieve displayId and the z-depth of eye view frustum
Product: WebKit Reporter: Sergio Villar Senin <svillar>
Component: New BugsAssignee: Sergio Villar Senin <svillar>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, svillar, webkit-bug-importer, zan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
zan: review+
Patch none

Description Sergio Villar Senin 2018-02-21 05:02:15 PST
[WebVR][OpenVR] Retrieve displayId and the z-depth of eye view frustum
Comment 1 Sergio Villar Senin 2018-02-21 05:06:57 PST
Created attachment 334365 [details]
Patch
Comment 2 Zan Dobersek 2018-02-22 06:28:16 PST
Comment on attachment 334365 [details]
Patch

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

> Source/WebCore/Modules/webvr/VRDisplay.cpp:49
> +    , m_depthNear(0.01) // Default value from spec.
> +    , m_depthFar(10000) // Default value from spec.

Members that are being initialized with such constants can be initialized at the point of declaration.

> Source/WebCore/Modules/webvr/VRDisplay.h:110
>      String m_displayName;
> +    unsigned m_displayId;

Nit: these should follow the order of the relevant getters.

> Source/WebCore/Modules/webvr/VRDisplay.h:113
> +    double m_depthNear;
> +    double m_depthFar;

For instance:

    double m_depthNear { 0.01 };
    double m_depthFar { 10000 };

> Source/WebCore/platform/vr/VRManager.cpp:64
> +unsigned long VRManager::s_displayIdentifier = 0;
> +
> +unsigned long VRManager::generateUniqueDisplayIdentifier()
> +{
> +    return ++s_displayIdentifier;
> +}

I think this should be an implementation detail of the OpenVR backend. I.e. some other implementation may have a better way of determining the unique display identifier than to use a static counter.

> Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.cpp:36
> +    m_displayInfo.displayIdentifier = VRManager::generateUniqueDisplayIdentifier();

unsigned long is being narrowed down to unsigned.
Comment 3 Sergio Villar Senin 2018-02-26 02:07:55 PST
Created attachment 334600 [details]
Patch
Comment 4 Zan Dobersek 2018-02-26 02:35:11 PST
Comment on attachment 334600 [details]
Patch

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

> Source/WebCore/Modules/webvr/VRDisplay.h:63
> +    unsigned displayId() const { return m_displayId; }

displayId attribute on the VRDisplay interface has the 'unsigned long' type, which in IDLTypes.h (through IDUnsignedLong) maps to uint32_t. IMO we should explicitly use uint32_t here too, as well as in the m_displayId declaration in this class.

> Source/WebCore/platform/vr/VRPlatformDisplay.h:50
> +    unsigned long displayIdentifier;

Since this directly maps to the displayId attribute in VRDisplay, this too should be uint32_t.

> Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.cpp:38
> +    m_displayInfo.displayIdentifier = ++s_displayIdentifier;

Problem is that in this case you're assigning from a 64-bit value to a 32-bit one. In reality this probably won't be a problem, but it's a small issue.
Comment 5 Sergio Villar Senin 2018-02-26 03:57:55 PST
Created attachment 334608 [details]
Patch

Patch for landing
Comment 6 Sergio Villar Senin 2018-02-26 05:38:03 PST
Committed r229014: <https://trac.webkit.org/changeset/229014>
Comment 7 Radar WebKit Bug Importer 2018-02-26 05:39:23 PST
<rdar://problem/37898645>