googlevr / gvr-unity-sdk

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

Latest VR Services (1.13.185188193) causes black screen at startup when launched in VR #855

Closed dustinkerstein closed 6 years ago

dustinkerstein commented 6 years ago

As originally noted in #766

With the latest VR Services (1.13.185188193) and applications built with 2017.2.1p4, 2017.1.3p1, or 2017.1.2p4 (and maybe others), when the app is launched with a Daydream View headset configured and in VR mode (loading the daydream device), you may end up with a black screen in VR mode after pairing with the controller even though the app is in fact running in the background (confirmed via logging).

It doesn't seem to happen on the first app launch, but subsequent launches usually trigger it. Also, it only happens when directly launching the app from the home screen. If you launch from the Daydream Home, this will not happen. I've replicated across several Unity versions on multiple phones (Pixel XL and Moto Z) and the only things that seem to have an effect are:

  1. Uninstalling VR services and installing an earlier version manually and hitting cancel when it asks you to update VR services (the latest update seems to be mandatory)
  2. Unity 2017.3.1p1, which isn't really a viable solution as it breaks Cardboard support

It seems like there are two options currently: live with the black screen (no idea how often it will actually happen in the wild) or upgrade to 2017.3.1p1 and break Cardboard support :(

Has anyone else seen this yet? Here's an empty Daydream project using Unity 2017.1.2p4 that replicates this issue ~40% of the time on startup for me on my Pixel XL - https://www.dropbox.com/s/37ld6u5i95ofnqg/DaydreamTest.zip?dl=0 - Just make sure to try more than a couple times as it can be a little fluky.

Update - Unity 2017.2.1p2 doesn't exhibit either of the two issues mentioned above and appears to be a solid workaround for now.

dustinkerstein commented 6 years ago

On Unity versions where this is visible I am able to fix the issue by disabling GVR SDK library loading in the Daydream developer tools. Here is the GVR debug log of the load of the empty demo app posted above when the issue occurs:

02-24 10:13:15.747 28885-28885/? I/Ion: [vr/gvr/capi/src/gvr_core_api_loader_android.cc:177] Successfully loaded GVR library version 1.130.0 from VrCore (target was 1.80.0).
02-24 10:13:15.800 28885-28885/? I/GVR: [vr/gvr/capi/src/gvr.cc:103] Initialized GVR version 1.130.0
02-24 10:13:15.826 28885-28885/? I/GvrLayoutFactory: Successfully loaded GvrLayout from VrCore.
02-24 10:13:15.829 28885-28885/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:1800] In-process composition enabled for Daydream
02-24 10:13:15.829 28885-28885/? I/GVR: [vr/gvr/render/scanline_racer.cc:1225] Configuring scanline racer for griffin using custom config.
02-24 10:13:15.912 28885-28913/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:495] Creating swap chain with id: [1]
02-24 10:13:15.912 28885-28913/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:499]   BufferSpec 0: Size=V[1850, 2184], ColorFormat=Rgba8888, Samples=0, Views=1
02-24 10:13:15.912 28885-28913/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:499]   BufferSpec 1: Size=V[1850, 2184], ColorFormat=Rgba8888, Samples=0, Views=1
02-24 10:13:15.913 28885-28913/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:495] Creating swap chain with id: [4]
02-24 10:13:15.913 28885-28913/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:499]   BufferSpec 0: Size=V[1295, 1529], ColorFormat=Rgba8888, Samples=0, Views=1
02-24 10:13:15.913 28885-28913/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:499]   BufferSpec 1: Size=V[1295, 1529], ColorFormat=Rgba8888, Samples=0, Views=1
02-24 10:13:16.239 28885-28951/? I/GVR: [vr/gvr/render/scanline_racer.cc:333] Scanline racing enabled with context sharing
02-24 10:13:16.338 28885-28951/? W/GVR: [vr/gvr/render/scanline_racer.cc:1392] Missed vsync by 50280us (CPU load is too high)
02-24 10:13:18.946 2504-2504/? I/GVR: [vr/gvr/capi/src/gvr.cc:103] Initialized GVR version 1.130.0
02-24 10:13:18.965 2504-2504/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:1800] In-process composition enabled for Daydream
02-24 10:13:18.965 2504-2504/? I/GVR: [vr/gvr/render/scanline_racer.cc:1225] Configuring scanline racer for griffin using custom config.
02-24 10:13:19.102 2504-28981/? I/GVR: [vr/gvr/render/scanline_racer.cc:333] Scanline racing enabled with context sharing
02-24 10:13:19.108 2504-28982/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:495] Creating swap chain with id: [15]
02-24 10:13:19.108 2504-28982/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:499]   BufferSpec 0: Size=V[2959, 1747], ColorFormat=Rgba8888, DepthFormat=RenderbufferDepth24Stencil8, Samples=2, Views=1
02-24 10:13:19.425 2504-28981/? W/GVR: [vr/gvr/render/scanline_racer.cc:1392] Missed vsync by 8863us (CPU load is too high)

