Jump to content

Engine don't show node loaded in async thread


photo

Recommended Posts

Hi,

I have problem with showed node loaded in async thread.

Even i call flushMesh is not showed and event it not showed in editor.

Test scene data.rar, push l to load node.

There is warning in log:

14:53:29 QObject::connect: Cannot queue arguments of type 'Unigine::NodePtr'
14:53:29 (Make sure 'Unigine::NodePtr' is registered using qRegisterMetaType().)

14:53:29 QObject::connect: Cannot queue arguments of type 'Unigine::NodePtr'
14:53:29 (Make sure 'Unigine::NodePtr' is registered using qRegisterMetaType().)

 

With loading node in async thread i have more problems.

When i load .\data\Honya\UMA\uma_character.world from main branch in Plastic.

1) Click to "Equip" button and select in combo box "helmets" item "chain_helmet_UMA_male", then editor stop response and created node is not showed.

2) When comment line 1486 MemoryUtils::deleteNode(body); in  .\data\esq\Scripts\Character\Character.h, then editor don't stop response and when click to last node "character_id_1" in world, then the node is showed.

Link to comment

Thanks for the feedback! We will take a look at the first test scene.

In general, Editor2 and some additional logic can work not as you expect (due to different approach - Editor is loaded as separate library, not written in UnigineScript as previous). If you can debug scripts without Editor - it's a preferable way for now.

12 hours ago, honya said:

When i load .\data\Honya\UMA\uma_character.world from main branch in Plastic.

Could you please prepare a separate small test scene for that in isolated environment? It's pretty hard to debug 40+ GB project where only a single line of code is not working as expected. That will surely speed up the debugging procedure.

A separate thread will be also a good choice to not mix up different reproductions and different bugs.

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Hi Silent,

i try to create test scene for other problems, but from my view it looks that have same source of problem, because i do same one thing and get this problems.

So i mentioned it here, because it strange behavior.

Also sometimes on ours scene, when i select added node from async node, the editor instantly stop response, when i select on other node another tab then Node, i can select it and when i select Node tab, the editor stop response.

Or in world view, the editor show node with name like <name_not_set>.

 

As i say, i will try to create simple scene, but sometimes you need heavy scene to product this result.

Link to comment
6 hours ago, silent said:

Could you please prepare a separate small test scene for that in isolated environment? It's pretty hard to debug 40+ GB project where only a single line of code is not working as expected. That will surely speed up the debugging procedure.

Just for your information, this project is made mostly from assets and is meant for world bulding. There is almost no code. There are some small test worlds related to prototyping asset related functionality like character morphing and equipping (Honya directory). So if you open one of these worlds, you debug just this small world with very limited functionality, it has nothing to do with our actual game code.

Edited by demostenes
Link to comment

Hi,

Actually, neither engine.world.loadNode (invoked by node_load) nor engine.editor.addNode functions are thread-safe.
Use engine.async.loadNode and when a node is loaded, add it to the editor inside the update function.

Link to comment

Ok, so it was changed, because in 2.6.1 this work fine.

And one question, must call engine.async.loadNode in main thread or can be called in async thread?

Link to comment

It's absolutely safe to invoke engine.async.loadNode from any thread, although there's no reason to since the method just registers a request and doesn't perform any I/O.

Link to comment

Thanks for yours answers.

The reason is that i proceed loaded nodes to create one mesh from them, create atlas, so i did it in async thread, because this take in second and i prefered most code do in async thread and in main thread only to show result.

Link to comment

Hi,

i change it to load Mesh via engine.async.loadMesh, then create ObjectMeshSkinned from it in asyn thread via Async.

After is loaded, it added to editor via engine.editor.addNode in main thread.

Still not showed until i click to it in World tab in editor.

data.rar

Link to comment

Hi,

Nodes that you create in an async thread are not added to the spatial tree.
Obviously, you can move node creation into the main thread, but I assume you moved it into a separate thread for reason.
So you have to invoke setEnabled(true) in the main thread(!) on this node after its creation.

UPD: not just in the main thread, but in the update() function, when it's safe to push changes to the spatial tree.

Link to comment

Hi ded,

if you check the code, you will see that after i load it in asyn thread, i do this steps on it in update() function:

tran.body.flushMesh();
tran.body.setEnabled(true);
engine.editor.addNode(tran.body);

So i do what you say.

And reason why i do in async thread is that i modify loaded mesh that take around 250-500 ms, so i cannot allow it in main thread to cause lag.

PS: in Unigine 2.6.1 i have not problem with this approach, it's start in version 2.7.

Link to comment

Indeed, there were some changes in the internal node management in the last SDK release.
So node.setEnabled(true) is not enough anymore since the node thinks it's already enabled.
Selecting the object in the editor causes its surfaces to be rendered, but it's still not added to the spatial tree.

There's ugly but working solution to this:

node.setEnabled(false);
node.setEnabled(true);

We'll think how to deal with this.
Maybe there will be a single method, or maybe the engine will automatically add asynchronously loaded nodes to the spatial tree on the next update.

Also, there's a completely different approach to the problem of spikes.
You can load all potentially required resources at the scene initialization and later add them or their clones to the scene.
It worked for some of our projects.
 

Link to comment
×
×
  • Create New...