Bug 1589913 - Update FxR Desktop default home page r=kip,bzbarsky
☠☠ backed out by fb5acb145e6a ☠ ☠
authorthomasmo <thomasmo@mozilla.com>
Tue, 05 Nov 2019 22:45:38 +0000
changeset 500728 c3813936e0745b02bd1e5e4c6c1ac10e74e2f445
parent 500727 1adbdd45d961602a1dec090e160ba88ddfaa4789
child 500729 2248bd863a26acf22e2522268aa0aff951ce8cc4
push id99796
push usertmoore@mozilla.com
push dateTue, 05 Nov 2019 23:17:49 +0000
treeherderautoland@c3813936e074 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskip, bzbarsky
bugs1589913
milestone72.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 1589913 - Update FxR Desktop default home page r=kip,bzbarsky This change updates the home page to webxr.today for Firefox Realty on Desktop. Further, since WebVR is not supported yet, this change includes a way to disable WebVR specifically for FxR windows without impacting Desktop Fx. Differential Revision: https://phabricator.services.mozilla.com/D51426
browser/fxr/content/fxrui.js
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/base/nsGlobalWindowInner.cpp
dom/ipc/BrowserParent.cpp
dom/ipc/BrowserParent.h
dom/ipc/PBrowser.ipdl
gfx/vr/nsFxrCommandLineHandler.cpp
--- a/browser/fxr/content/fxrui.js
+++ b/browser/fxr/content/fxrui.js
@@ -1,17 +1,17 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* import-globals-from common.js */
 
 // Configuration vars
-let homeURL = "https://www.mozilla.org/en-US/";
+let homeURL = "https://webxr.today/";
 // Bug 1586294 - Localize the privacy policy URL (Services.urlFormatter?)
 let privacyPolicyURL = "https://www.mozilla.org/en-US/privacy/firefox/";
 let reportIssueURL = "https://mzl.la/fxr";
 let licenseURL =
   "https://mixedreality.mozilla.org/FirefoxRealityPC/license.html";
 
 // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/browser
 let browser = null;
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1397,17 +1397,18 @@ Promise* Navigator::Share(const ShareDat
     text.Assign(NS_ConvertUTF16toUTF8(aData.mText.Value()));
   } else {
     text.SetIsVoid(true);
   }
 
   // The spec does the "triggered by user activation" after the data checks.
   // Unfortunately, both Chrome and Safari behave this way, so interop wins.
   // https://github.com/w3c/web-share/pull/118
-  if (StaticPrefs::dom_webshare_requireinteraction() && !UserActivation::IsHandlingUserInput()) {
+  if (StaticPrefs::dom_webshare_requireinteraction() &&
+      !UserActivation::IsHandlingUserInput()) {
     NS_WARNING("Attempt to share not triggered by user activation");
     aRv.Throw(NS_ERROR_DOM_NOT_ALLOWED_ERR);
     return nullptr;
   }
 
   // Let mSharePromise be a new promise.
   mSharePromise = Promise::Create(mWindow->AsGlobal(), aRv);
   if (aRv.Failed()) {
@@ -1483,25 +1484,71 @@ already_AddRefed<Promise> Navigator::Get
   nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(mWindow);
   win->NotifyVREventListenerAdded();
 
   RefPtr<Promise> p = Promise::Create(mWindow->AsGlobal(), aRv);
   if (aRv.Failed()) {
     return nullptr;
   }
 
-  // We pass mWindow's id to RefreshVRDisplays, so NotifyVRDisplaysUpdated will
-  // be called asynchronously, resolving the promises in mVRGetDisplaysPromises.
-  if (!VRDisplay::RefreshVRDisplays(win->WindowID())) {
-    p->MaybeReject(NS_ERROR_FAILURE);
-    return p.forget();
+  RefPtr<BrowserChild> browser(BrowserChild::GetFrom(mWindow));
+  if (!browser) {
+    MOZ_ASSERT(XRE_IsParentProcess());
+    FinishGetVRDisplays(true, p);
+  } else {
+    RefPtr<Navigator> self(this);
+    int browserID = browser->ChromeOuterWindowID();
+
+    browser->SendIsWindowSupportingWebVR(browserID)->Then(
+        GetCurrentThreadSerialEventTarget(), __func__,
+        [self, p](bool isSupported) {
+          self->FinishGetVRDisplays(isSupported, p);
+        },
+        [](const mozilla::ipc::ResponseRejectReason) {
+          MOZ_CRASH("Failed to make IPC call to IsWindowSupportingWebVR");
+        });
   }
 
+  return p.forget();
+}
+
+void Navigator::FinishGetVRDisplays(bool isWebVRSupportedInwindow, Promise* p) {
+  if (isWebVRSupportedInwindow) {
+    nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(mWindow);
+
+    // Since FinishGetVRDisplays can be called asynchronously after an IPC
+    // response, it's possible that the Window can be torn down before this
+    // call. In that case, the Window's cyclic references to VR objects are
+    // also torn down and should not be recreated via
+    // NotifyVREventListenerAdded.
+    if (!win->IsDying()) {
+      win->NotifyVREventListenerAdded();
+      // We pass mWindow's id to RefreshVRDisplays, so
+      // NotifyVRDisplaysUpdated will be called asynchronously, resolving
+      // the promises in mVRGetDisplaysPromises.
+      if (!VRDisplay::RefreshVRDisplays(win->WindowID())) {
+        // Failed to refresh, reject the promise now
+        p->MaybeRejectWithTypeError(u"Failed to find attached VR displays.");
+      } else {
+        // Succeeded, so cache the promise to resolve later
+        mVRGetDisplaysPromises.AppendElement(p);
+      }
+    } else {
+      // The Window has been torn down, so there is no further work that can
+      // be done.
+      p->MaybeRejectWithTypeError(
+          u"Unable to return VRDisplays for a closed window.");
+    }
+  } else {
+    // WebVR in this window is not supported, so resolve the promise
+    // with no displays available
+    nsTArray<RefPtr<VRDisplay>> vrDisplaysEmpty;
+    p->MaybeResolve(vrDisplaysEmpty);
+  }
   mVRGetDisplaysPromises.AppendElement(p);
-  return p.forget();
 }
 
 void Navigator::GetActiveVRDisplays(
     nsTArray<RefPtr<VRDisplay>>& aDisplays) const {
   /**
    * Get only the active VR displays.
    * GetActiveVRDisplays should only enumerate displays that
    * are already active without causing any other hardware to be
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -174,16 +174,17 @@ class Navigator final : public nsISuppor
 
   already_AddRefed<LegacyMozTCPSocket> MozTCPSocket();
   network::Connection* GetConnection(ErrorResult& aRv);
   MediaDevices* GetMediaDevices(ErrorResult& aRv);
 
   void GetGamepads(nsTArray<RefPtr<Gamepad>>& aGamepads, ErrorResult& aRv);
   GamepadServiceTest* RequestGamepadServiceTest();
   already_AddRefed<Promise> GetVRDisplays(ErrorResult& aRv);
+  void FinishGetVRDisplays(bool isWebVRSupportedInwindow, Promise* p);
   void GetActiveVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays) const;
   VRServiceTest* RequestVRServiceTest();
   bool IsWebVRContentDetected() const;
   bool IsWebVRContentPresenting() const;
   void RequestVRPresentation(VRDisplay& aDisplay);
   already_AddRefed<Promise> RequestMIDIAccess(const MIDIOptions& aOptions,
                                               ErrorResult& aRv);
 
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -4087,16 +4087,17 @@ void nsGlobalWindowInner::DisableGamepad
     RefPtr<GamepadManager> gamepadManager(GamepadManager::GetService());
     if (gamepadManager) {
       gamepadManager->RemoveListener(this);
     }
   }
 }
 
 void nsGlobalWindowInner::EnableVRUpdates() {
+  MOZ_ASSERT(!IsDying());
   if (mHasVREvents && !mVREventObserver) {
     mVREventObserver = new VREventObserver(this);
     nsPIDOMWindowOuter* outer = GetOuterWindow();
     if (outer && !outer->IsBackground()) {
       mVREventObserver->StartActivity();
     }
   }
 }
--- a/dom/ipc/BrowserParent.cpp
+++ b/dom/ipc/BrowserParent.cpp
@@ -3991,10 +3991,24 @@ mozilla::ipc::IPCResult BrowserParent::R
   aResolve(!isFxrWindow);
 #else
   MOZ_CRASH("Should only be called on Windows");
 #endif
 
   return IPC_OK();
 }
 
+mozilla::ipc::IPCResult BrowserParent::RecvIsWindowSupportingWebVR(
+    const uint64_t& aOuterWindowID,
+    IsWindowSupportingWebVRResolver&& aResolve) {
+#ifdef XP_WIN
+  bool isFxrWindow =
+      FxRWindowManager::GetInstance()->IsFxRWindow(aOuterWindowID);
+  aResolve(!isFxrWindow);
+#else
+  aResolve(true);
+#endif
+
+  return IPC_OK();
+}
+
 }  // namespace dom
 }  // namespace mozilla
--- a/dom/ipc/BrowserParent.h
+++ b/dom/ipc/BrowserParent.h
@@ -502,16 +502,20 @@ class BrowserParent final : public PBrow
       PBrowserBridgeParent* aActor, const nsString& aPresentationURL,
       const nsString& aRemoteType, BrowsingContext* aBrowsingContext,
       const uint32_t& aChromeFlags, const TabId& aTabId) override;
 
   mozilla::ipc::IPCResult RecvIsWindowSupportingProtectedMedia(
       const uint64_t& aOuterWindowID,
       IsWindowSupportingProtectedMediaResolver&& aResolve);
 
+  mozilla::ipc::IPCResult RecvIsWindowSupportingWebVR(
+      const uint64_t& aOuterWindowID,
+      IsWindowSupportingWebVRResolver&& aResolve);
+
   void LoadURL(nsIURI* aURI);
 
   void ResumeLoad(uint64_t aPendingSwitchID);
 
   void InitRendering();
   bool AttachLayerManager();
   void MaybeShowFrame();
 
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -1030,16 +1030,21 @@ child:
     async SkipBrowsingContextDetach() returns (bool success);
 
 parent:
     /**
      * Fetches whether this window supports protected media, which is sent back in response.
      */
     async IsWindowSupportingProtectedMedia(uint64_t aOuterWindowID) returns(bool isSupported);
 
+    /**
+    * Fetches whether this window supports WebVR, which is sent back in response.
+    */
+    async IsWindowSupportingWebVR(uint64_t aOuterWindowID) returns(bool isSupported);
+
     /** Records a history visit. */
     async VisitURI(URIParams aURI, URIParams? aLastVisitedURI,
                    uint32_t aFlags);
 
     /** Fetches the visited status for an array of URIs (Android-only). */
     async QueryVisitedState(URIParams[] aURIs);
 
     /**
--- a/gfx/vr/nsFxrCommandLineHandler.cpp
+++ b/gfx/vr/nsFxrCommandLineHandler.cpp
@@ -60,16 +60,20 @@ NS_IMPL_ISUPPORTS(nsFxrCommandLineHandle
 //      ...                       ...                     ...
 
 NS_IMETHODIMP
 nsFxrCommandLineHandler::Handle(nsICommandLine* aCmdLine) {
   bool handleFlagRetVal = false;
   nsresult result =
       aCmdLine->HandleFlag(NS_LITERAL_STRING("fxr"), false, &handleFlagRetVal);
   if (result == NS_OK && handleFlagRetVal) {
+    if (XRE_IsParentProcess() && !XRE_IsE10sParentProcess()) {
+      MOZ_CRASH("--fxr not supported without e10s");
+    }
+
     aCmdLine->SetPreventDefault(true);
 
     nsCOMPtr<nsIWindowWatcher> wwatch =
         do_GetService(NS_WINDOWWATCHER_CONTRACTID);
     NS_ENSURE_TRUE(wwatch, NS_ERROR_FAILURE);
 
     nsCOMPtr<mozIDOMWindowProxy> newWindow;
     result = wwatch->OpenWindow(nullptr,                            // aParent