And with GVR SDK library loading disabled:

02-24 10:10:59.308 27592-27592/? V/GvrLayoutFactory: Dynamic library loading disabled, using built-in GvrLayout implementation.
02-24 10:10:59.336 27592-27592/? I/GVR: [vr/gvr/capi/src/gvr.cc:105] Initialized GVR version 1.80.0
02-24 10:10:59.357 27592-27592/? D/GvrLayoutFactory: Loaded GvrLayout from SDK.
02-24 10:10:59.359 27592-27592/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:1503] In-process composition enabled for Daydream
02-24 10:10:59.359 27592-27592/? I/GVR: [vr/gvr/render/scanline_racer.cc:1019] Configuring scanline racer for griffin using custom config.
02-24 10:11:02.998 2504-2504/? I/GVR: [vr/gvr/capi/src/gvr.cc:103] Initialized GVR version 1.130.0
02-24 10:11:03.023 2504-2504/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:1800] In-process composition enabled for Daydream
02-24 10:11:03.023 2504-2504/? I/GVR: [vr/gvr/render/scanline_racer.cc:1225] Configuring scanline racer for griffin using custom config.
02-24 10:11:03.169 2504-27731/? I/GVR: [vr/gvr/render/scanline_racer.cc:333] Scanline racing enabled with context sharing
02-24 10:11:03.173 2504-27732/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:495] Creating swap chain with id: [9]
02-24 10:11:03.173 2504-27732/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:499]   BufferSpec 0: Size=V[2959, 1747], ColorFormat=Rgba8888, DepthFormat=RenderbufferDepth24Stencil8, Samples=2, Views=1
02-24 10:11:03.407 2504-27731/? W/GVR: [vr/gvr/render/scanline_racer.cc:364] GPU commands did not finish for strip 0, expect tearing
02-24 10:11:03.413 2504-27731/? W/GVR: [vr/gvr/render/scanline_racer.cc:1392] Missed vsync by 13787us (CPU load is too high)
02-24 10:11:06.653 27592-27691/? I/GVR: [vr/gvr/render/scanline_racer.cc:285] Scanline racing enabled with context sharing
02-24 10:11:06.875 27592-27691/? I/GVR: [vr/gvr/render/scanline_racer.cc:285] Scanline racing enabled with context sharing
02-24 10:11:14.178 27942-27942/? V/GvrLayoutFactory: Dynamic library loading disabled, using built-in GvrLayout implementation.
02-24 10:11:14.204 27942-27942/? I/GVR: [vr/gvr/capi/src/gvr.cc:105] Initialized GVR version 1.80.0
02-24 10:11:14.225 27942-27942/? D/GvrLayoutFactory: Loaded GvrLayout from SDK.
02-24 10:11:14.227 27942-27942/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:1503] In-process composition enabled for Daydream
02-24 10:11:14.227 27942-27942/? I/GVR: [vr/gvr/render/scanline_racer.cc:1019] Configuring scanline racer for griffin using custom config.
02-24 10:11:14.451 27942-28009/? I/GVR: [vr/gvr/render/scanline_racer.cc:285] Scanline racing enabled with context sharing
02-24 10:11:14.540 27942-28009/? W/GVR: [vr/gvr/render/scanline_racer.cc:1200] Missed vsync by 61758us (CPU load is too high)
02-24 10:11:26.241 28044-28044/? V/GvrLayoutFactory: Dynamic library loading disabled, using built-in GvrLayout implementation.
02-24 10:11:26.272 28044-28044/? I/GVR: [vr/gvr/capi/src/gvr.cc:105] Initialized GVR version 1.80.0
02-24 10:11:26.300 28044-28044/? D/GvrLayoutFactory: Loaded GvrLayout from SDK.
02-24 10:11:26.302 28044-28044/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:1503] In-process composition enabled for Daydream
02-24 10:11:26.302 28044-28044/? I/GVR: [vr/gvr/render/scanline_racer.cc:1019] Configuring scanline racer for griffin using custom config.
02-24 10:11:26.618 28044-28112/? I/GVR: [vr/gvr/render/scanline_racer.cc:285] Scanline racing enabled with context sharing
02-24 10:11:26.656 28044-28112/? W/GVR: [vr/gvr/render/scanline_racer.cc:1200] Missed vsync by 15132us (CPU load is too high)
02-24 10:11:29.260 2504-2504/? I/GVR: [vr/gvr/capi/src/gvr.cc:103] Initialized GVR version 1.130.0
02-24 10:11:29.274 2504-2504/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:1800] In-process composition enabled for Daydream
02-24 10:11:29.274 2504-2504/? I/GVR: [vr/gvr/render/scanline_racer.cc:1225] Configuring scanline racer for griffin using custom config.
02-24 10:11:29.466 2504-28143/? I/GVR: [vr/gvr/render/scanline_racer.cc:333] Scanline racing enabled with context sharing
02-24 10:11:29.468 2504-28144/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:495] Creating swap chain with id: [11]
02-24 10:11:29.468 2504-28144/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:499]   BufferSpec 0: Size=V[2959, 1747], ColorFormat=Rgba8888, DepthFormat=RenderbufferDepth24Stencil8, Samples=2, Views=1
02-24 10:11:29.620 2504-28143/? W/GVR: [vr/gvr/render/scanline_racer.cc:1392] Missed vsync by 7456us (CPU load is too high)
02-24 10:11:31.237 28044-28112/? W/GVR: [vr/gvr/render/scanline_racer.cc:1200] Missed vsync by 4480965us (CPU load is too high)
02-24 10:11:46.707 28336-28336/? V/GvrLayoutFactory: Dynamic library loading disabled, using built-in GvrLayout implementation.
02-24 10:11:46.732 28336-28336/? I/GVR: [vr/gvr/capi/src/gvr.cc:105] Initialized GVR version 1.80.0
02-24 10:11:46.752 28336-28336/? D/GvrLayoutFactory: Loaded GvrLayout from SDK.
02-24 10:11:46.755 28336-28336/? I/GVR: [vr/gvr/hmd/cardboard/cardboard_api_impl.cc:1503] In-process composition enabled for Daydream
02-24 10:11:46.755 28336-28336/? I/GVR: [vr/gvr/render/scanline_racer.cc:1019] Configuring scanline racer for griffin using custom config.
02-24 10:11:46.984 28336-28402/? I/GVR: [vr/gvr/render/scanline_racer.cc:285] Scanline racing enabled with context sharing
02-24 10:11:47.033 28336-28402/? W/GVR: [vr/gvr/render/scanline_racer.cc:1200] Missed vsync by 8752us (CPU load is too high)
dustinkerstein commented 6 years ago

