Adding Another ViewRenderable crashes the app
txcrrh opened this issue · 2 comments
txcrrh commented
So I am using ARCore-Location in an app I am creating. I followed the tutorial project for the most part but am running into a problem where adding another ViewRenderable to the activity crashes the app with no Logcat error.
private ViewRenderable exampleLayoutRenderable;
private ViewRenderable locationLayoutRenderable;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CompletableFuture<ViewRenderable> exampleLayout =
ViewRenderable.builder()
.setView(this, R.layout.ar_info_layout)
.build();
CompletableFuture<ViewRenderable> locationLayout =
ViewRenderable.builder()
.setView(this, R.layout.ar_location_layout)
.build();
CompletableFuture.allOf(
exampleLayout)
.handle(
(notUsed, throwable) -> {
if (throwable != null) {
ARCoreLocationUtils.displayError(this, "Unable to load renderables", throwable);
return null;
}
try {
exampleLayoutRenderable = exampleLayout.get();
locationLayoutRenderable = locationLayout.get();
hasFinishedLoading = true;
} catch (InterruptedException | ExecutionException ex) {
ARCoreLocationUtils.displayError(this, "Unable to load renderables", ex);
}
return null;
});
}
Calling the second .get() method freezes the app and makes it unresponsive. I have no clue what is causing this.
todoranalex commented
You only loaded the first view renderable ( exampleLayout), so when you're trying to get the second one, it will crash because it isn't loaded yet. So try this: CompletableFuture.allOf(exampleLayout,locationLayout).handle(...)
txcrrh commented
Gah of course it was staring me right in the face the whole time. Thank you for the help on that.