Skip to content

Commit

Permalink
Add application notes to crash report (#3106)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemarvin committed Apr 22, 2020
1 parent 34f07c6 commit 79098ed
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.mozilla.vrbrowser.browser.Accounts;
import org.mozilla.vrbrowser.browser.PermissionDelegate;
import org.mozilla.vrbrowser.browser.SettingsStore;
import org.mozilla.vrbrowser.browser.engine.EngineProvider;
import org.mozilla.vrbrowser.browser.engine.Session;
import org.mozilla.vrbrowser.browser.engine.SessionStore;
import org.mozilla.vrbrowser.crashreporting.CrashReporterService;
Expand Down Expand Up @@ -252,6 +253,8 @@ protected void onCreate(Bundle savedInstanceState) {
SessionStore.get().initializeStores(this);
SessionStore.get().setLocales(LocaleUtils.getPreferredLanguageTags(this));

EngineProvider.INSTANCE.getOrCreateRuntime(this).appendAppNotesToCrashReport("Firefox Reality " + BuildConfig.VERSION_NAME + "-" + BuildConfig.VERSION_CODE + "-" + BuildConfig.FLAVOR + "-" + BuildConfig.BUILD_TYPE + " (" + BuildConfig.GIT_HASH + ")");

// Create broadcast receiver for getting crash messages from crash process
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(CrashReporterService.CRASH_ACTION);
Expand Down Expand Up @@ -1209,6 +1212,12 @@ private void disableLayers() {
});
}

@Keep
@SuppressWarnings("unused")
private void appendAppNotesToCrashReport(String aNotes) {
runOnUiThread(() -> EngineProvider.INSTANCE.getOrCreateRuntime(VRBrowserActivity.this).appendAppNotesToCrashReport(aNotes));
}

private SurfaceTexture createSurfaceTexture() {
int[] ids = new int[1];
GLES20.glGenTextures(1, ids, 0);
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/cpp/VRBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const char* kOnAppLink = "onAppLink";
const char* kOnAppLinkSignature = "(Ljava/lang/String;)V";
const char* kDisableLayers = "disableLayers";
const char* kDisableLayersSignature = "()V";
const char* kAppendAppNotesToCrashReport = "appendAppNotesToCrashReport";
const char* kAppendAppNotesToCrashReportSignature = "(Ljava/lang/String;)V";

JNIEnv* sEnv = nullptr;
jclass sBrowserClass = nullptr;
Expand Down Expand Up @@ -86,6 +88,7 @@ jmethodID sHaltActivity = nullptr;
jmethodID sHandlePoorPerformance = nullptr;
jmethodID sOnAppLink = nullptr;
jmethodID sDisableLayers = nullptr;
jmethodID sAppendAppNotesToCrashReport = nullptr;
}

namespace crow {
Expand Down Expand Up @@ -129,6 +132,7 @@ VRBrowser::InitializeJava(JNIEnv* aEnv, jobject aActivity) {
sHandlePoorPerformance = FindJNIMethodID(sEnv, sBrowserClass, kHandlePoorPerformance, kHandlePoorPerformanceSignature);
sOnAppLink = FindJNIMethodID(sEnv, sBrowserClass, kOnAppLink, kOnAppLinkSignature);
sDisableLayers = FindJNIMethodID(sEnv, sBrowserClass, kDisableLayers, kDisableLayersSignature);
sAppendAppNotesToCrashReport = FindJNIMethodID(sEnv, sBrowserClass, kAppendAppNotesToCrashReport, kAppendAppNotesToCrashReportSignature);
}

void
Expand Down Expand Up @@ -167,6 +171,7 @@ VRBrowser::ShutdownJava() {
sOnAppLink = nullptr;
sDisableLayers = nullptr;
sEnv = nullptr;
kAppendAppNotesToCrashReport = nullptr;
}

void
Expand Down Expand Up @@ -376,4 +381,13 @@ VRBrowser::DisableLayers() {
CheckJNIException(sEnv, __FUNCTION__);
}

void
VRBrowser::AppendAppNotesToCrashLog(const std::string& aNotes) {
if (!ValidateMethodID(sEnv, sActivity, sAppendAppNotesToCrashReport, __FUNCTION__)) { return; }
jstring notes = sEnv->NewStringUTF(aNotes.c_str());
sEnv->CallVoidMethod(sActivity, sAppendAppNotesToCrashReport, notes);
sEnv->DeleteLocalRef(notes);
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 @@ -42,6 +42,7 @@ void HaltActivity(const jint aReason);
void HandlePoorPerformance();
void OnAppLink(const std::string& aJSON);
void DisableLayers();
void AppendAppNotesToCrashLog(const std::string& aNotes);
} // namespace VRBrowser;

} // namespace crow
Expand Down
5 changes: 5 additions & 0 deletions app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ struct DeviceDelegateOculusVR::State {
}
initialized = true;

std::string version = vrapi_GetVersionString();
std::string notes = "Oculus Driver Version: ";
notes += version;
VRBrowser::AppendAppNotesToCrashLog(notes);

layersEnabled = VRBrowser::AreLayersEnabled();
SetRenderSize(device::RenderMode::StandAlone);

Expand Down

0 comments on commit 79098ed

Please sign in to comment.