Quick update - Turning the screen off and then on when this issue occurs seems to fix it.

Also, I am not able to replicate this on 2017.2.1p2 - So even though disabling GVR Library Loading helps on versions that are affected, it doesn't seem like it's directly caused by the 1.80 -> 1.100 NDK upgrade that happened recently in Unity patch releases as 2017.3.1p1 (which also has NDK 1.100) doesn't exhibit this behavior. This is particularly useful info for me as I believe it's the only version I've tested so far that doesn't exhibit this black screen issue nor the broken Cardboard support - though I imagine there are other recent Unity versions that don't have these issues - I just haven't had a chance to test a lot of them.

rusmaxham commented 6 years ago

Thanks for reporting this. We'll take a look.

fredsa commented 6 years ago

EDIT: Fixed my typo; I originally said 2017.1.3p2 (wrong) but meant 2017.3.1p2 (correct).

Unity 2017.3.1p2 (https://unity3d.com/unity/qa/patch-releases) contains a fix for

(971671) - Android: Fixed black screen in when using Daydream unless started through the Daydream VR launcher.

Can you confirm whether 2017.3.1p2 fixes your project, so we can confirm that 971671 the problem you're experiencing ?

dustinkerstein commented 6 years ago

@fredsa, do you have a direct link for 2017.1.3p2? It doesn't seem like that version is available yet. I only see 2017.1.3p1.

Adam-VisualVocal commented 6 years ago

https://unity3d.com/unity/qa/patch-releases/2017.3.1p2

dustinkerstein commented 6 years ago

Ah, 3.1p2 not 1.3p2 - I will give it a try. However, as noted above, I was not able to reproduce this on Unity 2017.3.1p1 so I'm not sure what to make of that. Also, I can't use 2017.3.1p1 as it entirely breaks Cardboard support. Maybe that's fixed in P2... I will test later today.

fredsa commented 6 years ago

Apologies for the version mixup. 2017.3.1p2 is correct.

dustinkerstein commented 6 years ago

No worries. 2017.3.1p2 seems to be better (like 2017.3.1p1), though I did see 1 black screen out of around 30 attempts. However, unfortunately this patch isn't really viable as it breaks Cardboard support entirely for non-Daydream phones. Is it possible this black screen issue can be resolved with another VR Services update?

fredsa commented 6 years ago

Would you mind filing a new issue with whatever Cardboard problems you're seeing in 2017.3.1p2 ? A few extra things that would help to report in that issue:

fredsa commented 6 years ago

Would you mind filing a separate issue for the Daydream 1 black screen out of around 30 attempts when building with Unity 2017.3.1p2?

dustinkerstein commented 6 years ago

This is already reported in Unity here but do you feel I should also write up the issue for this repo?

fredsa commented 6 years ago

The specific black screen issue that exists in Unity 2017.3.1p1 was fixed in Unity 2017.3.1p2:

(971671) - Android: Fixed black screen in when using Daydream unless started through the Daydream VR launcher.

For clarity, let's close this issue. We can track the new / separate 2017.3.1p2 issues in new issues.

fredsa commented 6 years ago

This is already reported in Unity here but do you feel I should also write up the issue for this repo? Thanks for filing the Unity case and providing the case number. No need to file an issue here.

dustinkerstein commented 6 years ago

The specific black screen issue that exists in Unity 2017.3.1p1 was fixed in Unity 2017.3.1p2:

This specific ticket (#855) was actually more about every other version besides Unity 2017.3.1p1. While there may be a black screen issue in that 2017.3.1p1, I didn't notice it. In fact, it was one of the only versions that I couldn't replicate this issue in.

My main concern is that the latest VR Services update may have caused a black screen issue (possibly unique from 971671) for Daydream devices across many older Unity versions, and there's a good chance developers aren't aware that the update is causing issues yet. Should this not be investigated from the VR Services perspective as well?

fredsa commented 6 years ago

I tried the project you linked to above (https://www.dropbox.com/s/37ld6u5i95ofnqg/DaydreamTest.zip?dl=0) and do find that it mostly renders black on a Pixel phone (with Google VR Services 1.13.185188193) when built using Unity 2017.1.3p1, although it appears to work using 2017.3.1p2. For reference, I filed Unity case 1008211 for this.

There's was at least one issue that was fixed in 2017.3.1p2 (and was problematic in 2017.3.1p1). It may be that that fix just needs to be back ported to 2017.1.*.

fredsa commented 6 years ago

My main concern is that the latest VR Services update may have caused a black screen issue (possibly unique from 971671) for Daydream devices across many older Unity versions, and there's a good chance developers aren't aware that the update is causing issues yet. Should this not be investigated from the VR Services perspective as well?

Agreed that updating Google VR Services to the latest should never break existing apps that were working with a previous version of Google VR Services.

You mentioned several affected versions (including 2017.2.1p4, 2017.1.3p1, or 2017.1.2p4). I only tried building your project in 2017.1.3p1. While that APK doesn't work with Google VR Services 1.13.185188193, the same APK also doesn't work with the the 1.12.* version for me. I also tried the Test.apk you included in the zip, but couldn't get it to work with the prior version of Google VR Services.

dustinkerstein commented 6 years ago

While that APK doesn't work with Google VR Services 1.13.185188193, the same APK also doesn't work with the the 1.12.* version for me.

Interesting. It's possible it broke in a previous VR Services update. How were you able to test with older versions? When I try uninstalling VR Services (reverting to the stock version) I receive an alert about updating VR Services when I launch my app, and if I hit cancel it doesn't initialize Daydream like it usually would (no interstitial or controller connection prompt).

fredsa commented 6 years ago

The Play store will only give you the latest Google VR Services, so once your device updates there's no going back. And yeah, "uninstalling" the app will put you back to the old factory ROM version, which Play will then promptly attempt to update (as it should).

Do you have any published apps in Play store that you think were working in 1.12 but broke in 1.13?

dustinkerstein commented 6 years ago

Do you have any published apps in Play store that you think were working in 1.12 but broke in 1.13?

Well, I thought I did, but after retesting things today, the black screen issue seems to be even more fluky that I saw a few days ago. In the 10-15 launches (across both my app and the Test.apk posted above) I wasn't able to replicate on 1.13 or 1.12. I guess we'll just have to leave it there for now, and hope the root cause of this issue was fixed in 2017.3.1p2 (even though I did see 1 black screen in testing a few days ago). The flukiness makes it really hard to isolate.

fredsa commented 6 years ago

In case you're interested, Unity case 1008211 tracks the black screen on 2017.1.3p1 (and 2017.1.3p2).

As noted in the case, it appears that the issue will be fixed when 2017.3.1p3 comes out.

fredsa commented 6 years ago

Note that 2017.3.1p4 is out and works.

Please continue to follow Unity case 1008211 for the latest regarding a potential fix on the 2017.1 branch.

As always, Unity QA patches are available from https://unity3d.com/unity/qa/patch-releases.

dustinkerstein commented 6 years ago

Though it's worth noting that 2017.3.1p4 isn't a viable solution for folks dependent on Cardboard support as it still has this issue - https://answers.unity.com/questions/1456999/

Update - The issue I mentioned above appears to be fixed in 2018.1 per this ticket. @fredsa do you happen to know which 2018 releases 1008211 has been fixed in?

fredsa commented 6 years ago

We hope to have a fix for Unity 2017.1 built apps in the an upcoming version of Google VR Services. In the mean time, upgrading to a newer (2017.2, 2017.3 or soon LTS 2017.4) Unity branch should also address the issue.

Though it's worth noting that 2017.3.1p4 isn't a viable solution for folks dependent on Cardboard support as it still has this issue - https://answers.unity.com/questions/1456999/

I added a comment in https://answers.unity.com/questions/1456999/ to explain that manually pulling in an updated gvr.aar into your project, from the latest Google VR SDK for Unity, will also fix the issue if you don't want to wait for the patched Unity version.

do you happen to know which 2018 releases 1008211 has been fixed in?

I don't. Source of truth is Unity's issue tracker: https://issuetracker.unity3d.com/issues/xr-daydream-application-fails-to-initialize-and-renders-black-on-launch

jdduke commented 6 years ago

We hope to have a fix for Unity 2017.1 built apps in the an upcoming version of Google VR Services.

The updated version should be fully rolled out by this coming Friday (4/6).

fredsa commented 6 years ago

Fixed in Google VR Services 1.14.190701955.

To check the version currently installed on your phone: $ adb shell pm dump com.google.vr.vrcore | egrep -i versionName