Bug 1533197 - Pointing back to the same VR input action manifest file when the file has been existing. r=kip
authorDaosheng Mu <daoshengmu@gmail.com>
Wed, 17 Apr 2019 23:08:27 +0000
changeset 469963 b6723fd7683854907fd4b48cfdf73a406d825598
parent 469962 50c1ff58c6824782afdc10e65ee28cccdb60f7b2
child 469964 08611f20a20a8dbca2ec09a488430ad13a66d99a
push id35884
push userapavel@mozilla.com
push dateThu, 18 Apr 2019 21:35:00 +0000
treeherdermozilla-central@74dc09642c22 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskip
bugs1533197
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1533197 - Pointing back to the same VR input action manifest file when the file has been existing. r=kip Differential Revision: https://phabricator.services.mozilla.com/D27816
gfx/vr/service/OpenVRSession.cpp
--- a/gfx/vr/service/OpenVRSession.cpp
+++ b/gfx/vr/service/OpenVRSession.cpp
@@ -490,218 +490,216 @@ void OpenVRSession::SetupContollerAction
   rightContollerInfo.mActionFingerRing_Value = ControllerAction(
       "/actions/firefox/in/RHand_finger_ring_value", "vector1");
   rightContollerInfo.mActionFingerPinky_Value = ControllerAction(
       "/actions/firefox/in/RHand_finger_pinky_value", "vector1");
 
   mControllerHand[OpenVRHand::Left] = leftContollerInfo;
   mControllerHand[OpenVRHand::Right] = rightContollerInfo;
 
-  if (FileIsExisting(controllerAction)) {
-    return;
-  }
-
-  nsAutoString actionData;
-  JSONWriter actionWriter(MakeUnique<StringWriteFunc>(actionData));
-  actionWriter.Start();
+  if (!FileIsExisting(controllerAction)) {
+    nsAutoString actionData;
+    JSONWriter actionWriter(MakeUnique<StringWriteFunc>(actionData));
+    actionWriter.Start();
 
-  actionWriter.StringProperty("version",
-                              "0.1.0");  // TODO: adding a version check.
-  // "default_bindings": []
-  actionWriter.StartArrayProperty("default_bindings");
-  actionWriter.StartObjectElement();
-  actionWriter.StringProperty("controller_type", "vive_controller");
-  actionWriter.StringProperty("binding_url", viveManifest.BeginReading());
-  actionWriter.EndObject();
-  actionWriter.StartObjectElement();
-  actionWriter.StringProperty("controller_type", "knuckles");
-  actionWriter.StringProperty("binding_url", knucklesManifest.BeginReading());
-  actionWriter.EndObject();
-#if defined(XP_WIN)
-  actionWriter.StartObjectElement();
-  actionWriter.StringProperty("controller_type", "holographic_controller");
-  actionWriter.StringProperty("binding_url", WMRManifest.BeginReading());
-  actionWriter.EndObject();
-#endif
-  actionWriter.EndArray();  // End "default_bindings": []
-
-  // "actions": [] Action paths must take the form: "/actions/<action
-  // set>/in|out/<action>"
-  actionWriter.StartArrayProperty("actions");
-
-  for (auto& controller : mControllerHand) {
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty("name",
-                                controller.mActionPose.name.BeginReading());
-    actionWriter.StringProperty("type",
-                                controller.mActionPose.type.BeginReading());
-    actionWriter.EndObject();
-
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionTrackpad_Analog.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionTrackpad_Analog.type.BeginReading());
-    actionWriter.EndObject();
-
+    actionWriter.StringProperty("version",
+                                "0.1.0");  // TODO: adding a version check.
+    // "default_bindings": []
+    actionWriter.StartArrayProperty("default_bindings");
     actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionTrackpad_Pressed.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionTrackpad_Pressed.type.BeginReading());
+    actionWriter.StringProperty("controller_type", "vive_controller");
+    actionWriter.StringProperty("binding_url", viveManifest.BeginReading());
     actionWriter.EndObject();
-
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionTrackpad_Touched.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionTrackpad_Touched.type.BeginReading());
-    actionWriter.EndObject();
-
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionTrigger_Value.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionTrigger_Value.type.BeginReading());
-    actionWriter.EndObject();
-
     actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionGrip_Pressed.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionGrip_Pressed.type.BeginReading());
-    actionWriter.EndObject();
-
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionGrip_Touched.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionGrip_Touched.type.BeginReading());
+    actionWriter.StringProperty("controller_type", "knuckles");
+    actionWriter.StringProperty("binding_url", knucklesManifest.BeginReading());
     actionWriter.EndObject();
-
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionMenu_Pressed.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionMenu_Pressed.type.BeginReading());
-    actionWriter.EndObject();
-
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionMenu_Touched.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionMenu_Touched.type.BeginReading());
-    actionWriter.EndObject();
-
+#if defined(XP_WIN)
     actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionSystem_Pressed.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionSystem_Pressed.type.BeginReading());
+    actionWriter.StringProperty("controller_type", "holographic_controller");
+    actionWriter.StringProperty("binding_url", WMRManifest.BeginReading());
     actionWriter.EndObject();
