cancel
Showing results for 
Search instead for 
Did you mean: 

Android Native application crashes on vrapi_EnterVrMode

dan_engelbrecht
Honored Guest
We are building a native application which targets GearVR but the application just crashes(?) when calling vrapi_EnterVRMode with no real useful information.

It is running on the Samsung Note4 and our regular "plain" 2d-code path works fine. Here is the adb-logcat from our call to vrapi_EnterVrMode to the application being terminated. For all I can tell and adding extensive logging it seems to crash inside vrapi_EnterVRMode.

We set the Display, WindowSurface and ShareContext of the ovrModeParams and all calls to rendering functions including to vrapi_EnterVRMode are done from our rendering thread and we make sure to call AttachCurrentThread for the thread.

Any information or tips would be greatly appreciated.

10-06 17:14:02.897 23566 23635 I VrApi   : ---------- vrapi_EnterVrMode [start] ----------
10-06 17:14:02.907 23566 23635 I InputHooks: Enabling Native Input Hooks
10-06 17:14:02.907 23566 23635 I OVR     : DeviceManagerThread::AddSelectFd 52 (Tid=0)
10-06 17:14:02.907 23566 23655 I OVR     : DeviceManagerThread - running (Tid=0).
10-06 17:14:02.907 23566 23635 I OVR     : OVR::DeviceManager - initialized.
10-06 17:14:02.907 23566 23635 I HmdSensors: ovrHmdCap_UseHeadsetSensors
10-06 17:14:02.917 23566 23635 D VrApi   : targetSDKVersion 23
10-06 17:14:02.917 23566 23635 I VrApi   : DEVICE MODEL NUMBER = SM-N910F
10-06 17:14:02.917 23566 23635 I VrApi   : DEVICE HARDWARE = qcom
10-06 17:14:02.917 23566 23635 I VrApi   : DEVICE BUILD NAME = MMB29M.N910FXXS1DPH5
10-06 17:14:02.917 23566 23635 I VrApi   : DEVICE BUILD TYPE = user
10-06 17:14:02.917 23566 23635 I VrApi   : DEVICE OS VERSION = 6.0.1
10-06 17:14:02.917 23566 23635 I VrApi   : VRAPI VERSION = 1.0.3.7-284904-40583946 Oct  3 2016 02:06:03 Development RELEASE
10-06 17:14:02.917 23566 23635 I VrApi   : VRAPI LOADER VERSION = 1.0.3.1
10-06 17:14:02.917 23566 23635 I VrApi   : APP NAME = Stingray VR
10-06 17:14:02.917 23566 23635 I VrApi   : APP VERSION = 1.0 versionCode 1 internalVersionName <none>
10-06 17:14:02.917 23566 23635 I VrApi   : APP VR TYPE = vr_dual
10-06 17:14:02.917 23566 23635 I VrApi   : APP PACKAGE NAME = com.autodesk.stingray
10-06 17:14:02.917 23566 23635 I VrApi   : APP ACTIVITY CLASS = com.autodesk.GearVRNativeActivity
10-06 17:14:02.917 23566 23635 I VrApi   : ovrModeParms::VRAPI_MODE_FLAG_ALLOW_POWER_SAVE = 1
10-06 17:14:02.917 23566 23635 I VrApi   : ovrModeParms::VRAPI_MODE_FLAG_RESET_WINDOW_FULLSCREEN = 0
10-06 17:14:02.917 23566 23635 I VrApi   : ovrModeParms::VRAPI_MODE_FLAG_NATIVE_WINDOW = 1
10-06 17:14:02.917 23566 23635 I VrApi   : ovrModeParms::VRAPI_MODE_FLAG_FRONT_BUFFER_PROTECTED = 0
10-06 17:14:02.917 23566 23635 I VrApi   : ovrModeParms::VRAPI_MODE_FLAG_FRONT_BUFFER_565 = 0
10-06 17:14:02.917 23566 23635 I VrApi   : ovrModeParms::VRAPI_MODE_FLAG_FRONT_BUFFER_SRGB = 0
10-06 17:14:02.917 23566 23635 I OVR_LogUtils: SetAllowGpuTimerQueries( 0 )
10-06 17:14:02.917 23566 23635 W VrApi   : Operating without a sensor.
10-06 17:14:02.917 23566 23635 I Vsync   : Android reported display refresh rate = 60.00 Hz
10-06 17:14:02.917 23566 23635 I Vsync   : Opened /sys/class/graphics/fb0/vsync_event
10-06 17:14:02.917 23566 23635 I VrApi   : ovr_RegisterStatsReceivers
10-06 17:14:02.927 23566 23656 I Vsync   : vsync_event update delayed by 2765.2 milliseconds
10-06 17:14:02.927 23566 23635 D BatteryReceiver: Registering battery receiver
10-06 17:14:02.927   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:02.927 23566 23635 D HeadsetReceiver: startHeadsetReceiver: 0
10-06 17:14:02.927 23566 23635 I VrApi   : nativeHeadsetEvent(0)
10-06 17:14:02.937 23566 23635 I VrApi   : nativeGamepadListener(0)
10-06 17:14:02.937 23566 23635 I OutsideIn: OIT::Enter()
10-06 17:14:02.937 23566 23635 I OutsideIn: Set the dev_oitCamera localpref to enable
10-06 17:14:02.937 23566 23635 I VrApi   : OVR::Clocks thread started
10-06 17:14:02.937 23566 23635 I TimeWarp: -------------------- TimeWarpLocal() --------------------
10-06 17:14:02.937 23566 23635 I TimeWarp: dev_asyncTimewarp = 1
10-06 17:14:02.937 23566 23635 I TimeWarp: dev_frontbuffer = 1
10-06 17:14:02.937 23566 23635 I TimeWarp: dev_drawCalibrationLines = 0
10-06 17:14:02.937 23566 23635 I TimeWarp: dev_singleTriangle = 0
10-06 17:14:02.937 23566 23635 I TimeWarp: dev_singleTile = 0
10-06 17:14:02.937 23566 23635 I TimeWarp: TimeWarpAllocatedFrontBuffer = 1
10-06 17:14:02.937 23566 23635 I TimeWarp: Application context EGL_CONTEXT_CLIENT_VERSION = 3
10-06 17:14:02.937 23566 23635 I TimeWarp: VRAPI_MODE_FLAG_FRONT_BUFFER_PROTECTED = 0
10-06 17:14:02.937 23566 23635 I TimeWarp: VRAPI_MODE_FLAG_FRONT_BUFFER_565 = 0
10-06 17:14:02.937 23566 23635 I TimeWarp: VRAPI_MODE_FLAG_FRONT_BUFFER_SRGB = 0
10-06 17:14:02.937 23566 23635 I TimeWarp: eglConfig = 0xac0b8748
10-06 17:14:02.937 23566 23635 I VrApi   : ovr_IsProtectedContentAvailable: Not supported for this GPU.
10-06 17:14:02.937 23566 23635 I TimeWarp: display       : cached =        0x0, new =        0x1
10-06 17:14:02.937 23566 23635 I TimeWarp: config        : cached =        0x0, new = 0xac0b8748
10-06 17:14:02.937 23566 23635 I TimeWarp: native_window : cached =        0x0, new = 0x99a62ae0
10-06 17:14:02.937 23566 23635 I TimeWarp: num_attribs   : cached =        0x0, new =        0x0
10-06 17:14:02.937 23566 23635 I TimeWarp: attrib_list   : cached =     0x1505, new =     0x1505
10-06 17:14:02.937 23566 23657 D VrApi   : getDeviceProperty: device_gpu
10-06 17:14:03.027   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:03.127   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:03.227   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:03.327   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:03.437   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:03.527   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:03.627   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:03.727   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:03.747   422 22889 V NuPlayer: kWhatSourceNotify with buffering-update for NuPlayer 46
10-06 17:14:03.747   422 22889 V NuPlayer: msg : 3, ext1 : 46, ext2 : 0
10-06 17:14:03.747   422 22889 D NuPlayerDriver: notifyListener_l(0xaf0434a0), (3, 46, 0)
10-06 17:14:03.747   422 22889 V MediaPlayerService: [25] notify (0xacef0180, 3, 46, 0)
10-06 17:14:03.747   422 22906 D GenericSource: cachedDurationUs = 48.66 secs, eos=0
10-06 17:14:03.747 21667 21678 V MediaPlayer: message received msg=3, ext1=46, ext2=0
10-06 17:14:03.747 21667 21678 V MediaPlayer: buffering 46
10-06 17:14:03.747 21667 21678 V MediaPlayer: callback application
10-06 17:14:03.747 21667 21678 V MediaPlayer: back from callback
10-06 17:14:03.797   422 22890 V GenericSource: notifyBufferingUpdate: buffering 48%
10-06 17:14:03.797   422 22889 V NuPlayer: kWhatSourceNotify with buffering-update for NuPlayer 48
10-06 17:14:03.797   422 22889 V NuPlayer: msg : 3, ext1 : 48, ext2 : 0
10-06 17:14:03.797   422 22889 D NuPlayerDriver: notifyListener_l(0xaf0434a0), (3, 48, 0)
10-06 17:14:03.797   422 22889 V MediaPlayerService: [25] notify (0xacef0180, 3, 48, 0)
10-06 17:14:03.797   422 22890 V GenericSource: onPollBuffering: cachedDurationUs 48.7 sec
10-06 17:14:03.797 21667 21677 V MediaPlayer: message received msg=3, ext1=48, ext2=0
10-06 17:14:03.797   422 22890 V GenericSource: stopBufferingIfNecessary: mPrepareBuffering=0, mBuffering=0
10-06 17:14:03.797 21667 21677 V MediaPlayer: buffering 48
10-06 17:14:03.797 21667 21677 V MediaPlayer: callback application
10-06 17:14:03.797 21667 21677 V MediaPlayer: back from callback
10-06 17:14:03.827   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:03.927   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:04.027   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:04.127   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:04.227   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:04.327   422 22903 D NuCachedSource2: Remaining (5678K), LowWaterThreshold (4667)
10-06 17:14:04.387   383  4557 D libEGL  : eglTerminate EGLDisplay = 0xb0a0b6fc
10-06 17:14:04.387  1543  4704 I ActivityManager: Process com.autodesk.stingray (pid 23566)(adj 0) has died(310,811)
10-06 17:14:04.397   383   445 I SurfaceFlinger: id=2376 Removed HearVRNativ (4/7)
10-06 17:14:04.397   383   383 D libEGL  : eglTerminate EGLDisplay = 0xbed483bc
10-06 17:14:04.397   383  2375 I SurfaceFlinger: id=2376 Removed HearVRNativ (-2/7)
10-06 17:14:04.397  1543  4239 I WindowState: WIN DEATH: Window{8caecc9 u0 d0 com.autodesk.stingray/com.autodesk.GearVRNativeActivity}
10-06 17:14:04.397  1543  4704 D ActivityManager: isAutoRunBlockedApp:: com.autodesk.stingray, Auto Run ON
10-06 17:14:04.407  1543  4704 W ActivityManager: Force removing ActivityRecord{69211b1 u0 com.autodesk.stingray/com.autodesk.GearVRNativeActivity t1005}: app died, no saved state
10-06 17:14:04.417  1543  4239 D InputDispatcher: Focus left window: 23566


