From 02f860f374de5c457db731c9f037f47a5d077b14 Mon Sep 17 00:00:00 2001 From: Greg Fodor Date: Tue, 22 May 2018 13:03:05 -0700 Subject: [PATCH 1/3] Add debug mode and ability to set log levels on query string --- src/hub.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/hub.js b/src/hub.js index 8bd8e2a29f..4a19c796d2 100644 --- a/src/hub.js +++ b/src/hub.js @@ -6,6 +6,7 @@ import { patchWebGLRenderingContext } from "./utils/webgl"; patchWebGLRenderingContext(); import "aframe-xr"; +import debug from "debug"; import "./vendor/GLTFLoader"; import "networked-aframe/src/index"; import "naf-janus-adapter"; @@ -129,11 +130,19 @@ function qsTruthy(param) { } const isBotMode = qsTruthy("bot"); +const isTelemetryDisabled = qsTruthy("disable_telemetry"); +const isDebug = qsTruthy("debug"); +const logFilter = qs["log_filter"] || (isDebug && "naf-janus-adapter:*"); -if (!isBotMode) { +if (!isBotMode && !isTelemetryDisabled) { registerTelemetry(); } +// NOTE: this needs to happen after a-frame's `utils/debug.js` file has been eval'ed because it overwrites any prior debug settings :/ +if (logFilter) { + debug.enable(logFilter); +} + disableiOSZoom(); AFRAME.registerInputBehaviour("trackpad_dpad4", trackpad_dpad4); @@ -237,7 +246,8 @@ const onReady = async () => { scene.setAttribute("networked-scene", { room: hubId, - serverURL: process.env.JANUS_SERVER + serverURL: process.env.JANUS_SERVER, + debug: isDebug }); scene.setAttribute("stats-plus", false); @@ -310,12 +320,17 @@ const onReady = async () => { scene.components["networked-scene"].connect().catch(connectError => { // hacky until we get return codes const isFull = connectError.error && connectError.error.msg.match(/\bfull\b/i); + console.error(connectError); remountUI({ roomUnavailableReason: isFull ? "full" : "connect_error" }); exitScene(); return; }); + if (isDebug) { + NAF.connection.adapter.session.options.verbose = true; + } + if (isBotMode) { playerRig.setAttribute("avatar-replay", { camera: "#player-camera", From 1a5c554983701669def3d933a2dd5d05408e5c5a Mon Sep 17 00:00:00 2001 From: Greg Fodor Date: Tue, 22 May 2018 13:04:26 -0700 Subject: [PATCH 2/3] Update README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 5f0bf883f7..a3e7026c4e 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,9 @@ yarn build - `mobile` - Force mobile mode - `no_stats` - Disable performance stats - `vr_entry_type` - Either "gearvr" or "daydream". Used internally to force a VR entry type +- `disable_telemetry` - If `true` disables Sentry telemetry. +- `log_filter` - A `debug` style filter for setting the logging level. +- `debug` - If `true` performs verbose logging of Janus and NAF traffic. ## Additional Resources From fa6a74b766fffefc21db22d59b71751c7168b074 Mon Sep 17 00:00:00 2001 From: Greg Fodor Date: Tue, 22 May 2018 13:13:14 -0700 Subject: [PATCH 3/3] Only flip debug on scene if it is set, but leave it alone otherwise --- src/hub.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hub.js b/src/hub.js index 4a19c796d2..97470e1db7 100644 --- a/src/hub.js +++ b/src/hub.js @@ -246,10 +246,13 @@ const onReady = async () => { scene.setAttribute("networked-scene", { room: hubId, - serverURL: process.env.JANUS_SERVER, - debug: isDebug + serverURL: process.env.JANUS_SERVER }); + if (isDebug) { + scene.setAttribute("networked-scene", { debug: true }); + } + scene.setAttribute("stats-plus", false); if (isMobile || qsTruthy("mobile")) {