Skip to content

Commit

Permalink
Disable layers for oculus runtime 1.1.32.0 (#3079)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemarvin committed Mar 31, 2020
1 parent 4c550ff commit b52ff39
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
Expand Up @@ -1135,6 +1135,14 @@ private void onAppLink(String aJSON) {
});
}

@Keep
@SuppressWarnings("unused")
private void disableLayers() {
runOnUiThread(() -> {
SettingsStore.getInstance(this).setDisableLayers(true);
});
}

private SurfaceTexture createSurfaceTexture() {
int[] ids = new int[1];
GLES20.glGenTextures(1, ids, 0);
Expand Down
Expand Up @@ -98,6 +98,11 @@ SettingsStore getInstance(final @NonNull Context aContext) {

private int mCachedScrollDirection = -1;

private boolean mDisableLayers = false;
public void setDisableLayers(final boolean aDisableLayers) {
mDisableLayers = aDisableLayers;
}

public SettingsStore(Context aContext) {
mContext = aContext;
mPrefs = PreferenceManager.getDefaultSharedPreferences(aContext);
Expand Down Expand Up @@ -409,9 +414,11 @@ public void setMSAALevel(int level) {
}

public boolean getLayersEnabled() {
if (DeviceType.isOculusBuild()) {
if (DeviceType.isOculusBuild() && !mDisableLayers) {
Log.i(LOGTAG, "Layers are enabled");
return true;
}
Log.i(LOGTAG, "Layers are not supported");
return false;
}

Expand Down
14 changes: 13 additions & 1 deletion app/src/main/cpp/VRBrowser.cpp
Expand Up @@ -54,6 +54,8 @@ const char* kHandlePoorPerformance = "handlePoorPerformance";
const char* kHandlePoorPerformanceSignature = "()V";
const char* kOnAppLink = "onAppLink";
const char* kOnAppLinkSignature = "(Ljava/lang/String;)V";
const char* kDisableLayers = "disableLayers";
const char* kDisableLayersSignature = "()V";

JNIEnv* sEnv = nullptr;
jclass sBrowserClass = nullptr;
Expand All @@ -80,6 +82,7 @@ jmethodID sSetDeviceType = nullptr;
jmethodID sHaltActivity = nullptr;
jmethodID sHandlePoorPerformance = nullptr;
jmethodID sOnAppLink = nullptr;
jmethodID sDisableLayers = nullptr;
}

namespace crow {
Expand Down Expand Up @@ -121,6 +124,7 @@ VRBrowser::InitializeJava(JNIEnv* aEnv, jobject aActivity) {
sHaltActivity = FindJNIMethodID(sEnv, sBrowserClass, kHaltActivity, kHaltActivitySignature);
sHandlePoorPerformance = FindJNIMethodID(sEnv, sBrowserClass, kHandlePoorPerformance, kHandlePoorPerformanceSignature);
sOnAppLink = FindJNIMethodID(sEnv, sBrowserClass, kOnAppLink, kOnAppLinkSignature);
sDisableLayers = FindJNIMethodID(sEnv, sBrowserClass, kDisableLayers, kDisableLayersSignature);
}

void
Expand Down Expand Up @@ -155,7 +159,8 @@ VRBrowser::ShutdownJava() {
sAreLayersEnabled = nullptr;
sSetDeviceType = nullptr;
sHaltActivity = nullptr;
sOnAppLink = nullptr;
sOnAppLink = nullptr;
sDisableLayers = nullptr;
sEnv = nullptr;
}

Expand Down Expand Up @@ -353,4 +358,11 @@ VRBrowser::OnAppLink(const std::string& aJSON) {
CheckJNIException(sEnv, __FUNCTION__);
}

void
VRBrowser::DisableLayers() {
if (!ValidateMethodID(sEnv, sActivity, sDisableLayers, __FUNCTION__)) { return; }
sEnv->CallVoidMethod(sActivity, sDisableLayers);
CheckJNIException(sEnv, __FUNCTION__);
}

} // namespace crow
1 change: 1 addition & 0 deletions app/src/main/cpp/VRBrowser.h
Expand Up @@ -40,6 +40,7 @@ void SetDeviceType(const jint aType);
void HaltActivity(const jint aReason);
void HandlePoorPerformance();
void OnAppLink(const std::string& aJSON);
void DisableLayers();
} // namespace VRBrowser;

} // namespace crow
Expand Down
9 changes: 8 additions & 1 deletion app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp
Expand Up @@ -131,7 +131,6 @@ struct DeviceDelegateOculusVR::State {

void Initialize() {
elbow = ElbowModel::Create();
layersEnabled = VRBrowser::AreLayersEnabled();
vrb::RenderContextPtr localContext = context.lock();

java.Vm = app->activity->vm;
Expand All @@ -147,6 +146,14 @@ struct DeviceDelegateOculusVR::State {
return;
}
initialized = true;
std::string version = vrapi_GetVersionString();
if (version.find("1.1.32.0") != std::string::npos) {
VRB_ERROR("Disable layers due to driver bug. VRAPI Runtime Version: %s", vrapi_GetVersionString());
layersEnabled = false;
VRBrowser::DisableLayers();
} else {
layersEnabled = VRBrowser::AreLayersEnabled();
}
SetRenderSize(device::RenderMode::StandAlone);

for (int i = 0; i < VRAPI_EYE_COUNT; ++i) {
Expand Down
Expand Up @@ -12,6 +12,7 @@
import android.view.View;
import android.view.WindowManager;

import org.mozilla.vrbrowser.browser.SettingsStore;
import org.mozilla.vrbrowser.utils.SystemUtils;

public class PlatformActivity extends NativeActivity {
Expand Down

0 comments on commit b52ff39

Please sign in to comment.