quickstart-unity icon indicating copy to clipboard operation
quickstart-unity copied to clipboard

[Bug] Crashlytics not sending crashes to the console when using *.tgz and UPM

Open jamier-hh opened this issue 3 years ago • 15 comments

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2019.4.26f1
  • Firebase Unity SDK version: 8.1.0
  • Source you installed the SDK: UPM
  • Problematic Firebase Component: Crashlytics
  • Other Firebase Components in use: Core, Analytics
  • Additional SDKs you are using: Facebook, AppLovin MaxSDK
  • Platform you are using the Unity editor on: Mac
  • Platform you are targeting: iOS
  • Scripting Runtime: IL2CPP

[REQUIRED] Crashlytics not sending crashes to the console:

I wasn't sure where to add this issue. It seems to be specific to Unity when using iOS. Whenever including Crashlyitcs via UPM using *.tgz, Crashlytics does not seem to initialize properly and crashes will not get sent to the console. I've tried installing them via our custom registry as well directly in the project and it does not seem to make a difference.

Using the same GoogleService-Info.plist file, I've been able to send reports when using the *.unitypackage version of Crashlytics. I've removed my test *.plist for privacy purposes.

Steps to reproduce:

  1. Open attached project.
  2. Add the following tarball to the Packages folder: com.google.firebase.crashlytics-8.1.0.tgz, com.google.external-dependency-manager-1.2.166.tgz, com.google.firebase.analytics-8.1.0.tgz, com.google.firebase.app-8.1.0.tgz
  3. Add the GoogleService-info.plist to the Assets/* folder.
  4. Build for iOS
  5. Deploy to device. Crashes should happen automatically.
  6. Check the console and see no crashes. Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)? What's the issue repro rate? 100%

What happened? How can we make the problem occur? No errors are reported to the Crashlytics dashboard.

If you have a downloadable sample project that reproduces the bug you're reporting, you will likely receive a faster response on your issue.

TestingPackages.zip

jamier-hh avatar Aug 18 '21 13:08 jamier-hh

Hi @jamier-hh,

In order to identify what's causing this behvaior, could you provide the debug logs for your iOS build after enabling debug logging?

paulinon avatar Aug 19 '21 09:08 paulinon

I've included both since for whatever reason, the repro-projects logs aren't as good. The game logs are edited to remove identifying information but nothing pertinent should have been removed.

jamier-hh avatar Aug 19 '21 13:08 jamier-hh

Thanks for the additional information, @jamier-hh. Could you also verify if you're getting a similar result when using our quickstart?

paulinon avatar Aug 20 '21 09:08 paulinon

Hmm very odd. It seems to be working with the quickstart.

jamier-hh avatar Aug 20 '21 12:08 jamier-hh

I figured it out. I wasn't explicitly referencing any of the actual Crashlytics features so the Crashlytics files weren't being included in the actual build. This is likely related to the fact that link.xml files are not honoured when they are included in packages: https://forum.unity.com/threads/the-current-state-of-link-xml-in-packages.995848/

jamier-hh avatar Aug 20 '21 14:08 jamier-hh

Hi @jamier-hh,

I noticed that your minimal repro has the Crashlytics initialization and testing all in one script. Could you try following along the setup in the documentation and see if this works out for you?

paulinon avatar Aug 20 '21 16:08 paulinon

It doesn't make a difference. Because the Crashlytics assembly is being included as a package, if you do not explicitly reference the assembly (by calling something like "Crashlytics.SetCustomKey"), Unity will strip it out. This is why there is a discrepancy between the minimal repo project and the quickstart project.

For most use cases, this wouldn't matter as most people will likely be explicitly referencing the Crashlytics assembly.

At this point, I'm not really sure this is an issue for the quickstart-unity package (I'm not sure it ever was to be honest haha)

jamier-hh avatar Aug 20 '21 16:08 jamier-hh

Hi @jamier-hh, this sounds like a Unity optimization that removes unused code, do you agree? If so I'm not sure what can be done on our end to fix this problem other than advise users to always reference something in Crashlytics so that it doesn't get dropped.

What do you think?

Thanks!

DellaBitta avatar Sep 01 '21 18:09 DellaBitta

Yeh, essentially. It isn't a problem if they are using the *.unitypackage version of Crashlytics as it will preserve the link.xml file. I would add it as a note for anyone who, like us, wants to use the *.tgz versions.

jamier-hh avatar Sep 01 '21 18:09 jamier-hh

I'm marking this as a bug to create a ticket for us to update our documentation. Thanks for the issue!

DellaBitta avatar Sep 04 '21 13:09 DellaBitta

HI @jamier-hh,

I wasn't able to succesfully reproduce this with the versions that you specified. I followed the published instructions for importing the Unity Package Manager, Firebase Core/App and Firebase Crashlytics SDKs.

I've done all of this in the Crashlytics Quickstart project from this repo. Before building for Android I commented out all Crashlytics code invocations from the source. I then built the app into an .apk via Unity, and dragged and dropped the result into Android Studio where I was able to see the Crashlytics classes in the classes.dex file. There existence in the APK suggests that the classes aren't being stripped out.

I then launched the test app and used it to create uncaught exceptions. Upon restarting the app - which kicks off the Crashltyics upload process - I see the results in the Firebase Crashlytics project console.

Could you follow these steps and post here what your results are? Thank you!

DellaBitta avatar Sep 10 '21 13:09 DellaBitta

The original issue was iOS only, which was probably lost in my assertation of what the issue actually was - sorry about that. If you try the same steps for iOS, and open the project in Xcode. Specifically the Firebase.App.Crashlytics*.cpp files will be missing from the Classes/Native folder.

I've attached a version of the test app that reproduces the issue. You just need to add the dependencies to the package folder:

  • com.google.external-dependency-manager-1.2.166.tgz
  • com.google.firebase.analytics-8.1.0.tgz
  • com.google.firebase.app-8.1.0.tgz
  • com.google.firebase.crashlytics-8.1.0.tgz

jamier-hh avatar Sep 10 '21 14:09 jamier-hh

Ok, thanks for the quickly follow up @jamier-hh. I was able to reproduce this behavior, and I'm sorry for the confusion about the Android target.

DellaBitta avatar Sep 10 '21 16:09 DellaBitta

Interesting, looks like the prevention we put in Crashlytics no longer works.

Ex. this attribute, or the link.xml (This file is not found on firebase-unity-sdk. But probably just an unrelated issue.)

<linker>
<assembly fullname="Firebase.Crashlytics" ignoreIfMissing="1">
    <namespace fullname="Firebase.Crashlytics" preserve="all"/>
</assembly>
</linker>

It is pretty odd that this only affect .tgz but not .unitypackage.

chkuang-g avatar Sep 14 '21 03:09 chkuang-g

Note that link.xml files are not supported inside packages, but you can reference package assemblies from non-package link.xml files.

You can put this link.xml file into your main Assets folder and the .tgz version will work.

hegi25 avatar Oct 29 '21 07:10 hegi25

This will be fixed with the upcoming 10.1.0 Firebase Unity SDK, so closing the issue.

a-maurice avatar Oct 28 '22 01:10 a-maurice