googlevr / gvr-unity-sdk

Google VR SDK for Unity
http://developers.google.com/vr/unity/
Other
2.71k stars 1.09k forks source link

Detecting if a recenter event just happened appears to be broken #1055

Open SkyeOfBreeze opened 5 years ago

SkyeOfBreeze commented 5 years ago

SPECIFIC ISSUE ENCOUNTERED

Detecting the recenting event does not work every time, or not at all on Unity 2018 for some devices. This is needed to recenter some of the UI elements in the project where the issue started occurring

HARDWARE/SOFTWARE VERSIONS

Google Pixel XL running Android 9,

Google Pixel running Android 10,

Samsung Galaxy S8 running 8.0.0,

seems to work without issues on Motorola Moto Z XT1650-03 running Android 8.0.0

google/marlin/marlin:9/PQ3A.190705.001/5565753:user/release-keys,

google/sailfish/sailfish:10/QP1A.190711.019/5790879:user/release-keys,

samsung/dreamqltesq/dreamqltesq:8.0.0/R16NW/G950USQU5CRK1:user/release-keys,

motorola/griffin/griffin:8.0.0/OPL27.76-71-2-3/3:user/release-keys

Pixel


mBaseDisplayInfo=DisplayInfo{"Built-in Screen, displayId 0", uniqueId "local:0", app 1080 x 1920, real 1080 x 1920, largest app 1080 x 1920, smallest app 1080 x 1920, mode 1, defaultMode 1, modes [{id=1, width=1080, height=1920, fps=60.000004}], colorMode 0, supportedColorModes [0, 7], hdrCapabilities android.view.Display$HdrCapabilities@40f16308, rotation 0, density 420 (442.451 x 443.345) dpi, layerStack 0, appVsyncOff 2000000, presDeadline 11666666, type BUILT_IN, address {port=0}, state ON, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS, removeMode 0}

Pixel XL


mBaseDisplayInfo=DisplayInfo{"Built-in Screen", uniqueId "local:0", app 1440 x 2560, real 1440 x 2560, largest app 1440 x 2560, smallest app 1440 x 2560, mode 1, defaultMode 1, modes [{id=1, width=1440, height=2560, fps=60.000004}], colorMode 0, supportedColorModes [0, 7, 8], hdrCapabilities android.view.Display$HdrCapabilities@40f16308, rotation 0, density 560 (537.882 x 532.983) dpi, layerStack 0, appVsyncOff 2000000, presDeadline 11666666, type BUILT_IN, state ON, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS, removeMode 0}

Galaxy S8


 mBaseDisplayInfo=DisplayInfo{"Built-in Screen", uniqueId "local:0", app 1440 x 2960, real 1440 x 2960, largest app 1440 x 2960, smallest app 1440 x 2960, mode 1, defaultMode 1, modes [{id=1, width=1440, height=2960, fps=60.000004}, {id=2, width=1080, height=2220, fps=60.000004}, {id=3, width=720, height=1480, fps=60.000004}], colorMode 0, supportedColorModes [0], hdrCapabilities android.view.Display$HdrCapabilities@821b95f5, rotation 0, density 640 (562.707 x 565.293) dpi, layerStack 0, appVsyncOff 1000000, presDeadline 16666666, type BUILT_IN, state VR, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS, removeMode 0}

Motorola Moto Z

 mBaseDisplayInfo=DisplayInfo{"Built-in Screen", uniqueId "local:0", app 1440 x 2560, real 1440 x 2560, largest app 1440 x 2560, smallest app 1440 x 2560, mode 1, defaultMode 1, modes [{id=1, width=1440, height=2560, fps=60.000004}], colorMode 0, supportedColorModes [0], hdrCapabilities android.view.Display$HdrCapabilities@1d6308, rotation 0, density 640 (537.882 x 537.388) dpi, layerStack 0, appVsyncOff 1000000, presDeadline 16666666, type BUILT_IN, state ON, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS, removeMode 0}

Pixel


Packages:
    versionName=1.20.235017259
Hidden system packages:
    versionName=1.0.160607012
Active APEX packages:
Inactive APEX packages:
Factory APEX packages:

Pixel XL

Packages:
    versionName=1.20.235017259
Hidden system packages:
    versionName=1.15.195746028

Galaxy S8

Packages:
      versionName=1.20.235017259
  Hidden system packages:
      versionName=1.12.178282906

Moto Z

  Packages:
      versionName=1.20.235017259
  Hidden system packages:
      versionName=1.12.177372015

Daydream View (newer), but was not using headset

Demo project created with Unity 2018.4.4 or 2018.4.8

STEPS TO REPRODUCE THE ISSUE

  1. Create a new Unity project
  2. Set it to Android, and Set Daydream and Cardboard as VR options
  3. Set MinSDK level to 19 and target SDK level to 28
  4. Add a gameobject to the scene with the following code using the HelloVR demo
  5. Build and run to a device and recenter using the home button on the controller
    1. If there are issues with trying to reproduce, make sure script debugging and logging are both turned on

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DetectRecenter : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        GvrHeadset.OnRecenter += OnRecentered;
    }

    private void OnRecentered(GvrRecenterEventType recenterType, GvrRecenterFlags recenterFlags, Vector3 recenteredPosition, Quaternion recenteredOrientation)
    {
        Debug.Log("GvrHeadset.OnRecenter User Recentered"); //Seems to be more reliable, but not always hit
    }

    // Update is called once per frame
    void Update()
    {
        if (GvrControllerInput.Recentered) {
            Debug.Log("User Recentered"); //does not seem to be called on any device
        }
    }
}

WORKAROUNDS (IF ANY)

N/A

ADDITIONAL COMMENTS

GvrControllerInput.Recentered is what was used in 2017.4.30. On all devices no logs are received for that one, but the GvrHeadset.OnRecenter += OnRecentered method, logs show up on every controller recenter on the Moto Z.

By default Unity 2018 projects use the 4.x scripting runtime instead of the old 3.5 runtime. This setting was not changed from default, and is still at 4.x. No settings were customized.

Setting scripting runtime back to 3.5 does not fix the issue

SkyeOfBreeze commented 5 years ago

In case anyone runs into this, I worked around it by subscribing to recenter events via the Android SDK using Java code.

I subscribed to the recenter event using com.google.vr.sdk.controller.ControllerManager onRecentered() callback and sent it to unity using a callback.