firebase/quickstart-unity

Crashlytics run script doesn't upload all symbols correctly

L4fter opened this issue · 2 comments

Please fill in the following fields:

Unity editor version: 2019.3. Doesn't reproduce on 2019.2 or lower.
Firebase Unity SDK version: 6.13
Source you installed the SDK (.unitypackage or Unity Package Manager): Tried both.
Firebase plugins in use (Auth, Database, etc.): Crashlytics. Adding or removing Anylytics, Remote Configs had no effect for me.
Additional SDKs you are using (Facebook, AdMob, etc.): Bug can be reproduced with or without sdks.
Platform you are using the Unity editor on (Mac, Windows, or Linux): Win and Mac.
Platform you are targeting (iOS, Android, and/or desktop): iOS
Scripting Runtime (Mono, and/or IL2CPP): il2cpp

Please describe the issue here:

Starting from 2019.3 Unity iOS xcode project contains two targets: Main and UnityFramework. Firebase Crashlyitcs only uploads symbols from Main target. This can be observed in Xcode which only shows "Crashlytics run script" in main target only.

Crashes have missing symbols marked as "optional" and stacktraces in crahlytics are misleading and not marked as (missing) or (none) just displayed with grayish color:
image
Notice the huge offsets numbers on "MetalHeap::AliasResources()" and "UnityAdsEngineSetDidFinishCallback", and lack of lines numbers.

When symbols are uploaded manually, this changes to
image

The similar issue should be happening in Android version, but I haven't been able to test it out.

Please answer the following, if applicable:

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)?
Haven't tried it, but I believe it would be easy to reproduce once you find how to crash the quickstart project.

What's the issue repro rate? (eg 100%, 1/5 etc)

100%

Workaround for iOS

Copy the following hacky script to any Editor folder. It does everything that Crashlyitcs script does on Main target, but applies to UnityFramework target.

using System;
using System.IO;
using System.Linq;
using Firebase.Crashlytics.Editor;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEngine;

public class CrashlyticsHelpher : MonoBehaviour
{
    [PostProcessBuild(101)]
    public static void OnPostprocessBuild(BuildTarget buildTarget, string buildPath)
    {
        if (buildTarget.ToString() == "iOS" || buildTarget.ToString() == "iPhone")
        {
            string projectPath = Path.Combine(buildPath, "Unity-iPhone.xcodeproj/project.pbxproj");
            var storageProviderType = AppDomain.CurrentDomain.GetAssemblies()
                .SelectMany(assembly => assembly.GetTypes())
                .FirstOrDefault(type => type.FullName.Contains("Firebase.Crashlytics.Editor.StorageProvider"));

            var propertyInfo = storageProviderType.GetProperty("ConfigurationStorage");
            IFirebaseConfigurationStorage value = (IFirebaseConfigurationStorage) propertyInfo.GetValue(null);
            PrepareProject(projectPath, value);
        }
    }

    private static void PrepareProject(string projectPath, IFirebaseConfigurationStorage configurationStorage)
    {
        Debug.Log("Adding Crashlytics Run Script 2 to the Xcode project's Build Phases");
        PBXProject pbxproject = new PBXProject();
        pbxproject.ReadFromFile(projectPath);

        // Next line does the trick
        var unityFrameworkGuid = pbxproject.GetUnityFrameworkTargetGuid();
        var runScriptBody = iOSPostBuild.GetRunScriptBody(configurationStorage);
        try
        {
            pbxproject.AddShellScriptBuildPhase(unityFrameworkGuid, "Crashlytics Run Script 2",
                "/bin/sh -x",
                runScriptBody);
        }
        catch (Exception ex)
        {
            Debug.LogWarning("Failed to add Crashlytics Run Script 2: '" + ex.Message +
                             "'. You can manually fix this by adding a Run Script Build Phase to your Xcode project with the following script:\n" +
                             runScriptBody);
        }
        finally
        {
            pbxproject.SetBuildProperty(unityFrameworkGuid, "DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym");
            pbxproject.WriteToFile(projectPath);
        }
    }
}

@L4fter
This sounds like a reasonable request. I'll file a support ticket for this.

Thank you for reporting this and the workaround.

Hey folks, this issue should be fixed in the newest version of the Unity SDK (version 8.2.0). Please upgrade to get the fix!

If you have added custom code to handle this yourself, you may want to remove it just so you don't get a duplicate Run Script Build Phase.

Thanks for reporting!