Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Clone WidgetPlacement before sending to VR render thread to prevent c…
Browse files Browse the repository at this point in the history
…oncurrent access.
  • Loading branch information
bluemarvin committed Oct 22, 2019
1 parent eedb732 commit 3ac6ea5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
18 changes: 8 additions & 10 deletions app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1055,15 +1055,9 @@ public int newWidgetHandle() {


public void addWidgets(final Iterable<? extends Widget> 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) {
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 3ac6ea5

Please sign in to comment.