Search Issue Tracker

Won't Fix

Votes

96

Found in

2019.3.15f1

2019.4

2020.2

Issue ID

1262272

Regression

No

[iOS][UaaL] UnityFramework with 3rd party plugins triggers watchdog termination after launch

iOS

-

Reproduction steps:
1. Open project in "FirebaseTestMintegral.zip"
2. Build the project for iOS
3. Open .xcworkspace generated in the build folder
4. Deploy the Application to an iOS device
5. Shut the Application down (using Xcode or the device itself)
6. Open the Application from the device (without using Xcode)

Expected result: the Application will launch successfully
Actual result: the Application starts launching and shuts down in around 10-20 secs

Reproducible with: 2019.3.15f1, 2019.4.5f1, 2020.1.0f1, 2020.2.0a18
Could not test with 2018.4, 2019.3.0a1 because I was unable to resolve package/namespace errors

Devices tested:
Reproducible with:
VLNQA00310 iPad Pro 12.9 1st gen (iOS 13.4.1)
Not reproducible with:
VLNQA00204 iPhone 5C (iOS 10.3.3)
iPhone 7 iOS 12.3.
iPad 7th gen iOS 13.2.2
VLNQA00015, Samsung Galaxy Note8 (SM-N950W), Android 8.0.0, CPU: Snapdragon 835 MSM8998, GPU: Adreno (TM) 540

---------------
Possible workaround:
By default UnityFramework.framework is embedded in Unity-iPhone target and it is not linked with it some plugins are sensitive to this initialization path. UnityFramework is loaded later at runtime.
* Go to Unity-iPhone / Build Phases / Link Binary with Libraries build section and add UnityFramework.framework.
UnityFramework will be loaded at the same time as the main executable.

  1. Response avatar

    Resolution Note (2021.1.X):

    At some point, UnityFramework runtime together with plugins is loaded at run time by dyld/NSBundle.load. Please keep that in mind while developing a plugin.
    Any API-rich initialization on +(load), attribute(constructor), and global object construction code paths should be moved to a later phase preferably after UnityFramework is loaded, and even better when Unity is initialized.
    Simple plain data initialization is safe, but API-rich calls that deal with other os parts especially networking and user interface APIs might lead to deadlock leading to watchdog termination.
    By doing delayed/lazy initialization you can get better control over initialization order, you can reduce the application load time, and most importantly you avoid possible deadlock.

    ---------------
    Possible workaround:
    By default UnityFramework.framework is embedded in Unity-iPhone target and it is not linked with it, UnityFramework is loaded later at runtime and some plugins are sensitive to this initialization path.

    * Go to Unity-iPhone / Build Phases / Link Binary with Libraries build section and add UnityFramework.framework.
    UnityFramework will be loaded at the same time as the main executable.

Comments (32)

  1. 740bfc6d4ba61f244e67bdcfbb56a378?d=mm

    AcuityCraig

    Nov 19, 2020 18:31

    Anyone have any suggestions on how to implement this workaround within Unity Cloud Build?

  2. A585e3e6dd08e42e4a46bd3eca057a0c?d=mm

    sarebots2

    Nov 15, 2020 19:02

    @Moriarty83 You have to move BuildProcessors script into the Editor folder

  3. 0568219f93007a82c35f9a16f394e634?d=mm

    moriarty83

    Nov 13, 2020 20:50

    A huge thanks to the people figuring out this workaround. Waldgeist, I'm getting some namespace build errors when I try to implement the workaround:

    Assets/Scripts/Classes/iOS_14_2_Workaround.cs(10,36): error CS0246: The type or namespace name 'IPostprocessBuildWithReport' could not be found (are you missing a using directive or an assembly reference?)

    Same error for:
    using UnityEditor.Build;
    using UnityEditor.Build.Reporting;
    using UnityEditor.iOS.Xcode;

    Are you able to give me a pointer or two on how to successfully implement? Huge thank you to all!

  4. B5c7fca07bf8702b45cc18c7e69fecb8?d=mm

    Ja3gger

    Nov 12, 2020 19:21

    About the info.plist file is the same for 2019.4.5 app and 2019.4.14 app, so the problem don't come from this.

  5. B5c7fca07bf8702b45cc18c7e69fecb8?d=mm

    Ja3gger

    Nov 12, 2020 19:19

    I'm working in google cardboard project and unity videoplayer. Using unity 2019.4.5 the videoplayer crashes randomly, and to solve this we updated to 2019.4.14. The videoplayer crashes it's solved but when we launch the app to the store, they rejected the validation and they asked to us to modify the info.plist file because can not install in Iphone XR/ Ipad 3r Gen.
    They finally accept the app but when we download the app from store, in the splash screen show a black screen and the app don't continue.
    In the testflight and xcode works, the problem is in the store.
    Our problem it can be caused with this?

  6. 8e4ddb4b65fb55ddc8b82b7b9e1b9de8?d=mm

    alan25799

    Nov 12, 2020 04:20

    Reproduced on Unity 2019.4.9f1 / Xcode 12.1 / iOS 13.7
    The solution works!

  7. 8e4ddb4b65fb55ddc8b82b7b9e1b9de8?d=mm

    alan25799

    Nov 12, 2020 04:13

    It works. You save my day. Thanks!

  8. 337287d8a04e97e8c9e197ddc4fb290f?d=mm

    waldgeist

    Nov 09, 2020 22:25

    The workaround works, thanks Binouze! Fun fact: I mentioned that this is a hotfix for iOS 14.2 when re-submitting the app to the app store. It took less than 5 minutes (!) until they took it under review. I guess you are right, MigrantP!

    For all of you who struggle with the script because they are not so familiar with the Unity Build API, here's a version that contains all required Using directives and also the missing callback order:

    ```cs

    using System.IO;
    using UnityEngine;
    using UnityEditor;
    using UnityEditor.Build;
    using UnityEditor.Build.Reporting;
    using UnityEditor.iOS.Xcode;

    public class iOS_14_2_Workaround : IPostprocessBuildWithReport
    {

    public int callbackOrder => 1;

    public void OnPostprocessBuild( BuildReport report ) {
    #if UNITY_IOS
    if( report.summary.platform == BuildTarget.iOS ) {
    Debug.Log("Applying iOS 14.2 workaround. Remove me once Unity has patched this.");
    var pathToBuiltProject = report.summary.outputPath;
    var projectPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
    var project = new PBXProject();
    project.ReadFromString(File.ReadAllText(projectPath));
    project.AddFrameworkToProject( project.GetUnityMainTargetGuid(), "UnityFramework.framework", false );
    project.WriteToFile( projectPath );
    }
    #endif
    }

    }

    ```

  9. 337287d8a04e97e8c9e197ddc4fb290f?d=mm

    waldgeist

    Nov 09, 2020 20:35

    We got our app update rejected by Apple today because of this! We haven't even been aware of this problem, since we didn't upgrade our devices to iOS 14.2 yet. With 14.1, they still worked fine. This is REALLY annoying. I am not even aware of any "3rd party plugins" involved here.

  10. Bd5f99cd93b337412a81858ef4eeb79f?d=mm

    MigrantP

    Nov 09, 2020 04:15

    Thanks Binouze, that workaround has helped us get fixes out rapidly for our games that are built on Unity 2019.4.0.

    I'm not sure if it's random, or if it's because our update notes mention fixing a crash due to iOS 14.2, but our first game's update was reviewed and approved in a matter of hours!

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.