Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

IEnumerator Invoke causes app hard freeze only on apk execution

Discussion in 'Editor & General Support' started by tsibiski, May 16, 2018.

  1. tsibiski


    Jul 11, 2016
    I have an IEnumerator that I use to invoke a specific method. This is part of a test framework. The purpose of this method is to launch a Test coroutine as if it was a helper method. The test runner logic knows to consider anything launched in this way as part of the test calling it - rather than its own test (because the method calling it is in fact its own test).

    While my workaround is to simply put all the test logic into a separate IEnumerator that is called in every place it is needed - and while under any other circumstance, that would clearly be the logical way to do it, and not a workaround - but under this very particular circumstance, I prefer the tests to be capable of being called as a helper method for some other test using the following logic.

    Code (CSharp):
    2. public IEnumerator RunFloatingDependency(string dependencyName) {
    4.      MethodInfo methodNonTest = FloatingDependencies.Find(x => x.Value.Name == dependencyName).Value;
    5.      Type typeNonTest = methodNonTest.ReflectedType;
    6.      MonoBehaviour monoNonTest = gameObject.AddComponent(typeNonTest) as MonoBehaviour;
    7.      _floatingDependenciesMonos.Add(monoNonTest);
    8.       yield return StartCoroutine((IEnumerator)methodNonTest.Invoke(monoNonTest, new object[]{ }));
    10. }
    This works exactly as intended when it is called in the Editor, from an ipa, from WebGL, and has worked fine in apk's in earlier versions of Unity (used it originally in 5.6.3). However, in my current version (2017.2.1p4), the entire apk hard freezes the moment invoke is called here. There are no errors logged. Logcat simply notes that the app has stopped responding. I cannot reproduce the issue with my platform set as android in the editor.
    Last edited: May 16, 2018