Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

Can't even transform a point unless you are on the main thread?

I'm trying to transform and save the spatial mapping meshes as one big mesh. All of my code works but with the caveat that I have to do all of the heavy lifting on the main thread which causes my framerate to drop severely. If I try to touch any of the Unity objects on a separate thread (either via a task or parallel.foreach etc.) I get the following exception. In this case, I am trying to call transform.TransformPoint() in a Parallel loop:

Exception thrown: 'System.ArgumentException' in UnityEngineProxy.dll
Additional information: INTERNAL_CALL_TransformPoint can only be called from the main thread.

I must be doing something wrong. Certainly there is a way to do something as simple as transform points on a separate thread isn't there?

I am using a coroutine now to at least allow my app to do this processing without hanging (and thus crashing) the app. Is coroutine the only solution?

Thanks

Answers

  • Options

    It is true that you cannot access any Unity API when not in the main thread. This becomes especially ridiculous when you only need coordinates or a game object's name. The direction to look is Unity's coroutines which are pseudo-threads and should do well as substitutes in some cases.

    Building the future of holographic navigation. We're hiring.

  • Options

    In the unite 2016 keynote that mentioned that they have "rewritten our transform component so it can be safely accessed from jobs. With the rewrite, we’ll not only be able to jobify the code but also optimize the transform component’s performance when used only on the main thread."

    Part of the reason transform can't be accessed safely from other threads is that changing the transform of a game object needs to propogate that change to children in the hierarchy and there are a series of events that get fired to notify other components that need to be updated, etc. having all of that sequential on the main thread makes it a lot easier to manage and reason about.

    The "C# Job System" is still forthcoming, but it will be another option at some point. Unfortunately I don't know much about it because its all the search results are just turning up job openings at unity or working with unity... not helpful.

Sign In or Register to comment.