+#endif
+    actionWriter.EndArray();  // End "default_bindings": []
+
+    // "actions": [] Action paths must take the form: "/actions/<action
+    // set>/in|out/<action>"
+    actionWriter.StartArrayProperty("actions");
+
+    for (auto& controller : mControllerHand) {
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty("name",
+                                  controller.mActionPose.name.BeginReading());
+      actionWriter.StringProperty("type",
+                                  controller.mActionPose.type.BeginReading());
+      actionWriter.EndObject();
 
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionSystem_Touched.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionSystem_Touched.type.BeginReading());
-    actionWriter.EndObject();
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionTrackpad_Analog.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionTrackpad_Analog.type.BeginReading());
+      actionWriter.EndObject();
 
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionA_Pressed.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionA_Pressed.type.BeginReading());
-    actionWriter.EndObject();
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionTrackpad_Pressed.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionTrackpad_Pressed.type.BeginReading());
+      actionWriter.EndObject();
+
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionTrackpad_Touched.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionTrackpad_Touched.type.BeginReading());
+      actionWriter.EndObject();
 
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionA_Touched.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionA_Touched.type.BeginReading());
-    actionWriter.EndObject();
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionTrigger_Value.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionTrigger_Value.type.BeginReading());
+      actionWriter.EndObject();
 
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionB_Pressed.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionB_Pressed.type.BeginReading());
-    actionWriter.EndObject();
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionGrip_Pressed.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionGrip_Pressed.type.BeginReading());
+      actionWriter.EndObject();
+
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionGrip_Touched.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionGrip_Touched.type.BeginReading());
+      actionWriter.EndObject();
 
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionB_Touched.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionB_Touched.type.BeginReading());
-    actionWriter.EndObject();
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionMenu_Pressed.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionMenu_Pressed.type.BeginReading());
+      actionWriter.EndObject();
+
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionMenu_Touched.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionMenu_Touched.type.BeginReading());
+      actionWriter.EndObject();
 
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionThumbstick_Analog.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionThumbstick_Analog.type.BeginReading());
-    actionWriter.EndObject();
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionSystem_Pressed.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionSystem_Pressed.type.BeginReading());
+      actionWriter.EndObject();
+
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionSystem_Touched.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionSystem_Touched.type.BeginReading());
+      actionWriter.EndObject();
 
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionThumbstick_Pressed.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionThumbstick_Pressed.type.BeginReading());
-    actionWriter.EndObject();
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionA_Pressed.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionA_Pressed.type.BeginReading());
+      actionWriter.EndObject();
 
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionThumbstick_Touched.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionThumbstick_Touched.type.BeginReading());
-    actionWriter.EndObject();
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionA_Touched.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionA_Touched.type.BeginReading());
+      actionWriter.EndObject();
+
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionB_Pressed.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionB_Pressed.type.BeginReading());
+      actionWriter.EndObject();
 
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionFingerIndex_Value.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionFingerIndex_Value.type.BeginReading());
-    actionWriter.EndObject();
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionB_Touched.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionB_Touched.type.BeginReading());
+      actionWriter.EndObject();
 
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionFingerMiddle_Value.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionFingerMiddle_Value.type.BeginReading());
-    actionWriter.EndObject();
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionThumbstick_Analog.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionThumbstick_Analog.type.BeginReading());
+      actionWriter.EndObject();
+
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionThumbstick_Pressed.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionThumbstick_Pressed.type.BeginReading());
+      actionWriter.EndObject();
 
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionFingerRing_Value.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionFingerRing_Value.type.BeginReading());
-    actionWriter.EndObject();
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionThumbstick_Touched.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionThumbstick_Touched.type.BeginReading());
+      actionWriter.EndObject();
 
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty(
-        "name", controller.mActionFingerPinky_Value.name.BeginReading());
-    actionWriter.StringProperty(
-        "type", controller.mActionFingerPinky_Value.type.BeginReading());
-    actionWriter.EndObject();
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionFingerIndex_Value.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionFingerIndex_Value.type.BeginReading());
+      actionWriter.EndObject();
+
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionFingerMiddle_Value.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionFingerMiddle_Value.type.BeginReading());
+      actionWriter.EndObject();
 
-    actionWriter.StartObjectElement();
-    actionWriter.StringProperty("name",
-                                controller.mActionHaptic.name.BeginReading());
-    actionWriter.StringProperty("type",
-                                controller.mActionHaptic.type.BeginReading());
-    actionWriter.EndObject();
-  }
-  actionWriter.EndArray();  // End "actions": []
-  actionWriter.End();
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionFingerRing_Value.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionFingerRing_Value.type.BeginReading());
+      actionWriter.EndObject();
+
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty(
+          "name", controller.mActionFingerPinky_Value.name.BeginReading());
+      actionWriter.StringProperty(
+          "type", controller.mActionFingerPinky_Value.type.BeginReading());
+      actionWriter.EndObject();
 
-  std::ofstream actionfile(controllerAction.BeginReading());
-  nsCString actionResult(NS_ConvertUTF16toUTF8(actionData.get()));
-  if (actionfile.is_open()) {
-    actionfile << actionResult.get();
-    actionfile.close();
+      actionWriter.StartObjectElement();
+      actionWriter.StringProperty("name",
+                                  controller.mActionHaptic.name.BeginReading());
+      actionWriter.StringProperty("type",
+                                  controller.mActionHaptic.type.BeginReading());
+      actionWriter.EndObject();
+    }
+    actionWriter.EndArray();  // End "actions": []
+    actionWriter.End();
+
+    std::ofstream actionfile(controllerAction.BeginReading());
+    nsCString actionResult(NS_ConvertUTF16toUTF8(actionData.get()));
+    if (actionfile.is_open()) {
+      actionfile << actionResult.get();
+      actionfile.close();
+    }
   }
 
   vr::VRInput()->SetActionManifestPath(controllerAction.BeginReading());
 
   // Notify the parent process these manifest files are already been recorded.
   if (gfxPrefs::VRProcessEnabled()) {
     NS_DispatchToMainThread(NS_NewRunnableFunction(
         "SendOpenVRControllerActionPathToParent",