googlevr / gvr-unity-sdk

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

Unity 5.2.2f / SDK 0.5.2 - Renderproblems distortion / Startglitch / missing Gui Elements #116

Closed noemis84 closed 8 years ago

noemis84 commented 8 years ago

My App starts in portrait mode, let the user browse through menues, vr mode is startet later.

My short setup (similar as in a recent issue from me), which you recommended:

primary Bugs/Problems (Android):

  1. directly after splash screen there is a frame where the alignment marker and settings button appear = Startglitch
  2. If have enabled the settings button and the back button... but they're not visible. Only sometimes, very randomly.
  3. When I press home and then resume to the app, many bugs appear: random crashes and many distortion problems, sometimes the back and settings button appear suddenly, sometimes not... I append a screenshot with some samples... all taken within 5min in the same app version on a samsung s6.

One note: In editor everything works fine, exept when I switch to other windows and refocus... very seldom I get a null reference from Cardboard.cs line 627 from OnApplicationFocus() - maybe this could be also the reason for some crashes on android... hope this helps.

For all other points I'm looking forward for solutions, advices or maybe I can help to make it more stable.

bugsamples

smdol commented 8 years ago

For picture#1, make sure the main camera's background color has is fully opaque (alpha is turned all the way up).

For the start glitch, try setting the Enable checkboxes for each UI element to false. Wait till you enable VR mode to turn them on. This may affect the visibility bug you sometimes see.

I'm not sure that will fix ask the pause/resume issues. For those, cash you see anything in the adb logcat?

noemis84 commented 8 years ago

I took the cameras from the prefab, the only settings I changed are the clipping planes to 0.01. And I set the toggle culling mask @ cardboard eye script.

I tried your advice and turn the settings and back button off and after instantiate to on, but this doesn't help. The glitch is still there.

I also changed the cameras to solid black color, the distortion bugs seem to disappear, but difficult to say, they're not constant bugs.

Meanwhile switched to 5.2.2 - I'll also change the title. I still try to figure out from where the crashes come... The app never crashes after first start. When I go to pause (via home button) and then return a crash is very likely, but not always...

ognjenmarcheta commented 8 years ago

First problem might be if you have another camera (which is not related to cardboard) in your scene. Problem with cardboard UI (settings button) i have it too.

noemis84 commented 8 years ago

I've to correct me: the setup of your scene doesn't matter. The startglitch is always there... it just isn't so obvious, when the settings/alignment/back button stays there, because your app starts with vr mode enabled... even if you just turn off vr mode from one of the prefabs (single cam mode) and so also the gui elements should be not visible, there is also a short frame between loading and your scene... so all in all it just would be cool to have more control or possibilities to divide between menue/app stuff and a vr mode... besides: this is the app I'm talking about: https://play.google.com/store/apps/details?id=com.mikavaa.vrais

hacaro76 commented 8 years ago

Same, startglitch, checkboxes are unchecked, and i've also set the : EnableAlignmentMarker = false; and EnableSettingsButton = false; by code, but nothing the glitch remain. I've noted that this appear only on the Android build. On iOS after setting the values to false from the code all it's ok .

JagaHee commented 8 years ago

I have the same problems. App always crashes and no ui elements on the screen. DId you solve your problem?

noemis84 commented 8 years ago

No, I haven't a solution and even not an idea what else to try... in my eyes, the sdk needs definitly an update. I have another bug sample, which makes everything even more confusing for me. I have two cardboards V2.0... one from Zaak, one from google via a conference (the cardboards have been sponsored by google)... when I configure the viewer I get very different lens distortion... and the one from zaak seem to be correct. I have no idea why and I also remember, that both cardboards had the same correct distortion two weeks ago. These test are from Moto x 2nd. But on a samsung s6 I've seen same problems,,,, for better understanding see image attached below: bugsamples2_small

smdol commented 8 years ago

The SDK definitely needs an update -- there are several bugs already on the list of what needs to be fixed, including the start glitch. I'm not allowed to say anything about when new releases are scheduled though :(

noemis84 commented 8 years ago

So this is good and bad news... good, because I stop thinking about fixing these issues and if they are're caused by me, bad, that I've no idea when I can say to our customers (even more for myself): Now I have an reliable vr mobile workflow with untiy + google sdk... looking forward the update. Is there maybe a source you can tell me/us from where we get the latest news about such update?

smdol commented 8 years ago

We can still try to find a workaround for you with the current SDK too. Also, I typically come back through these issue posts and say when a new release is available if it has a fix for that issue.

jxxxxst commented 8 years ago

Hey everyone, I'm fighting the startglitch too. I even commented out the GL rendering code in CardboardPostRender.cs. Unfortunately even then the alignment marker is appearing in the glitch at startup and even after that.

JagaHee commented 8 years ago

As far as i understand this GL is drawn only on devices that don't support native UI. In other way marker and other elements are generated from android plugin.

noemis84 commented 8 years ago

As simple workaround for missing gui elements, maybe interessting for someone:

  1. disable settings/back button in cardboard.cs
  2. in CardboardPreRender.cs set camera.depth from 100 to 99 for example
  3. use your own gui cam on depth 100 with similar icons/buttons and use anchors for position (in my case ngui, but unity ui should also work)
  4. call Cardboard.SDK,ShowSettingsDialog() and what you want on back button
noemis84 commented 8 years ago

To prevent some crashes I would like to quit the app, if the user pauses the app. I know, not best pratice, but most crashes (maybe all, and with no debug logcat output) happen after resuming the app. But when I want to use this code for example:

void OnApplicationPause (bool state) {
        if (state) {
            Debug.Log("pause");
            Application.Quit();
        }
    }

The app quits not correct. I get an timeout error: "Timeout while trying to pause the Unity Engine.", When I restart it, it crashes/hangs at start (I think it tries to resume). Has someone a workaround for a clean exit like on IOS (exit on suspend) but for android for usage with this SDK?

Scott-Driscoll commented 8 years ago

I just wanted to add that we're facing the same startup glitch bug and have tried all suggestions listed here. SDK 0.5.2 Unity 5.2.2p4

smdol commented 8 years ago

OK, sorry for the long absence from this thread. @HansBernd The GL rendering code in CardboardPostRender.cs is only for when you run the game in the editor.

The "start glitch" is due to the native Java code that creates the UI elements. It has their visibility set initially to "on", and only after that does the Cardboard SDK get a chance to turn them off. So you can see a flicker. As we see, this is a hard problem to work around from the Unity level.

noemis84 commented 8 years ago

So than isn't it possible that someone, who is able to, change (I assume unityvractivity.jar) the java code and set visibility initially to "off"? (a patched version beside the normal version)

Another important fix would be, that we can quit the app properly as described 3 posts above without timeout... that would make a more or less stable release possible.

smdol commented 8 years ago

Yes, changing the Java code would work. (I counted Java as "native" code because of the need to marshal calls from .NET)

noemis84 commented 8 years ago

Any chances of an update? I think there're enough bugs to fix and I wondering, when I see new posts and tweets about google cardboard sdk and unity, how easy it is, but no one talks about the problems... 3 months is a loooooong time for an important update :(

smdol commented 8 years ago

Definitely updates are coming. We just aren't allowed to give exact dates, I guess because it's better to not make a promise than to make one and have to break it :(

noemis84 commented 8 years ago

I saw, there's an update. Great! I'll test it and post the result here.

noemis84 commented 8 years ago

I'll close this issue after the new sdk release 0.6. This solves the

  1. the startglitch
  2. missing Gui Elements

All other problems (crash/timeout) are discussed in a new thread #137