From 3ac6ea5a3cbaef60c88a56a39b3312272b0641d4 Mon Sep 17 00:00:00 2001 From: "Randall E. Barker" Date: Tue, 22 Oct 2019 11:42:27 -0700 Subject: [PATCH] Clone WidgetPlacement before sending to VR render thread to prevent concurrent access. --- .../mozilla/vrbrowser/VRBrowserActivity.java | 18 ++++++++---------- .../vrbrowser/ui/widgets/WidgetPlacement.java | 3 ++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java index 76a9133933..28b55b88de 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java @@ -1055,15 +1055,9 @@ public int newWidgetHandle() { public void addWidgets(final Iterable aWidgets) { - for (Widget widget: aWidgets) { - mWidgets.put(widget.getHandle(), widget); - ((View)widget).setVisibility(widget.getPlacement().visible ? View.VISIBLE : View.GONE); + for (Widget widget : aWidgets) { + addWidget(widget); } - queueRunnable(() -> { - for (Widget widget: aWidgets) { - addWidgetNative(widget.getHandle(), widget.getPlacement()); - } - }); } private void updateActiveDialog(final Widget aWidget) { @@ -1087,13 +1081,17 @@ private boolean isWidgetInputEnabled(Widget aWidget) { public void addWidget(Widget aWidget) { mWidgets.put(aWidget.getHandle(), aWidget); ((View)aWidget).setVisibility(aWidget.getPlacement().visible ? View.VISIBLE : View.GONE); - queueRunnable(() -> addWidgetNative(aWidget.getHandle(), aWidget.getPlacement())); + final int handle = aWidget.getHandle(); + final WidgetPlacement clone = aWidget.getPlacement().clone(); + queueRunnable(() -> addWidgetNative(handle, clone)); updateActiveDialog(aWidget); } @Override public void updateWidget(final Widget aWidget) { - queueRunnable(() -> updateWidgetNative(aWidget.getHandle(), aWidget.getPlacement())); + final int handle = aWidget.getHandle(); + final WidgetPlacement clone = aWidget.getPlacement().clone(); + queueRunnable(() -> updateWidgetNative(handle, clone)); final int textureWidth = aWidget.getPlacement().textureWidth(); final int textureHeight = aWidget.getPlacement().textureHeight(); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WidgetPlacement.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WidgetPlacement.java index ae322db5c7..754bc299d4 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WidgetPlacement.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WidgetPlacement.java @@ -95,10 +95,11 @@ public void copyFrom(WidgetPlacement w) { this.proxifyLayer = w.proxifyLayer; this.textureScale = w.textureScale; this.cylinder = w.cylinder; - this.cylinderMapRadius = w.cylinderMapRadius; this.tintColor = w.tintColor; this.borderColor = w.borderColor; this.name = w.name; + this.clearColor = w.clearColor; + this.cylinderMapRadius = w.cylinderMapRadius; } public int textureWidth() {