Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller flickering when moving with camera position #1686

Closed
SteveGreatApe opened this issue Jan 3, 2018 · 30 comments
Closed

Controller flickering when moving with camera position #1686

SteveGreatApe opened this issue Jan 3, 2018 · 30 comments
Labels

Comments

@SteveGreatApe
Copy link

SteveGreatApe commented Jan 3, 2018

This is using the same controller code as in #1685, using the latest pull of the framework code. I've based my picker code on that found in the gvr-controller sample, using inputManager.selectController(), to access GVRPicker I've added a call to newController.getPicker().

    inputManager.selectController(new GVRInputManager.ICursorControllerSelectListener() {
        public void onCursorControllerSelected(GVRCursorController newController, GVRCursorController oldController) {
            GVRPicker picker = newController.getPicker();
            EnumSet<GVRPicker.EventOptions> eventOptions = picker.getEventOptions();
            eventOptions.add(GVRPicker.EventOptions.SEND_TO_HIT_OBJECT);
            ...

I attach the picker to the camera with:

GVRCameraRig cameraRig = mMainScene.getMainCameraRig(); cameraRig.getHeadTransformObject().attachComponent(picker);

When I move the camera rig the controller moves with the camera okay, but it displays a very bad flicker, there's two very clear flickering instances of the picker visible whenever the camera position is moving.

@SteveGreatApe
Copy link
Author

A bit of extra detail, I'm updating the camera rig position in a GVRDrawFrameListener.onDrawFrame() callback. I can see from looking in GearCursorController.java that it's posting a message to the EventHandlerThread to call the handleControllerEvent() function that will update the controller position relative to the Camera rig. So that update is getting done out of sync with the other updates that running on the GL Thread which would explain the flickering.

@liaxim liaxim added the bug label Jan 8, 2018
@NolaDonato
Copy link
Contributor

The controller will issue an event every frame. You can update the camera rig right after you handle the controller event and avoid the flickering.

@NolaDonato
Copy link
Contributor

We are looking into enabling a thread-safe way for you to modify the camera transform and avoid flickering. It doesn't work in the draw frame listener because it needs to be done right after the head sensors are read. I might be able to add something for you this week - I need to consult with a colleague to figure out how to do it.

@NolaDonato
Copy link
Contributor

I have added a feature to allow you to update the camera rig safely. It is in PR #1646. The ICameraEvents interface defines the onViewChange function which is not called IMMEDIATELY after the camera rig is updated from the sensor EVERY FRAME. I wrote a test to verify the handler is called. I did not verify it fixes the flickering. Let me know if it still flickers.

ICameraEvents myHandler = new ICameraEvents()
{
public void onViewChange(GVRCameraRig rig)
{
// you can modify the camera rig here safely
// don't do a lot of work in this routine or head tracking will suffer
}
}
GVRContext ctx = ....
ctx.getEventReceiver().addListener(myHandler);

@liaxim
Copy link
Contributor

liaxim commented Jan 11, 2018

@SteveGreatApe Please help me reproduce. Made some tweaks to gvr-controller in https://github.com/liaxim/GearVRf-Demos/tree/test1686. Is this what you have in mind? Thanks.

@SteveGreatApe
Copy link
Author

I've updated my GVRf Keyboard project at https://github.com/SteveGreatApe/AvrKeyboard/tree/GVRfv4x to allow you to move around the environment with the controller.

To use it checkout the GVRfv4x branch and update the following path in build.gradle to point to your GearVRf folder:

// Enable this (and adjust path if necessary) to build from local GearVRf build
        flatDir {
            dirs '../../GearVRf/GearVRf/GVRf/gearvrf-libs'
        }

Once you've got it up and running use the controller touchpad to navigate, swipe left and right to rotate, and press down on the touchpad to move in a direction corresponding to your touch position.

@liaxim
Copy link
Contributor

liaxim commented Jan 12, 2018

Ok, it is not exactly flicker and it is not exactly a thread-safety problem from what I can tell thus far.

Your app is rendering at ~30fps. If continuously pressing the button, the controller model kind of gets left behind. I see a lag of 30+ ms from the time the camera rig is updated to the time the handleControllerEvent runs. Pretty much at the same time the camera rig jumps to the next location but the model is at the one that is 30+ ms old. Every once in a while the stars align and handleControllerEvent gets much more recent camera rig position, the model jumps to a more correct location but then it starts lagging again.

Still trying to comprehend the problem. To me it seems it is all about the lag right now.

@liaxim
Copy link
Contributor

liaxim commented Jan 12, 2018

@SteveGreatApe Please instead of calling directly updateCameraRig from onDrawFrameListener do this:

            mScene.getGVRContext().runOnGlThreadPostRender(0, new Runnable() {
                @Override
                public void run() {
                    updateCameraRig(mCameraRig);
                }
            });

I find a great improvement. I see it as more of a workaround though.

@NolaDonato
Copy link
Contributor

Should GearVRf emit the controller events post-render too?

@NolaDonato
Copy link
Contributor

I removed ICameraEvents since this approach was flawed

@liaxim
Copy link
Contributor

liaxim commented Jan 12, 2018

Regarding controller events from post-render - undecided. I rather look into what are the problems first.

@SteveGreatApe
Copy link
Author

Is there any reason the Picker can't simply be attached to the Camera Rig like it was in 4.0? That worked with no problems and avoided the problem with it not rotating with the camera as well as this flicker issue.

@NolaDonato
Copy link
Contributor

You can attach a picker to the camera any time you want. This still works. You can ignore the picker attached to the controller if you want to. The camera picker will produce pick events (IPickEvents) but not touch events (ITouchEvents).

Each controller has a picker so it can generate touch events. In the case of the Gaze controller, the picker is attached to the camera rig. For the Gear controller. the picker is attached to the controller model in the scene so it will pick from the controller instead of the eye.

@SteveGreatApe
Copy link
Author

I think I see some confusion, I've been using the term Picker to refer the Controller & Picker combined. So what I should actually be saying is I want the Controller attached to the camera rig so it moves and rotates with it. At the moment you're manually moving it in sync with the camera rig, but not rotating it with the rig.

Whereas if the controller was attached to the camera rig it would automatically move and rotate with it, you'd just need to update the relative position and rotation from the received ControllerEvent's.

@NolaDonato
Copy link
Contributor

The controller's position and orientation is reported to us by the system (either Oculus or Daydream). If the controller was attached to the camera rig, we would still need to compute the inverse of the camera rig's transform to maintain a global position that is relative to the camera. The problem would not go away, it would just move somewhere else.

I made a small change to my pull request to help synchronize the picking better. It performs the picking part of controller event processing in the GL thread. See if it fixes your problem.

@SteveGreatApe
Copy link
Author

It still looks flickery to me when moving around.

I've come up with a change that fixes the orientation issue, this matches the controller orientation with the camera rig. Add the "Steve's Mod" section into GearCursorController.java


        void handleControllerEvent(final ControllerEvent event) {
            context.getEventManager().sendEvent(context.getActivity(), IActivityEvents.class, "onControllerEvent",
                                                event.position, event.rotation, event.pointF, event.touched);

            this.currentControllerEvent = event;
            Quaternionf q = event.rotation;
            Vector3f pos = event.position;
            int key = event.key;
            GVRTransform camTrans = context.getMainScene().getMainCameraRig().getTransform();
            float cameraX = camTrans.getPositionX();
            float cameraY = camTrans.getPositionY();
            float cameraZ = camTrans.getPositionZ();

            q.normalize();
            //ZZZ Steve's Mod, translate controller position for camera rig body angle
            Quaternionf cameraQuaternion = new Quaternionf(camTrans.getRotationX(), camTrans.getRotationY(), camTrans.getRotationZ(), camTrans.getRotationW());
            cameraQuaternion.normalize();
            cameraQuaternion.transform(pos);
            q = cameraQuaternion.mul(q);
            //ZZZ End Steve's Mod
            mPivotRoot.getTransform().setRotation(q.w, q.x, q.y, q.z);
            q.transform(FORWARD, result);
            setOrigin(cameraX + pos.x, cameraY + pos.y, cameraZ + pos.z);
            mPivotRoot.getTransform().setPosition(cameraX + pos.x, cameraY + pos.y, cameraZ + pos.z);
            ...

@NolaDonato
Copy link
Contributor

I am looking at your modification to see if what effect it has on the rest of our sample applications. I will include this mod if it doesn't break stuff.

@SteveGreatApe
Copy link
Author

SteveGreatApe commented Feb 7, 2018

Thanks, I've been using it since posting it above and it's working fine for dealing with rotating the controller with the camera rig.

But the flicker and lag issue still exists, is there a reason for not updating the controller postion in GearCursorController.onDrawFrame() itself, rather than posting the update to the EventHandlerThread?

@NolaDonato
Copy link
Contributor

I agree that the code which updates the controller model should be in onDrawFrame. The event generation can stay in the handler thread. I will make this change to PR #1731

@NolaDonato
Copy link
Contributor

I have eliminated the event handler thread entirely for the Gear controller. I am reviewing whether it is needed for the other controllers. You should not see flickering now. If this fix works for your app we will merge it in.

@SteveGreatApe
Copy link
Author

Hi, I've tried using your NolaDonato:controllerfix branch to test this, but I can't get it start up now. It's crashing after getting an error binding a texture. The last log line on thread that dies is as below, followed by the Fatal Signal 11 error. I sometimes get log lines from other threads in between. But it seems this pair consistently go together for the thread that is crashing.

02-14 11:27:33.221 28680-28710/com.greatape.avrgallery E/gvrf: GLImage::bindTexture error: GL_INVALID_ENUM
...
02-14 11:27:33.937 28680-28710/com.greatape.avrgallery A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x1c in tid 28710 (GLThread 27879)

The crash happens after the call to my MainActivity onCreate function has completed including a call to setMain() with my GVRMain derived class. But it doesn't reach my GVRMain onInit function before it dies. So I've done very little work in my app that could have triggered the problem.

Here's the full log for the thread that crashed, this includes an extra log line of the form "ZZZ glBindTexture %d" to log whenever it's binding a texture, and STOP_ON_ERROR defined in gvr_log.h so it stops straight after the error with "Fatal signal 6".

02-14 12:18:03.724 31754-31828/com.greatape.avrgallery V/gvrf: GVRActivity::leaveVrMode
02-14 12:18:03.724 31754-31828/com.greatape.avrgallery W/gvrf: GVRActivity::leaveVrMode: ignored, have not entered vrMode
02-14 12:18:03.830 31754-31828/com.greatape.avrgallery V/OvrVrapiActivityHandler: EGLContextFactory.createContext 0x193BA74E
02-14 12:18:03.834 31754-31828/com.greatape.avrgallery V/OvrVrapiActivityHandler: EGLWindowSurfaceFactory.eglCreatePbufferSurface 0x1988B18E
02-14 12:18:03.836 31754-31828/com.greatape.avrgallery I/OvrVrapiActivityHandler: onSurfaceCreated
02-14 12:18:03.836 31754-31828/com.greatape.avrgallery V/gvrf: GVRActivity::onSurfaceCreated
02-14 12:18:03.836 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --- framebuffer configuration ---
02-14 12:18:03.837 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --- width 1024
02-14 12:18:03.837 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --- height: 1024
02-14 12:18:03.837 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --- multisamples: 2
02-14 12:18:03.837 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --- color texture format: 4
02-14 12:18:03.837 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --- resolve depth: 0
02-14 12:18:03.837 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --- depth texture format: 8
02-14 12:18:03.837 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: ---------------------------------
02-14 12:18:03.837 31754-31828/com.greatape.avrgallery V/GVRViewManager: onSurfaceCreated
02-14 12:18:03.884 31754-31828/com.greatape.avrgallery D/SensorManager: registerListener :: 13, MPL Game Rotation Vector, 0, 0,  
02-14 12:18:03.889 31754-31828/com.greatape.avrgallery I/OvrVrapiActivityHandler: onSurfaceChanged; 2560 x 1440
02-14 12:18:03.889 31754-31828/com.greatape.avrgallery V/gvrf: GVRActivity::leaveVrMode
02-14 12:18:03.889 31754-31828/com.greatape.avrgallery W/gvrf: GVRActivity::leaveVrMode: ignored, have not entered vrMode
02-14 12:18:03.890 31754-31828/com.greatape.avrgallery V/OvrVrapiActivityHandler: --- window surface configuration ---
02-14 12:18:03.892 31754-31828/com.greatape.avrgallery V/OvrVrapiActivityHandler: --- srgb framebuffer: false
02-14 12:18:03.894 31754-31828/com.greatape.avrgallery V/OvrVrapiActivityHandler: --- protected framebuffer: false
02-14 12:18:03.895 31754-31828/com.greatape.avrgallery V/OvrVrapiActivityHandler: ------------------------------------
02-14 12:18:03.897 31754-31828/com.greatape.avrgallery D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000,  [2560x1440]-format:5
02-14 12:18:03.899 31754-31828/com.greatape.avrgallery V/OvrVrapiActivityHandler: mMainSurface: 0x1988a96e
02-14 12:18:03.899 31754-31828/com.greatape.avrgallery V/gvrf: GVRActivityT::onSurfaceChanged
02-14 12:18:03.899 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --- mode configuration ---
02-14 12:18:03.899 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --- allowPowerSave: 1
02-14 12:18:03.899 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --- resetWindowFullscreen: 1
02-14 12:18:03.899 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --------------------------
02-14 12:18:03.900 31754-31828/com.greatape.avrgallery I/VrApi: ---------- vrapi_EnterVrMode [start] ----------
02-14 12:18:03.902 31754-31828/com.greatape.avrgallery D/InputHooksJava: Enabling Java Input Hooks
02-14 12:18:03.902 31754-31828/com.greatape.avrgallery I/OVR_InputDevices: ovrInputDeviceManager::Initialize
02-14 12:18:03.923 31754-31828/com.greatape.avrgallery D/VrApi: getPublicVrProviderProperty: selected_hand: right
02-14 12:18:03.923 31754-31828/com.greatape.avrgallery I/ScreenCapture: GetScreenCaptureFlagFromVrHelper
02-14 12:18:03.936 31754-31828/com.greatape.avrgallery D/VrApi: getPublicVrProviderProperty: screen_capture_state: enabled
02-14 12:18:03.936 31754-31828/com.greatape.avrgallery D/TrackingServiceConnectionGear: onClientConnect
02-14 12:18:03.947 31754-31828/com.greatape.avrgallery D/TrackingServiceConnectionGear: Waiting on connection
02-14 12:18:03.962 31754-31828/com.greatape.avrgallery D/TrackingServiceConnectionGear: TrackingService client: bindService returned true
02-14 12:18:03.963 31754-31828/com.greatape.avrgallery I/TrackingServiceClient: ClientConnectComplete
02-14 12:18:03.967 31754-31828/com.greatape.avrgallery D/VrApi: targetSDKVersion 25
02-14 12:18:03.970 31754-31828/com.greatape.avrgallery I/VrApi: DEVICE MODEL NUMBER = SM-G930F
02-14 12:18:03.970 31754-31828/com.greatape.avrgallery I/VrApi: DEVICE HARDWARE = samsungexynos8890
02-14 12:18:03.970 31754-31828/com.greatape.avrgallery I/VrApi: DEVICE BUILD NAME = NRD90M.G930FXXS1DQLC
02-14 12:18:03.970 31754-31828/com.greatape.avrgallery I/VrApi: DEVICE BUILD TYPE = user
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: DEVICE OS VERSION = 7.0
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: VRAPI VERSION = 1.1.9.0-454768-73575278 Sep 28 2017 12:55:59 Development RELEASE
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: VRAPI LOADER VERSION = 1.1.9.0
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: APP NAME = AvrGallery
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: APP VERSION = 1.0 versionCode 1 internalVersionName <none>
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: APP VR TYPE = vr_only
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: APP PACKAGE NAME = com.greatape.avrgallery
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: APP ACTIVITY CLASS = com.greatape.avrgallery.MainActivity
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: ovrModeParms::VRAPI_MODE_FLAG_ALLOW_POWER_SAVE = 1
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: ovrModeParms::VRAPI_MODE_FLAG_RESET_WINDOW_FULLSCREEN = 1
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: ovrModeParms::VRAPI_MODE_FLAG_NATIVE_WINDOW = 0
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: ovrModeParms::VRAPI_MODE_FLAG_FRONT_BUFFER_PROTECTED = 0
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: ovrModeParms::VRAPI_MODE_FLAG_FRONT_BUFFER_565 = 0
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: ovrModeParms::VRAPI_MODE_FLAG_FRONT_BUFFER_SRGB = 0
02-14 12:18:03.971 31754-31828/com.greatape.avrgallery I/VrApi: HMD sensor attached.
02-14 12:18:03.974 31754-31828/com.greatape.avrgallery I/Vsync: Android reported display refresh rate = 59.00 Hz for display 0
02-14 12:18:03.974 31754-31828/com.greatape.avrgallery I/Vsync: Using VsyncModel 0
02-14 12:18:03.974 31754-31828/com.greatape.avrgallery I/Vsync: Failed to open /sys/class/graphics/fb0/vsync_event (No such file or directory)
02-14 12:18:03.975 31754-31828/com.greatape.avrgallery I/Vsync: Started Choreographer doFrame() callback.
02-14 12:18:03.975 31754-31828/com.greatape.avrgallery D/BatteryReceiver: Registering battery receiver
02-14 12:18:03.987 31754-31828/com.greatape.avrgallery D/HeadsetReceiver: getCurrentHeadsetState: false
02-14 12:18:03.987 31754-31828/com.greatape.avrgallery I/DeviceStatus_Android: nativeHeadsetEvent(0)
02-14 12:18:03.992 31754-31828/com.greatape.avrgallery I/DeviceStatus_Android: nativeGamepadListener(0)
02-14 12:18:03.995 31754-31828/com.greatape.avrgallery I/VrApi: OVR::Clocks thread started
02-14 12:18:03.995 31754-31828/com.greatape.avrgallery I/TimeWarp: ---------------- TimeWarpLocal() ----------------
02-14 12:18:03.995 31754-31828/com.greatape.avrgallery I/TimeWarp: DisplayParms.ScanoutDirection = 0
02-14 12:18:03.995 31754-31828/com.greatape.avrgallery I/TimeWarp: DisplayParms.ShutterType = 0
02-14 12:18:03.995 31754-31828/com.greatape.avrgallery I/TimeWarp: DisplayParms.timing = 0.500000 1.000000
02-14 12:18:03.995 31754-31828/com.greatape.avrgallery I/TimeWarp: DisplayParms.prediction = (1.000000 1.500000) (1.500000 2.000000)
02-14 12:18:03.995 31754-31828/com.greatape.avrgallery I/TimeWarp: TimeWarpAllocatedFrontBuffer = 0
02-14 12:18:03.995 31754-31828/com.greatape.avrgallery I/TimeWarp: Application context EGL_CONTEXT_CLIENT_VERSION = 3
02-14 12:18:03.995 31754-31828/com.greatape.avrgallery I/TimeWarp: frontBufferWidth = 2560
02-14 12:18:03.996 31754-31828/com.greatape.avrgallery I/TimeWarp: frontBufferHeight = 1440
02-14 12:18:03.996 31754-31828/com.greatape.avrgallery I/TimeWarp: frontBufferIsProtected = 0
02-14 12:18:03.996 31754-31828/com.greatape.avrgallery I/TimeWarp: frontBufferIs565 = 0
02-14 12:18:03.996 31754-31828/com.greatape.avrgallery I/TimeWarp: warpMeshClipMode = 1
02-14 12:18:04.134 31754-31828/com.greatape.avrgallery I/TimeWarp: -------------- TimeWarpLocal() End --------------
02-14 12:18:04.134 31754-31828/com.greatape.avrgallery I/VrApi: OVR::Stats thread started
02-14 12:18:04.233 31754-31828/com.greatape.avrgallery D/VrApi: setSchedFifoStatic tid:31832 pto:2
02-14 12:18:04.234 31754-31828/com.greatape.avrgallery D/VRManagerGearVR: Connected to vr service
02-14 12:18:04.240 31754-31828/com.greatape.avrgallery D/VRManagerGearVR: VRManager set thread priority to 2
02-14 12:18:04.240 31754-31828/com.greatape.avrgallery I/VrApi_Clocks: SetSchedFifo( tid=31832, pri=2 ) succeeded
02-14 12:18:04.240 31754-31828/com.greatape.avrgallery D/VrApi: getSystemBrightness
02-14 12:18:04.241 31754-31828/com.greatape.avrgallery D/VRManagerGearVR: Connected to vr service
02-14 12:18:04.262 31754-31828/com.greatape.avrgallery I/VrApi: System brightness = 162
02-14 12:18:04.262 31754-31828/com.greatape.avrgallery D/VrApi: setSystemBrightness 162
02-14 12:18:04.262 31754-31828/com.greatape.avrgallery D/VRManagerGearVR: Connected to vr service
02-14 12:18:04.301 31754-31828/com.greatape.avrgallery I/VrApi: Set brightness to 162
02-14 12:18:04.301 31754-31828/com.greatape.avrgallery D/VrApi: getDoNotDisturbMode 
02-14 12:18:04.301 31754-31828/com.greatape.avrgallery D/VRManagerGearVR: Connected to vr service
02-14 12:18:04.305 31754-31828/com.greatape.avrgallery I/VrApi: Set DND mode to false
02-14 12:18:04.305 31754-31828/com.greatape.avrgallery D/VrApi: setDoNotDisturbMode false
02-14 12:18:04.305 31754-31828/com.greatape.avrgallery D/VRManagerGearVR: Connected to vr service
02-14 12:18:04.310 31754-31828/com.greatape.avrgallery I/VrApi: System DND mode = false
02-14 12:18:04.310 31754-31828/com.greatape.avrgallery I/VrApi: ---------- vrapi_EnterVrMode [end] ----------
02-14 12:18:04.310 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --- performance configuration ---
02-14 12:18:04.310 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --- gpuLevel: 2
02-14 12:18:04.310 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --- cpuLevel: 2
02-14 12:18:04.310 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --------------------------
02-14 12:18:04.316 31754-31828/com.greatape.avrgallery V/gvrf: FrameBufferObject::create: multisampleMode: 1, glRenderbufferStorageMultisampleEXT: 0xf5339e54, glFramebufferTexture2DMultisampleEXT: 0xf5339e68
02-14 12:18:04.327 31754-31828/com.greatape.avrgallery V/gvrf: FrameBufferObject::create: multisampleMode: 1, glRenderbufferStorageMultisampleEXT: 0xf5339e54, glFramebufferTexture2DMultisampleEXT: 0xf5339e68
02-14 12:18:04.332 31754-31828/com.greatape.avrgallery V/gvrf: ConfigurationHelper: --- viewport configuration ---
02-14 12:18:04.333 31754-31828/com.greatape.avrgallery V/OvrViewManager: onSurfaceChanged
02-14 12:18:04.335 31754-31828/com.greatape.avrgallery D/gvrf: Mesh::ctorBuffer vertices = 0xe6c57b00, indices = 0x0
02-14 12:18:04.335 31754-31828/com.greatape.avrgallery D/gvrf: VertexBuffer::setFloatVec a_position 12
02-14 12:18:04.335 31754-31828/com.greatape.avrgallery V/gvrf: VertexBuffer: allocating vertex buffer of 128 bytes with 4 vertices
02-14 12:18:04.335 31754-31828/com.greatape.avrgallery D/gvrf: VertexBuffer::setFloatVec a_normal 12
02-14 12:18:04.335 31754-31828/com.greatape.avrgallery D/gvrf: VertexBuffer::setFloatVec a_texcoord 8
02-14 12:18:04.336 31754-31828/com.greatape.avrgallery V/gvrf: IndexBuffer: 0xcdd8c1e0 allocating index buffer of 12 bytes
02-14 12:18:04.336 31754-31828/com.greatape.avrgallery V/gvrf: Renderer::createIndexBuffer(2, 6) = 0xcdd8c1e0
02-14 12:18:04.682 31754-31828/com.greatape.avrgallery V/gvrf: Texture: BitmapImage::update(bitmap)
02-14 12:18:04.682 31754-31828/com.greatape.avrgallery D/gvrf: Texture: UPDATE_PENDING 
02-14 12:18:04.682 31754-31828/com.greatape.avrgallery V/gvrf: Texture::setImage
02-14 12:18:04.754 31754-31828/com.greatape.avrgallery D/AsyncBitmapTexture: Actual GL_MAX_TEXTURE_SIZE = 16384
02-14 12:18:04.755 31754-31828/com.greatape.avrgallery V/gvrf: GLImage: texture id created is 11
02-14 12:18:04.758 31754-31828/com.greatape.avrgallery V/gvrf: GLImage: ZZZ glBindTexture 11
02-14 12:18:04.758 31754-31828/com.greatape.avrgallery V/gvrf: GLImage: update texparams for 11
02-14 12:18:04.762 31754-31828/com.greatape.avrgallery V/gvrf: GLImage: ZZZ glBindTexture 11
02-14 12:18:04.776 31754-31828/com.greatape.avrgallery I/VrApi: ovr_HandleHmdEvents: HMT was mounted
02-14 12:18:04.776 31754-31828/com.greatape.avrgallery I/ScreenCaptureReceiver: setting new mount status: true
02-14 12:18:04.783 31754-31828/com.greatape.avrgallery W/VrApi: Time to first swap: 3.240 seconds
02-14 12:18:04.783 31754-31828/com.greatape.avrgallery W/VrApi: out of order frame index (prev = 0, new = 2)
02-14 12:18:04.887 31754-31828/com.greatape.avrgallery I/TimeWarp: WarpSwap: Bailed because choreographer callback never got called.
02-14 12:18:04.993 31754-31828/com.greatape.avrgallery I/GVRActivity: handleOnDock
02-14 12:18:05.000 31754-31828/com.greatape.avrgallery V/gvrf: GLImage: texture id created is 12
02-14 12:18:05.001 31754-31828/com.greatape.avrgallery V/gvrf: GLImage: ZZZ glBindTexture 12
02-14 12:18:05.001 31754-31828/com.greatape.avrgallery V/gvrf: GLImage: update texparams for 12
02-14 12:18:05.245 31754-31828/com.greatape.avrgallery V/gvrf: Texture: GLBitmapImage::update(12, bitmap)
02-14 12:18:05.245 31754-31828/com.greatape.avrgallery D/gvrf: Texture: UPDATE_COMPLETE 
02-14 12:18:05.256 31754-31828/com.greatape.avrgallery D/gvrf: SHADER: before add shader 1 GVRTextureShader$u_texture-#a_texcoord#
02-14 12:18:05.257 31754-31828/com.greatape.avrgallery D/gvrf: SHADER: GVRTextureShader$u_texture-#a_texcoord#
02-14 12:18:05.257 31754-31828/com.greatape.avrgallery D/gvrf: SHADER: after obj creation shader 1 GVRTextureShader$u_texture-#a_texcoord#
02-14 12:18:05.260 31754-31828/com.greatape.avrgallery E/GVRShaderTemplate: SHADER: generated shader #1 GVRTextureShader$u_texture-#a_texcoord#
02-14 12:18:05.261 31754-31828/com.greatape.avrgallery V/gvrf: GLImage: texture id created is 13
02-14 12:18:05.261 31754-31828/com.greatape.avrgallery V/gvrf: GLImage: ZZZ glBindTexture 13
02-14 12:18:05.261 31754-31828/com.greatape.avrgallery V/gvrf: GLImage: update texparams for 13
02-14 12:18:05.262 31754-31828/com.greatape.avrgallery V/gvrf: GLImage: ZZZ glBindTexture 13
02-14 12:18:05.264 31754-31828/com.greatape.avrgallery V/gvrf: GLImage: ZZZ glBindTexture 12
02-14 12:18:05.264 31754-31828/com.greatape.avrgallery D/gvrf: VertexBuffer::updateGPU creating vertex array 1
02-14 12:18:05.311 31754-31828/com.greatape.avrgallery W/gvrf: createProgram attaching shaders
02-14 12:18:05.330 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: program 6 texture u_texture loc 0
02-14 12:18:05.330 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: uniform ambient_color has no location in shader 6
02-14 12:18:05.330 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: uniform diffuse_color has no location in shader 6
02-14 12:18:05.330 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: uniform specular_color has no location in shader 6
02-14 12:18:05.330 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: uniform emissive_color has no location in shader 6
02-14 12:18:05.330 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: program 6 uniform u_color loc 3
02-14 12:18:05.330 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: program 6 uniform u_opacity loc 2
02-14 12:18:05.330 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: uniform specular_exponent has no location in shader 6
02-14 12:18:05.330 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: uniform u_view has no location in shader 6
02-14 12:18:05.330 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: program 6 uniform u_mvp loc 1
02-14 12:18:05.330 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: uniform u_mv has no location in shader 6
02-14 12:18:05.331 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: uniform u_mv_it has no location in shader 6
02-14 12:18:05.331 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: uniform u_view_i has no location in shader 6
02-14 12:18:05.331 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: uniform u_model has no location in shader 6
02-14 12:18:05.331 31754-31828/com.greatape.avrgallery V/gvrf: SHADER: uniform u_right has no location in shader 6
02-14 12:18:05.331 31754-31828/com.greatape.avrgallery V/gvrf: GLImage: ZZZ glBindTexture 12
02-14 12:18:05.332 31754-31828/com.greatape.avrgallery E/gvrf: GLImage::bindTexture error: GL_INVALID_ENUM
02-14 12:18:05.332 31754-31828/com.greatape.avrgallery A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 31828 (GLThread 27963)

@NolaDonato
Copy link
Contributor

I rebased my branch with master to prepare for merging. I will look into this.

@bohuang3d
Copy link

@SteveGreatApe Do you get the error at the exact same texture #12 each time you launch? How about after modifying some files of your code and relaunch?

SIGSEGV is segmentation fault. Wondering if corrupt memory somehow changed the values of parameters to glBindTexture() thus throwing GL_INVALID_ENUM.

@NolaDonato
Copy link
Contributor

I just rebased this branch and applied some fixes from another PR which should take care of this crashing. Please try again and let me know if it still crashes for you.

@SteveGreatApe
Copy link
Author

Thanks, it's working now. I found a couple of issues that I've sorted out.

There was still the problem I mentioned before where the controller orientation wasn't getting adjusted properly as you rotate the camera rig. I've fixed that by swapping the order of the multiplication between mTempPivotMtx and q.

diff --git a/GVRf/Framework/framework/src/main/java/org/gearvrf/io/GearCursorController.java b/GVRf/Framework/framework/src/main/java/org/gearvrf/io/GearCursorController.java
index 0b7fdbf..c822a0d 100644
--- a/GVRf/Framework/framework/src/main/java/org/gearvrf/io/GearCursorController.java
+++ b/GVRf/Framework/framework/src/main/java/org/gearvrf/io/GearCursorController.java
@@ -437,8 +437,8 @@ public final class GearCursorController extends GVRCursorController
         x += pos.x;
         y += pos.y;
         z += pos.z;
-        q.mul(mTempRotation);               // rotate pivot by combined event and camera rotation
-        mTempPivotMtx.rotation(q);          // translate pivot by combine event and camera translation
+//        q.mul(mTempRotation);               // rotate pivot by combined event and camera rotation
+        mTempPivotMtx.rotation(mTempRotation.mul(q));          // translate pivot by combine event and camera translation
         mTempPivotMtx.setTranslation(x, y, z);
         mPivotRoot.getTransform().setModelMatrix(mTempPivotMtx);
         setOrigin(x, y, z);

There was still a lag of a frame between updating the camera position and updating the controller position. This is because in OvrViewManager.onDrawFrame it was calling mGearController.onDrawFrame() after actually drawing the frame, whereas usual onDrawFrame callbacks in the application are called just before drawing the frame. I've swapped the order around and it's working okay for me, not sure if there was a reason for doing it the old way around that will makes this more complicated, but seems fine for me at least.

--- a/GVRf/Framework/backend_oculus/src/main/java/org/gearvrf/OvrViewManager.java
+++ b/GVRf/Framework/backend_oculus/src/main/java/org/gearvrf/OvrViewManager.java
@@ -291,14 +291,14 @@ class OvrViewManager extends GVRViewManager implements OvrRotationSensorListener
     /** Called once per frame */
     protected void onDrawFrame() {
         beforeDrawEyes();
-        drawEyes(mActivity.getActivityNative().getNative());
-
         // update the gear controller
         if (mGearController != null)
         {
             mGearController.onDrawFrame();
         }

+        drawEyes(mActivity.getActivityNative().getNative());
+
         afterDrawEyes();
     }

@NolaDonato
Copy link
Contributor

Thanks for your testing! I will test your changes against our samples to make sure they don't break anything.

@SteveGreatApe
Copy link
Author

Hi, I've just pulled from the Master branch and found it's got the fix merged in, but it's missing the two changes I suggested above.

@NolaDonato
Copy link
Contributor

My bad. Wasn't paying attention when merging. Try PR #1775

@SteveGreatApe
Copy link
Author

Thanks, that seems to fix it

@liaxim
Copy link
Contributor

liaxim commented Apr 5, 2018

@SteveGreatApe Planning to close this issue soon.

@liaxim liaxim closed this as completed May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants