get_version can only be called from the main thread

So I am using parse.com(a backend database provider, made by facebook) for my unity project. I got stuck with a serious problem. Here is the explanation;

as long as i throw out my Synchronization codes from my game everything works fine but i need it in order to make the player sync their data to the server.

So here is the error im an getting: error · GitHub

And here is my user.cs code: user.cs · GitHub

here is my sync.cs script: sync.cs · GitHub

Do you have a full stack trace of where this error is coming from ?

Most of Unity’s API can only be called from the main (scripting thread). This particular error means you’re trying to access some property (called Version) from a non-scripting thread.

In the code you posted, i cannot see any call to the Version property, but that may occur internally in the Parse library code, or in some other code you haven’t posted.

What platform is this on? Also, do you know what’s the threading model the Parse SDK uses? does it use threading ?

Hello, thanks for the response. I am for sure using other scripts but none of them are running at runtime. I use them for user register and logins and they are out of their functionality when user opens this scene for syncing their data. I said those user register and login scripts are losing their functionality because none of the functions inside the script is being called that moment so i dont think they can be the problem. They are even at a different scene.

This is running on pc platform.

Sadly the error i posted here is the only error i got and it doesnt contain any information to stack trace.

But as i mentioned, when i delete sync parts of the script it just works fine as expected, without syncin the data to server for sure.

Some code is accessing a property from a different thread and this is illegal in Unity. I can have another look at home to try and figure out where exactly.

Thank you so much for your support. Was trying to find an alternative way to do this for a day but no luck sadly.
It is really weird that unity doesnt tells me which line/s are the corrupt scripts but its even more weird that when i delete the sync script i dont get any error, it is more weird because i am succesfully retrieving character informations from parse.com database at LoginUser() void. Only difference between SyncToServer and LoginUser voids are i am trying to save the client sided data to the database after retrieving them, its the only difference between SyncToServer(the void which is possibly giving the error) and LoginUser voids. I just save some client sided data after retreving them.

The reason i retreive data is to change to correct user’s data. I retreive his username and change that username’s data.

So the problem is probably this portion of code: Sync.cs · GitHub

But i cant see anything illegal to Unity in that portion of code. Is it possible to be a bug caused from parse.com API or Unity?

Edit: And what is even even even more weird is, i can succesfully get the object id from database so i dont think the problem is causes from Parse API(still there is a possible chance for it, dont know how parse handles things at behind.).

wait for a while to finish sync with parse. so put this code after sync code.
while(!lsync.IsCompleted)
yieldreturnnull;

1 Like

Sorry but i really dont get that where to put that while statement and also there isnt anything called lsync in the code. Im really confused with this part. If you can explain i would really apprecaite it

Okay this is what i came out with but still getting the same error:

the problem is being caused from SyncToServer() function.

Any help please? Im stuck on this issue longer than a week

Same problem here. Unity 5.1.2f1 and latest Parse SDK. 1.5.3

I have a big code based on Parse and after upgrading from 1.4.1 to latest version now i get this same problem.

Now how to find if it is a Unity or Parse problem? Annoying.

I found this after digging around on facebook(Log into Facebook)!
confirmed fix, too!

“Hi all, I have reproduced the issue and fixed it by updating AndroidManifest.xml and the most recent SDK. I can repro this in 1.5.3 so this will be fixed in 1.5.4 (next native release). Attached is the fixed project. Dropbox

I got the error every time I tried to run SaveAsync() inside of a .ContinueWith()… this indeed fixed it. replace your dll and any manifests you might be using with the one in his zip.
hope it found you in time to help, @JeffScm !

1 Like

Great! Thanks a lot and I will give a try asap. Soon I post the results.

Regards

It worked!

Thanks for the help. I will be testing the new version for this weekend.

Also, do you know any other improvement for the latest version 1.5.4?

Thanks

J

not that I’m aware of. I’m glad it helped!