[1.4] Unusual Call stack "get_unityPreferencesFolder can only be called from main thread"

Reality.Stop() 3 years ago updated by Lazlo Bonin (Lead Developer) 3 years ago 11

Happened after I made modifications to C# code and added a flow machine

2018.2, Bolt 1,4, .Net 4.6

Causes this in the inspector:

There is nothing in the variables, or in the flow machine, they are entirely blank.

Removing the [Inspectable] attribute from the following code resolved the error.

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Satisfaction mark by Reality.Stop() 3 years ago
Pending Review

At first look, this seems like a Unity bug, where they somehow inject an main-thread-only API call inside a .NET / Mono runtime method... (which is a really, really bad idea if you ask me!). Does that prevent you from using Inspectable attributes everywhere?

Yes.  I haven't exhaustively checked, but it would appear that as soon as there is an [Inspectable] attribute anywhere in my codebase, it breaks.  I'll try to get some more details for you tomorrow.

Working on Fix

Will investigate tomorrow.

Thanks!  I have to be honest though, I tried to trigger this again, succeeded, and started playing with it.   Then it disappeared and I haven't gotten it to come back.  I THOUGHT I had figured it out, that it was related to the error that happens if I have an Inspectable property with a getter but no setter, but that wasn't it either.  :-(

I don't have a smoking gun for you, and with the Jam I haven't been working in the C# side of things.

Cannot Reproduce

I tried reproducing this but I can't:

  • Unity 2018.2.3f1
  • Bolt v.1.4.0f4
  • .NET 4.x

Here is my script:

using Ludiq;
using UnityEngine;
public class Team
    public GameObject BotPrefab;

Without the top-level [Inspectable] which isn't in your code, Bolt complains that no inspector can be found, but does not give throw error you posted.

As expected, I am able to create and inspect the type:

Thanks for trying!  Yeah, as mentioned, I can't get it to happen again either.  I'm not sure what broke it or fixed it (it persisted through a restart of Unity).

If it ever happens again, I'll see if I can't get a repro project for you!

Hit it again, no idea the cause:

Working on Fix

This seems like an issue with Unity's [FilePathAttribute]. Here:


It uses a non-thread safe API in the constructor, which shouldn't be legal.

Do you notice it happening when using a class from Unity in particular?

I will report the issue to them, but without reproduction steps, they tend to ignore my reports, even if they have clear line numbers.

Fixed in Next Version

I reported the issue and added further exception checking to the attribute cache in the mean time. This should result in a warning for future versions until Unity fixes their underlying bug. In this case it should be harmless and it will allow the rest of the code to keep working normally.

Here is the bug report link: https://fogbugz.unity3d.com/default.asp?1077857_c01rikini4o59vhg

Thanks!  I have no problem with harmless warnings.  That's much preferable to the Bolt-ending error.

I'll keep an eye out, since it seems to be particular to my setup here (I haven't heard anyone else encounter it)