4 REPLIES 4

doles
Protege
Hi Dan, looks like its failing somewhere in eglCreateWindowSurface inside VrApi. First thought is make sure your WindowSurface is a valid ANativeWindow and that you are not yourself creating an EGLSurface from it since you are setting the VRAPI_MODE_FLAG_NATIVE_WINDOW flag.

Also, are you using native_app_glue or creating a SurfaceView in java?

dan_engelbrecht
Honored Guest
Thanks for the input, will check it out!

dan_engelbrecht
Honored Guest
I'm looking at our code (unfortunately I am not the author of the code - the author is no longer with us).

            auto vr_mode_parms = vrapi_DefaultModeParms(&_java_render);
            vr_mode_parms.Flags &= ~VRAPI_MODE_FLAG_RESET_WINDOW_FULLSCREEN;
            vr_mode_parms.Flags |= VRAPI_MODE_FLAG_ALLOW_POWER_SAVE;
            vr_mode_parms.Flags |= VRAPI_MODE_FLAG_NATIVE_WINDOW;

            auto* device = plugin_interface().render_api->device();
            vr_mode_parms.Display = reinterpret_cast<unsigned long long>(device->display);
            vr_mode_parms.WindowSurface = reinterpret_cast<unsigned long long>(device->surface);
            vr_mode_parms.ShareContext = reinterpret_cast<unsigned long long>(device->context);

We set the VRAPI_MODE_FLAG_NATIVE_WINDOW flag, but we also provide the Display, WindowSurface and ShareContext to the vrapi_EnterVrMode call.

As far as I can tell we are setting up the WindowSurface ourselves. Is this a proper way to set this up?

EDIT: The second part was actually commented out earlier with this statement:
            // Don't do this or else the ATW will try to seize the EGL rendering context in vain since it's attached to this thread
            // and it will cause an exception upon vrapi_enterVrMode

Will try without it.

doles
Protege
What is the type of "device->surface" and where does it come from?