Skip to content

Commit

Permalink
Fixing initial crash with autofocus
Browse files Browse the repository at this point in the history
If the scene started with autofocus turned on from the begining,
we were crashing since ARCore wouldnt be initialized then.


Former-commit-id: cc1a6aa7ac9393a896766d49f0cf9aaf28c9b6da
  • Loading branch information
manbod committed Aug 27, 2018
1 parent 6356c3d commit 615ac9a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.viro.core.ViroContext;

import com.viro.core.ViroView;
import com.viro.core.ViroViewARCore;
import com.viro.core.ViroViewScene;
import com.viromedia.bridge.ReactViroPackage;
import com.viromedia.bridge.component.node.VRTScene;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public void run() {
}
}
});

if (navigator.mNeedsAutoFocusToggle) {
navigator.setAutoFocusEnabled(navigator.mAutoFocusEnabled);
navigator.mNeedsAutoFocusToggle = false;
}
}

@Override
Expand Down Expand Up @@ -91,17 +96,6 @@ protected ViroView createViroView(ReactContext reactContext) {
new StartupListenerARCore(this));
}


@Override
public void onPropsSet() {
if (mNeedsAutoFocusToggle) {
if (mViroView != null && mViroView instanceof ViroViewARCore) {
((ViroViewARCore)mViroView).setCameraAutoFocusEnabled(mAutoFocusEnabled);
mNeedsAutoFocusToggle = false;
}
}
}

@Override
public void addView(View child, int index) {
// This view only accepts ARScene and VrView children!
Expand Down Expand Up @@ -131,6 +125,10 @@ protected void onDetachedFromWindow() {

public void setAutoFocusEnabled(boolean enabled) {
mAutoFocusEnabled = enabled;
mNeedsAutoFocusToggle = true;
if (mGLInitialized) {
((ViroViewARCore)mViroView).setCameraAutoFocusEnabled(mAutoFocusEnabled);
} else {
mNeedsAutoFocusToggle = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package com.viromedia.bridge.component;

import android.util.Log;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.annotations.ReactProp;
Expand Down
Binary file modified android/viro_renderer/viro_renderer-release.aar
Binary file not shown.

0 comments on commit 615ac9a

Please sign in to comment.