Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Using openvr on windows leads to TrackedDevicePose_t uninitilized error #105

Open
ghost opened this issue Apr 2, 2021 · 6 comments
Open

Comments

@ghost
Copy link

ghost commented Apr 2, 2021

Hi,

i am using the HTC Vive on windows, with OpenVR.
If i start use the device like in the example, i get an error, TrackedDevicePose_t uninitilized.
The stacktrace leads to:
https://github.com/servo/rust-webvr/blob/master/rust-webvr/src/api/openvr/display.rs#L118

At first i tought i did setup the device wrong, but seeing the code two lines above. Can it be, that indeed struct should be initilized?

Rust Version:
nightly-x86_64-pc-windows-msvc (default)
rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)

' panicked at 'attempted to leave type `api::openvr::binding::TrackedDevicePose_t` uninitialized, which is invalid', C:\Users\gojira\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\mem\mod.rs:660:9
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597\/library\std\src\panicking.rs:493
   1: core::panicking::panic_fmt
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597\/library\core\src\panicking.rs:92
   2: core::panicking::panic
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597\/library\core\src\panicking.rs:50
   3: core::mem::uninitialized
             at C:\Users\gojira\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\mem\mod.rs:660
   4: rust_webvr::api::openvr::display::{{impl}}::synced_frame_data
             at C:\Users\gojira\.cargo\registry\src\github.com-1ecc6299db9ec823\rust-webvr-0.19.0\src\api\openvr\display.rs:118
   5: shadow_of_truth::vr::VirtualReality::sync_data
@ghost
Copy link
Author

ghost commented Apr 2, 2021

And indeed proper initilizing the struct, resolves this error.

 let mut display_pose = openvr::TrackedDevicePose_t {
    mDeviceToAbsoluteTracking: openvr::HmdMatrix34_t {
        m: [
            [0.0, 0.0, 0.0, 0.0],
            [0.0, 0.0, 0.0, 0.0],
            [0.0, 0.0, 0.0, 0.0],
        ]
    },
    vVelocity: openvr::HmdVector3_t { v: [0.0, 0.0, 0.0] },
    vAngularVelocity: openvr::HmdVector3_t { v: [0.0, 0.0, 0.0] },
    eTrackingResult: openvr::ETrackingResult::ETrackingResult_TrackingResult_Uninitialized,
    bPoseIsValid: false,
    bDeviceIsConnected: false,
};

After a quick google, this error ocours because, std::mem::uninitilized is considered deprecated and unsave.

At this point i would encourage to use either a sane Default implementation or using MaybeUninit!

But i see this all over the code base, so it would be really nice to fix this.
I am suprised no one stumbled about this earlier.

@Manishearth
Copy link
Member

Servo mostly switched over to https://github.com/servo/webxr which has a safer design.

@jdm
Copy link
Member

jdm commented Apr 2, 2021

More specifically: this crate is unmaintained, and we would be happy to hand over control of it to anybody who would like to maintain it.

@ghost
Copy link
Author

ghost commented Apr 3, 2021

Well, it seems, that in genarel OpenVR is outdated in the favor of OpenXR.
But after another short googleing session, it seems, that it does not make sense to maintain this repo, because OpenXR is the way to go. So makes sense that servo switched to webxr.

Or is there any real need for this repo, that i am not aware of?

@jdm
Copy link
Member

jdm commented Apr 3, 2021

The only use case for this repo that I'm aware of is for VR integration on platforms where openxr isn't available.

@ghost
Copy link
Author

ghost commented Apr 12, 2021

This would be the HTC Vive Cosmos for example :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants