- Home /
All calls to Resources.Load stopped working on Amazon devices (Unity 5.6.3p3)
Short version: suddenly we cannot use Resources.Load on Amazon devices anymore. Anyone seen strange behavior like this before?
Starting some time back in our project, on Amazon builds only (other Android and iOs work fine), all invocations to Resources.Load result in one of the following two exceptions: "Recursive Serialization is not supported. You can't dereference a PPtr while loading. (Constructors of C# classes may not load objects either. See stacktrace.)" or "ExecutionEngineException: SIGILL". This occurs on mulitiple Kindle Fire devices, 100% of the time.
The commits that coincide with the start of this problem are innocuous (one changed some packing tags, the other added a method that is not used in the game before bug expresses). Reverting the commits did not help the issue. In fact, I had to go back a full week in the repo before the builds from our build machine started failing in order the be able to locally rebuild a working version. There were no changes to the build machine that coincided with the start of the problem.
I've gone over all uses of Resources.Load in the project and ensured that they are not being done either in constructors or recursively. I have also tried delaying calls to Resources.Load by one frame in order to give the engine more time to get itself set up, but to no avail. I have tried deleting the Library and disconnecting from our asset server before rebuilding, but to no available. I have tried re-cloning our project repository and rebuilding, but to no avail. Upgrading the project to Unity 5.6.3p4 did not help. However, downgrading the project to Unity 5.5.3f1 did work and the project ran just fine on Amazon devices with that build.
Answer by jcox_PlayQ · Oct 19, 2017 at 09:37 PM
We were finally able to track this down, so I'll post this here in case anyone else runs into a similar problem. It came down to a prefab that had separate animator components on the base object plus some of its children. This is possibly a regression of https://issuetracker.unity3d.com/issues/animating-gameobject-dot-isactive-of-a-child-with-animator-controller-crashes in Unity 5.6. The bug does not appear to express in Unity 5.5 or Unity 2017.1+.
Random changes to different parts of the codebase could cause the bug to express or not, which implied either a race condition or something in the Unity build process. In addition, once the bug expressed (usually, but not always, with a SIGILL error), any subsequent call to Resources.Load would fail (with the "Recursive serialization..." error).
In our case, we finally found that the bug expression was always tied to the loading of a particular prefab. This prefab (prefab1) was stored in Resources (thus was loaded with Resources.Load()), had an Animator component, and had a script with a reference to another prefab (prefab2, not stored in Resources) that had animator components on the parent object as well as five of its children. In editor, this prefab (prefab1) loaded just fine, although it did produce several warnings that all said "Parameter "" does not exist." (always with the empty quotes). It did not require instantiating the prefab (prefab1); merely calling Resources.Load() on the path to prefab1 threw the error.
We ended up fixing this issue by removing all the child Animator components on the secondary prefab (prefab 2). Thus, prefab1 retained its Animator, and prefab2 retained the animator on the base object, but all the children of prefab2 had their animators removed and the relevant animations moved to layers within prefab2's remaining Animator.
Your answer
![](https://koobas.hobune.stream/wayback/20220612140351im_/https://answers.unity.com/themes/thub/images/avi.jpg)