compileAllObjects in another thread

Started by Luka, March 14, 2016, 04:28:33 PM

Previous topic - Next topic

Luka

Hi
I have an app in which user can choose which 3d object wants to see. When the user taps on the button, I call loadSerializedObjectArray, set up the textures and everything, and at the end, call compileAllObjects. However, this method is rather slow and sometimes it takes around 3-5 seconds to execute. This blocks OpenGL thread and, of course, the screen freezes. Would it be possible to call compileAllObjects in another thread? This way, the rendering of the rest of the scene would continue normally and the object would be shown when ready. Would it be possible to somehow do the compilation beforehand?  I've tried calling object.compile() in another thead, but still compileAllObjects takes too long.

Thanks for the help,

Luka

EgonOlsen

Maybe you can...I've done nothing to ensure thread safety there, but it doesn't make use of the GL context, so it might work. However, you somehow have to ensure that objects that are processed by compileAllObjects() are not rendered at the same time. Maybe by adding them to another, otherwise unused instance of World just for compilation purposes.

Luka

Thanks, this really did it. I just created fake world to do only compilation.
However, compilation is still rather slow. It takes 4-5 seconds to compile a model with 4500 polygons. Would it be possible to somehow compile the object beforehand? The ideal solution would be to include the compiled object in serialized object file. Other solution could be to cache the compiled instance and serialize it on target device. Maybe use reflection to get ArrayList<CompiledInstance> compiled in Object3D and save it to disk when compiled for the first time?


EgonOlsen

No, that's not possible, I'm afraid. Which device is that? 4-5 secs for 4500 polygons sounds a little too much for a current device!?