From 6f898f045894e85fe6c2259bbe072cf007981f14 Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Mon, 18 Nov 2019 19:16:02 +0100 Subject: [PATCH] Only capture screenshots if the first paint is ready (#2304) --- .../org/mozilla/vrbrowser/ui/widgets/WindowWidget.java | 6 ++++-- .../shared/org/mozilla/vrbrowser/ui/widgets/Windows.java | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java index 03bce7043..d5d7a5c3e 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java @@ -978,7 +978,7 @@ public void setFirstDrawCallback(Runnable aRunnable) { @Override public boolean isFirstPaintReady() { - return mWidgetPlacement.composited; + return mWidgetPlacement != null && mWidgetPlacement.composited; } @Override @@ -1536,7 +1536,9 @@ public void onPageStart(@NonNull GeckoSession geckoSession, @NonNull String s) { public void onPageStop(@NonNull GeckoSession aSession, boolean b) { if (mCaptureOnPageStop || !mSession.hasCapturedBitmap()) { mCaptureOnPageStop = false; - captureImage(); + if (isFirstPaintReady()) { + captureImage(); + } } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java index d6bacc533..97f70cc46 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java @@ -973,7 +973,9 @@ public void onTabsClicked() { // Capture active session snapshots when showing the tabs menu for (WindowWidget window: getCurrentWindows()) { - window.captureImage(); + if (window.isFirstPaintReady()) { + window.captureImage(); + } } }