-
I have a weird problem with ViewRenderable not being rendered in one of my scenes and I wanted to ask if someone has faced the same problem at some point. In my case I made my own SelectionVisualizer that uses a ViewRenderable. At first I suspected that selecting the node doesn't trigger the visualizer or changing the visualizer for the transformation system is not happening for some reason, but that was not the case (the original FootprintSelectionVisualizer works, however it uses a ModelRenderable). At some point I then tried to add a simple node with a ViewRenderable and a normal button and the problem happened there too. The problem resolves by leaving and then returning to the app, by rotating or after a permission request (so with other words: when onResume() is called), although it may take a considerable time before any node shows up again (even nodes with a ModelRenderable), but then everything shows up. I was debugging the app and as it seems the View of the ViewRenderable does not get attached to the window which is why in prepareForDraw() it doesn't get initialized. What makes me curious is that it can take a large amount of time before the nodes are visible again after resuming (can last from few seconds to dozens of seconds), but the plane itself is there immediately. I didn't open an issue because it might be an issue on my side, however I can't wrap my head around why it is happening as it never happened to me before; I also don't understand what makes the affected scene so special that it only happens there. Does someone have any ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
I have to say that it was the first time I opened the ViewRenderable class since there is not so much questions about it. My first guess is that since the SelectionVisualizer is attached and detached from the parent node depending on the current selection, your issues could come from something related to the View reussing forbid like in a normal Activity layout. Can you provide screenshots and make a PR about it? |
Beta Was this translation helpful? Give feedback.
-
I found the culprit and I "fixed" it for myself, but I still don't understand why it is happening in the first place. The problem starts with the fact that the View does not get attached to the window, so in ViewRenderable.prepareForDraw() the code does not pass the following check:
Only if it passes this check the ExternalTexture will be set. So the question is why the view does not get attached. The problem is in ViewAttachmentManager.onResume():
The Runnable simply does not run when called the first time for some reason. I "fixed" it by calling this method in onResume() of my Fragment:
The Runnable gets executed and so each ViewRenderable works as expected. This "fix" shouldn't have any side effects, as it pretty much does nothing after the View is attached. I don't understand what is going on here. Is something else removing the Runnable from the message queue or is it a performance/race condition issue? Never seen something like this before. Well at least I can continue using my good old ViewRenderable. |
Beta Was this translation helpful? Give feedback.
-
Nice job. We (@RGregat and I) have worked on many things including some resume/pause/destroy fixes here: #143 I have made tests with it and, in my environment, the ownerView.post(
() -> {
if (frameLayout.getParent() == null && ownerView.isAttachedToWindow()) {
windowManager.addView(frameLayout, windowLayoutParams);
}
}); Could you checkout the Pull Request and check that this issues is fixed with it ? |
Beta Was this translation helpful? Give feedback.
-
It sadly doesn't fix it. My fix is still required (which is okay for now). It actually introduces a bug where when the ViewRenderable is rendered for the first time it shows a frame of the fireplace video which is used in the VideoNode inside the chimney (in my video I posted earlier you can barely see it). I suppose ViewRenderable also uses ExternalTexture underneath so there seems to be an issue with it. If I remove the VideoNode the first frame shows some gibberish from the surrounding area. |
Beta Was this translation helpful? Give feedback.
I found the culprit and I "fixed" it for myself, but I still don't understand why it is happening in the first place.
The problem starts with the fact that the View does not get attached to the window, so in ViewRenderable.prepareForDraw() the code does not pass the following check:
Only if it passes this check the ExternalTexture will be set. So the question is why the view does not get attached. The problem is in ViewAttachmentManager.onResume():