From 269f751ce7e71e1f3aea62d604b17557ae3b727c Mon Sep 17 00:00:00 2001 From: James Willcox Date: Thu, 17 Jan 2019 14:17:50 +0000 Subject: [PATCH] Bug 1514253 - Create PanZoomController immediately in GeckoSession r=geckoview-reviewers,droeh#geckoview-reviewers Differential Revision: https://phabricator.services.mozilla.com/D14562 --HG-- extra : moz-landing-system : lando --- .../java/org/mozilla/geckoview/GeckoSession.java | 15 +++------------ widget/android/nsWindow.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java index 05f1040e0c07..950cfa0fc15b 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java @@ -107,7 +107,7 @@ public class GeckoSession implements Parcelable { private boolean mShouldPinOnScreen; // All fields are accessed on UI thread only. - private PanZoomController mNPZC; + private PanZoomController mPanZoomController = new PanZoomController(this); private OverscrollEdgeEffect mOverscroll; private DynamicToolbarAnimator mToolbar; private CompositorController mController; @@ -3658,13 +3658,7 @@ public class GeckoSession implements Parcelable { public @NonNull PanZoomController getPanZoomController() { ThreadUtils.assertOnUiThread(); - if (mNPZC == null) { - mNPZC = new PanZoomController(this); - if (mAttachedCompositor) { - mCompositor.attachNPZC(mNPZC); - } - } - return mNPZC; + return mPanZoomController; } /** @@ -4340,10 +4334,7 @@ public class GeckoSession implements Parcelable { } mAttachedCompositor = true; - - if (mNPZC != null) { - mCompositor.attachNPZC(mNPZC); - } + mCompositor.attachNPZC(mPanZoomController); if (mSurface != null) { // If we have a valid surface, create the compositor now that we're attached. diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index a88e576fa4e8..e8f92242efa1 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -890,7 +890,14 @@ class nsWindow::LayerViewSupport final } MOZ_ASSERT(aNPZC); - MOZ_ASSERT(!mWindow->mNPZCSupport); + + // We can have this situation if we get two GeckoViewSupport::Transfer() + // called before the first AttachNPZC() gets here. Just detach the current + // instance since that's what happens in GeckoViewSupport::Transfer() as + // well. + if (mWindow->mNPZCSupport) { + mWindow->mNPZCSupport.Detach(mWindow->mNPZCSupport->GetJavaNPZC()); + } auto npzc = PanZoomController::LocalRef( jni::GetGeckoThreadEnv(), PanZoomController::Ref::From(aNPZC));