Skip to content
This repository has been archived by the owner on Nov 8, 2019. It is now read-only.

Cardboard (and hybrid 2D+Daydream) apps crash on S8 when screen resolution is not WQHD+ (Switching Between VR.enabled cause crash) #671

Closed
VadimTikhonyuk opened this issue Jul 31, 2017 · 67 comments
Labels

Comments

@VadimTikhonyuk
Copy link

Hi, everyone

I had issue with switching between 2D and VR Mode
This method cause crash

StartCoroutine(LoadDevice("cardboard"));

IEnumerator LoadDevice(string newDevice)
{
	yield return null;
	VRSettings.LoadDeviceByName(newDevice);
	yield return null;
	VRSettings.enabled = true;
}

`
LOGCAT
libEGL : eglCreateWindowSurface: native_window_api_connect (win=0xc687d808) failed (0xffffffed) (already connected to another API?)
libEGL : eglCreateWindowSurface:484 error 3003 (EGL_BAD_ALLOC)
Unity : [EGL] Failed to create window surface: EGL_BAD_ALLOC: EGL failed to allocate resources for the requested operation.
Unity :
Unity : (Filename: ./Runtime/GfxDevice/egl/WindowContextEGL.cpp Line: 141)
Unity :
libEGL : call to OpenGL ES API with no current context (logged once per thread)

Im using Unity 5.6.0f3 and Samsung S8

I see many similar problem with this method but anyone find solution?

@VadimTikhonyuk
Copy link
Author

Update, On Unity 2017.1.0f3 same issue

@VadimTikhonyuk
Copy link
Author

Update, On my old Fly IQ4516 everething works fine.
I think this crash happens on Samsung S8 after android update, which I got few days ago, after this update I didnt test VR mode in my app.

@tedruxpin
Copy link
Collaborator

Hi VadimTikhonyuk, can you attach a full log for this crash?

@WeaselKing
Copy link

WeaselKing commented Aug 3, 2017

I have the same use case and what appears to be the same problem.

Phone: Samsung Galaxy S8 Plus
Unity version: 2017.1.0f3
Code that I am using to crash the game:

    public void initiatevr()
    {
        StartCoroutine(initiatevrcoroutine());
    }

    IEnumerator initiatevrcoroutine()
    {
        Debug.Log("Initiating the VR Sequence");
        VRSettings.LoadDeviceByName("Cardboard");
        yield return null;
        VRSettings.enabled = true;
        Debug.Log("VR Sequence initiation complete");
    }

I put Debug.log strings in the code so you can see it in the logcat output more easily.

Some things of note:
The game does not crash if you disable Google VR Services. This is replicated with the version that shipped with the phone, as well as the latest version which as of this moment is 1.7.161000338

The game does not crash on my old handset which is an LG G2.

Building with a mono back end or using IL2CPP makes no difference. Crash is the same.

I attached the logcat for the crash so you can check it out.

bestiLogcat.txt

@VadimTikhonyuk
Copy link
Author

Hi, tedruxpin,
There is log file, I cut it from adb logcat, so something important maybe lost, because full logfile is huge
log.txt

@fredsa
Copy link
Member

fredsa commented Aug 15, 2017

On S8+, can you let us know if the Cardboard app runs correctly (no crash) when you set the phone's screen resolution to the native device resolution:

Settings > Display > Screen resolution > WQHD+ > APPLY

@fredsa fredsa added the bug label Aug 23, 2017
@fredsa fredsa changed the title Switching Between VR.enabled cause crash Cardboard apps crash on S8 when screen resolution is not WQHD+ (Switching Between VR.enabled cause crash) Aug 23, 2017
@Pseudopode
Copy link

I have the same problem with a S8.

@fredsa : I made the test you asked for. Here's the results, with the latest Google VR Services update :

  • S8 with the Google VR Services activated, @FHD+(2220x1080) resolution = crash on startup for the app
  • S8 with the Google VR Services deactivated @FHD+(2220x1080) resolution = app runs fine, I can push screen luminosity as high as I want
  • S8 with the Google VR Services deactivated @FHD+(2220x1080) resolution = app runs fine, I can push screen luminosity as high as I want, it doesn't crash if I switch back to the panel, activate Google VR Services while the app is running and go back to the app
  • S8 with the Google VR Services activated @WQHD+(2960x1440) resolution = app runs fine, I can't push screen luminosity as high as I want, and it seems that the phones goes in low persistence mode.
  • S8 with the Google VR Services deactivated @WQHD+(2960x1440) resolution = app runs fine, I can push screen luminosity as high as I want, and the phone doesn't goes into low persistence mode (I suppose it's because the Service isn't activated).

@VadimTikhonyuk
Copy link
Author

@fredsa There have any way to open native settings and give user to change resolution. Similar to how this work in Gear VR. I have some skills in writing plugins on java

@fredsa
Copy link
Member

fredsa commented Aug 24, 2017

@Pseudopode, thank you for confirming and sharing your results with WQHD+ and FHD+.

The behavior you're seeing when deactivating Google VR Services is expected as this service is responsible for entering VR mode, which includes enabling Low Persistence mode, which helps greatly with user comfort and image quality.

@fredsa
Copy link
Member

fredsa commented Aug 24, 2017

@VadimTikhonyuk We're looking into this underlying issue. If in the mean time you have a workaround, please feel free to share here.

@OmegaMule
Copy link

Hi, is there any progress? We are having the same issue, instant crash on S8/S8+ when using non-native resolution. It would be really wonderful to get a fix asap.

Or is there a way to force user or Android to always switch to native resolution before staring an app?
Thx.

@sigmaxipi
Copy link

One possible workaround is to add android:configChanges="density" to your Activity's manifest entry. I haven't tried this on Unity, but it works for a similar Android issue on the S8.

@fredsa
Copy link
Member

fredsa commented Sep 13, 2017

Using a test apk, built using Unity 2017.1.0p4, it appears that it's not quite enough to use android:configChanges="density|…" in the app's activity.

Although this does prevent the app from immediately closing when it's launched at a less than full screen resolution, the result is that the stereo output is rendered at the wrong scale.

hd-plus
fhd-plus

@fredsa
Copy link
Member

fredsa commented Sep 14, 2017

We're looking into a couple of potential routes to fix this issue:

  1. An update to the Unity Android Player and the build process, to handle the density change event.
  2. An update to Google VR Services, to avoid the density change in the first place.

@OmegaMule
Copy link

OmegaMule commented Sep 14, 2017

Thank you for response.
Just my two cents on the first solution/workaround:

  1. That would require new Unity (patch) release and re-import of ALL projects for every developer. Also from my experience with Unity, it might work in one release and stops working in another...

Could anyone please point me to the root cause of the crash? Is it GVR SDK, GVR service or Unity Player causing this? Thx.

@guneyozsan
Copy link

guneyozsan commented Sep 15, 2017

We get the same reports from users with S8+. If it is WQHD it works fine, if not it crashes during switch from 2D to VR. Since the app starts 2D we don't have info on what happens during switch from VR to 2D.

@GavinThornton
Copy link

Same on the Samsung Galaxy Note 8, I'm starting in "none" standard mode and loading Cardboard later, at that point crashes out if the device is in FHD+ 2200x1080 mode, change the device to WQHD 2960x1440 and is fine.

Log:

Could not recreate VR window because GfxDevice is in an invalid state (device lost)
[EGL] Attaching window :0xd413b808
onPause
D/VrManagerService: DisableKeycodeWink, component = ComponentInfo{com.conquermobile.ubc.eyetrackpd/com.unity3d.player.UnityPlayerNativeActivity}, enabled = true
V/SystemKeyManager: requestSystemKeyEvent() is called keyCode = 1082 componentName = ComponentInfo{com.conquermobile.ubc.eyetrackpd/com.unity3d.player.UnityPlayerNativeActivity} request = true
ANativeWindow: (2220/1080) RequestedResolution: (0/0) RenderingResolution: (0/0) EGLSurface: (2220/1080)
Error trying to call delegated method pause. null

@dustinkerstein
Copy link

dustinkerstein commented Sep 21, 2017

Just wanted to check up on this issue as I'm getting more and more reports from users of this crash.

This is likely affecting the majority of S8 / S8+ / Note 8 users as those devices ship from the factory at FHD.

I was thinking about pushing out an update to my app that warns these users and prevents VR mode, but since I have the "daydream" VR device as the first in the list (and needs to stay this way for Daydream approval), my app will crash immediately at launch since it loads in VR mode from the beginning.

If anyone has a workaround or insight as to when this might be fixed, I'd very much appreciate it.

@OmegaMule
Copy link

OmegaMule commented Sep 21, 2017

It is becoming to be a really pressing issue, especially for developers who have their apps already on Google Play. Bad reviews could bury their apps, nobody cares it's not their fault. I just hope they will be able to fix it via GVR Services update which should be released at the end of this month. If not, then I'll have to do some ugly workarounds.

Also, IMHO, VR (or any app) should keep the resolution user has selected and shouldn't try to switch to native. Software should respect users settings, not override it. This problem shouldn't exist.

@fredsa
Copy link
Member

fredsa commented Sep 21, 2017

We're actively working on a fix for this issue.

In the mean time the best available workaround is to have users change their device's default resolution to WQHD+:

Settings > Display > Screen resolution > WQHD+ > APPLY

@dustinkerstein
Copy link

Thank for the update @fredsa

Do you happen to know if it's going to be a fix to VR services or Unity? Any ETA?

Asking users to switch resolutions isn't really practical as I have no way to reach out to them, and in my case the application crashes immediately at launch so I can't warn them at all.

@GavinThornton
Copy link

GavinThornton commented Sep 21, 2017

We're actively working on a fix for this issue.

Is there an ETA of less than a few days or will it be longer?

Just want to know if it is worth working on a "detect and ask S8/S8+/Note8 users" system and pushing it out, or if this fix will come soon.

@dustinkerstein
Copy link

dustinkerstein commented Sep 21, 2017

Just a quick note - I believe this bug will result in all Daydream Unity apps crashing on startup when set to FHD (the default resolution) on S8 / Note 8 devices, at least on the Unity / VR services versions where this bug exists. Please let me know if I can help at all. I'm happy to test any potential fixes or workarounds as this is a bit of a showstopper for me at the moment.

@fredsa
Copy link
Member

fredsa commented Sep 21, 2017

Is there an ETA of less than a few days or will it be longer?

@GavinThornton It will very likely take longer than a few days.

@dustinkerstein
Copy link

Just wanted to check in. Any news from the Samsung / Unity / GVR side of things?

@OmegaMule
Copy link

@dustinkerstein: Unity 2017.1.2p1 "XR: Fixed handling of Android density (screen resolution) changes to avoid a crash."

  • I haven't tried it yet, because I use 5.6.x, but this change should avoid the crash. Whether they also fixed the scaling issue is unknown. Somebody should try it.

@rusmaxham
Copy link
Contributor

A fix for this is also coming to Unity 5.6.x.

@dustinkerstein
Copy link

@OmegaMule Nice! I just confirmed this is working correctly in 2017.1.2p1 for both FHD+ and WQHD+ resolutions. Toggling VR mode also works correctly.

@OmegaMule
Copy link

OmegaMule commented Oct 22, 2017

OK I've tested the crashfix change on Unity 2017.1.2p1 and Unity 5.6.4p1, the result is as I've predicted. Unity devs just added "density" to Android Manifest, which prevents the crash when GVR Services enforce resolution change. The scaling, however, is still not fixed. VR viewports are incorrectly scaled and positioned due to resolution difference.

So this is just first step. Users still need to change resolution to WQHD to use Cardboard.

Is there any ETA for the scaling fix? Thanks.

Update:
Luckily it's possible to create a fully working workaround using Screen.SetResolution() to make it work without user intervention.

@dustinkerstein
Copy link

@OmegaMule Can you post a screenshot of that? I haven't seen that when testing on the devices here - http://developer.samsung.com/remotetestlab/rtlDeviceList.action

@OmegaMule
Copy link

OmegaMule commented Oct 22, 2017

@dustinkerstein:
https://user-images.githubusercontent.com/1235362/30393677-baf78ef4-9875-11e7-971b-f217abded447.png

It looks exactly like that on real Galaxy S8 device and clean Unity version I mentioned before.

Update:
I've also tried it on S8 simulator you posted with the same result.

@dustinkerstein
Copy link

@OmegaMule Interesting, I am not able to replicate that behavior with my app when testing on the Samsung Remote Device lab (which I believe are in fact real devices, not emulators or simulators). Is it possible to post your project online?

@jdduke
Copy link

jdduke commented Oct 23, 2017

Is there any ETA for the scaling fix? Thanks.

The plan is to push an updated Google VR Services build to resolve the second half of the problem (properly responding to "density" changes when declared in the manifest). We expect the rollout to hit 100% by the end of next week (Nov. 3).

@jdduke
Copy link

jdduke commented Nov 3, 2017

The fix to allow "density" changes without an app restart (by way of the app manifest) has rolled out to 100%. Note that the resolution change will still occur if the user has not explicitly changed the resolution to native.

Separately, we're exploring rollout of a global prompt to change the resolution of the device to native, sometime in December. That will avoid the resolution switch entirely, though it may be suboptimal for some users who don't want their device always running at native resolution.

@rusmaxham
Copy link
Contributor

The fix for this issue requires Unity 5.6.4p1, 2017.1.2p1, and 2017.2.0f3 and VR Services 1.10.172754103 or later.

@Adam-VisualVocal
Copy link

I can confirm that the combination of Unity 2017.1.2p1 and VR Services 1.10.172754103 is successful. What's the best way to detect if a user doesn't have the latest VR Services installed though?

@Adam-VisualVocal
Copy link

I ended up using the PackageManager to get the PackageInfo for com.google.vr.vrcore. Then I checked the versionCode to make sure it was at least 160729830 (aka 1.10.172754103). If there's a better way then please let me know. Thanks.

@rusmaxham
Copy link
Contributor

You can also now upgrade to the latest Google VR SDK for Unity (v1.110) which has the Android GVR lib v1.101 embedded in the .unitypackage. This embedded GVR lib has the fix in it and should work even if the user hasn't upgraded their VR Services.

@Adam-VisualVocal
Copy link

Awesome. That works. Thanks!

@tomszirtes
Copy link

Hi, I'm still getting the same problem (crash on start when not in WQHD+) with Samsung S8, Google VR Services 1.10.172754103, Unity 2017.1.2f1, Google VR SDK for Unity (v.1.110)

Other than importing the latest Google VR SDK to my project is there anything else I need to do to make it use the VR lib? Not sure how Unity knows to use the one in the SDK instead of it's own built-in library.

@tomszirtes
Copy link

Ok, requires Unity 2017.1.2p1 it seems not working with 2017.1.2f1

@hyenachi
Copy link

hyenachi commented Nov 20, 2017

When I turn off Google VR Service, my vr app works. But When I turn on Google VR Service in applicatioon ->vr helper etc, my app doesnt work.
If I put vrmode false in AndroidManifest, Google VR Service shouldn't work to my vr app ?
"

<uses-feature android:name="android.software.vr.mode" android:required="false"/>
<uses-feature android:name="android.hardware.vr.high_performance" android:required="false"/>

"

How can i avoid this problem on s8 and cardboard sdk 0.8?
I tried to build an app in unity 564p2 and unity2017.2.0p2 but I failed.
Is there any solution in cardboard sdk0.8 ?

@fredsa
Copy link
Member

fredsa commented Nov 20, 2017

@hyenachi Version 0.8 of the Google VR SDK for Unity is very old. If you encounter any issues with the latest SDK, please file a new issue for that.

@andypoly
Copy link

andypoly commented Jan 9, 2018

I can not currently upgrade Unity and the SDK on our project but have hit this annoying bug. Can I fix the crash at least with a manifest update like android:configChanges="density" then?

@jdduke
Copy link

jdduke commented Jan 16, 2018

Can I fix the crash at least with a manifest update like android:configChanges="density" then?

You can try, though I don't believe the behavior will be consistent or correct unless you have the latest SDK and Unity version.

@andypoly
Copy link

Yes I finally could update to latest Unity & I must say it's much better now but what a rocky road to get there from Google!

@jox
Copy link

jox commented Feb 3, 2018

We're using Unity 2017.3 and gvr-sdk 1.120.0 and there is still the issue with the S8 in the non-WQHD+ resolutions that the output is rendered at the wrong scale.
Fredsa has written about it 4 months ago.

Wrong scale in FHD+

Wrong scale in HD+

Is there any information/workaround/solution available or in prospect?

@fredsa
Copy link
Member

fredsa commented Feb 5, 2018

@jox Can you confirm that the device has the latest version of Google VR Services?

@jox
Copy link

jox commented Feb 14, 2018

@fredsa
GoogleVR Services is the latest available on my phone. It's version 1.12.177372015 (updated 2017-11-30).

@jox
Copy link

jox commented Feb 14, 2018

@fredsa By the way, when I go to Settings -> Apps and deactivate the Google VR Services, it will run fine in both non-WQHD+ resolutions. When trying to configure the viewer then, it will ask to install the Cardboard App.

@fredsa
Copy link
Member

fredsa commented Feb 15, 2018

@jox I've been unable to reproduce this using Unity 2017.3.1p1 on a Samsung Galaxy S8.

It would be helpful to know:

  • What's the Android operation system version installed on the device?
    Settings > About phone > Software information > Build number
  • Since there are many SKUs for the S8, what model number are you testing with?
    Settings > About phone > Model number
  • What's the exact version of Unity you're using?
    Unity > About Unity…
  • What's the currently installed Google VR Services version (currently likely 1.13.185188193):
    adb shell pm dump com.google.vr.vrcore | grep version

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

No branches or pull requests