baldurk / renderdoc

RenderDoc is a stand-alone graphics debugging tool.
https://renderdoc.org
MIT License
8.9k stars 1.33k forks source link

Android apps built with Daydream SDK break when Renderdoc attaches #1008

Closed nerites closed 4 years ago

nerites commented 6 years ago

Description

While debugging Unity builds for Android, I noticed that Renderdoc will only work as intended when the app is built with "Cardboard" set as the VR SDK (in Edit > Project Settings > Player Settings > XR Settings). If "Daydream" is set instead, the resulting apk will crash when Renderdoc tries to attach and launch (with the Nightly builds of renderdoc), or just displays a black screen with a bar of static across the front.

I also attempted to test on a sample APK built per the instructions given here: https://developers.google.com/vr/develop/android/get-started Once again, the app crashes when Renderdoc is used to launch it, but in this case I couldn't figure out how to specify Cardboard vs. Daydream.

Repro steps

I've attached a .zip file of a Unity project (though you'll need to reimport the GVR package as in Step 3), but here's instructions as well:

  1. Create a new 3D project using Unity (technically I've observed this in many templates across many Unity versions).
  2. Go to Edit > Project Settings > Player > Android (you may need to install the Android Player if you don't already have it) > XR Settings, then check "Virtual Reality Supported", and add Daydream to "Virtual Reality SDKs".
  3. Download a GoogleVR .unitypackage here: https://github.com/googlevr/gvr-unity-sdk/releases
  4. Import it: Assets > Import Package > Custom Package > (select the downloaded .unitypackage)
  5. File > Build Settings > Android, then "Switch Platform" if Android is not already the selected platform. Set Development Build/Built Type to "Debug" (depending on your Unity versions), set your Run Device to a connected Android device, then click "Build and Run".
  6. In RenderDoc, connect to the Android device, then launch the freshly-installed APK.

It should either crash immediately or show a black screen. To compare against expected behavior, simply remove Daydream from "Virtual Reality SDKs", then add Cardboard. Build and Run, then launch from Renderdoc, and see that it's behaving nicely.

Environment

Additional details

I've also attached .rdcs of the same app in Cardboard vs. Daydream, though I don't know how to reproduce the capture of Daydream.

The way this bug was found, it's hard to tell whether it's because of Unity (something about how its Android Player builds APKs for different VR SDKs?), Google (something about Daydream itself vs. Cardboard?), or Renderdoc.

A photo of Daydream app behavior on RenderDoc v1.0: 20180601_095223

Captures of Cardboard vs. Daydream builds of the same project: Captures.zip

A basic project if you don't feel like setting up a new project from scratch (you'll have to reimport GVR): renderviewportscale_unity2017_cardboard.zip

nerites commented 6 years ago

Hello there! An update:

I tried using Renderdoc to launch all the sample GVR apps, built using Android Studio. It attaches just fine to any of them that do not invoke the Daydream overlay.

controllerclient: launches and attaches to embedded render window simplepanowidget: same as controllerclient simplevideowidget: same as cc treasurehunt: after "waiting for debugger to attach", and a brief black screen, appears to close. The app itself is still open but does not have focus; if you reopen it then it finished loading without renderdoc attached. video360: same as cc videoplayer: same as treasurehunt (also uses daydream overlay), except app does not remain open in the background.

I don't know how to use Android Studio to build specifically for Cardboard, so I can't really get a "working baseline" like I did when building with Unity.

GVR sample apps can be found here: https://developers.google.com/vr/develop/android/get-started

baldurk commented 6 years ago

I've looked into this a bit. So far it looks like the difference is that daydream has its own special API for some rendering things, whereas cardboard just uses regular GL (or enough that it captures fine).

Some of this I might be able to fix if I hook and capture the relevant bits of the gvr API, e.g. to detect when a framebuffer is created and with what parameters, and emulate that with regular GL on replay. But I don't know yet if that will be enough to get it working, since that doesn't explain why the rendering is broken while running with renderdoc. Also some crashes I encountered will be very difficult to diagnose since Android is such an incredibly painful platform to work with.

baldurk commented 4 years ago

Google has discontinued support for Daydream so this feature request is no longer relevant. Closing this issue.