Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Disable layers for oculus runtime 1.1.32.0 #3079

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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