firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

Crashes from Apple Watch are not reported by Crashlytics

Open michaello opened this issue 5 years ago • 40 comments

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 12.2 b3
  • Firebase SDK version: 6.34
  • Installation method: CocoaPods
  • Firebase Component: Crashlytics

[REQUIRED] Step 2: Describe the problem

Crashlytics.crashlytics().didCrashDuringPreviousExecution() returns false on Apple Watch after crash. Crashes are not visible in Firebase dashboard.

Steps to reproduce:

Check sample project here: https://github.com/michaello/Crashlytics-Test

Tested both on simulator(6.2) and real Apple Watch(watchOS 7.1)

michaello avatar Oct 27 '20 10:10 michaello

I have the same problem, tried running with/without debugger, simulator, device etc. Are anyone able to get crash reports off the Apple Watch?

grEvenX avatar Nov 11 '20 19:11 grEvenX

I've received crash reports on apple watch simulator and device just fine. It could be that your crashes are mach exceptions or signal crashes which are not able to be recorded. I would create a test crash button and tie it to a selector that doesn't exist.

I have noticed it does take a bit for the crash to be processed and displayed but I believe that is caused by the backend and nothing we can do on the frontend.

In regards to the sample project above I didn't see where you are forcing a crash to test, or where your firebase initialization is.

jostster avatar Nov 11 '20 19:11 jostster

@jostster I'm using the following logic to trigger a crash on the device:

let something = 30 / divisionByZero

Where divisionByZero is a defined variable set to 0. If you use 0 instead or trying to access a selector that doesn't exist directly, the compiler will stop you during build-time.

grEvenX avatar Nov 11 '20 19:11 grEvenX

@jostster sorry, forgot to push the code. Updated the repo, setup is in ExtensionDelegate.

michaello avatar Nov 11 '20 19:11 michaello

@grEvenX you would want to use a string selector so that it passes the build checks like perform(Selector(("crash")))

jostster avatar Nov 11 '20 20:11 jostster

Also can you confirm you are not attaching the debugger during the crash?

jostster avatar Nov 11 '20 20:11 jostster

If you run in simulator what I usually do is run it from Xcode, then press Stop in Xcode. From there I then continue on the simulator without the debugger attached. However can you run it in the simulator with debugger attached and look for [Firebase/Crashlytics][I-CLS000000] Root: <directory> in the xcode console. From there open a Finder window to that path. Stop the debugger so it isn't attached and run the application on just the simulator. Trigger a crash and browse to the path above, followed by v5/reports/active. You should see some report ID's in there.

jostster avatar Nov 11 '20 21:11 jostster

As mentioned: Tested both on simulator(6.2) and real Apple Watch(watchOS 7.1)

Without the debugger.

michaello avatar Nov 12 '20 09:11 michaello

@jostster Debugger detached: yes. My approach is to detach the debugger, then launch the Apple Watch app again through the debugger to check if it has a crash reported. Tried changing to using a selector instead of the "division by zero" logic, but that didn't help (as I would expect, they should both trigger the same kind of crash).

I can inspect the directory you mentioned, and there is a folder in v5/reports/active that seems to reset for each launch. The folder is named like c7cdf51f3b8344bcac1874824169481d (name changes for each launch, and the existing files have been deleted) and has the following files:

  • binary_images.clsrecord
  • internal_incremental_kv.clsrecord
  • metadata.clsrecord
  • sdk.log

I enabled debugging with -FIRDebugEnabled option, and this is my output from an app launch just after it crashed:

Warning: Error creating LLDB target at path '/Users/even/Library/Developer/Xcode/DerivedData/MyBioAge-gmlbyptstghpoeduwyrefofbptas/Build/Products/Debug-watchsimulator/Myworkout GO.app'- using an empty LLDB target which can cause slow memory reads from remote devices.
skipping /Applications/Xcode-beta.app/Contents/Developer/Platforms/WatchOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/watchOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/dyld_sim
2020-11-12 13:43:29.379813+0100 Myworkout GO Extension[79141:1893179] [default] lookupMainFuncAddressInMachHeader:71: Invalid Swift entry point data
2020-11-12 13:43:29.379947+0100 Myworkout GO Extension[79141:1893179] [default] lookupMainFuncAddressInMachHeader:77: Swift entry point addres could not be determined.
2020-11-12 13:43:29.445079+0100 Myworkout GO Extension[79141:1893343] 7.0.0 - [Firebase/Core][I-COR000001] Configuring the default app.
Nov 12 13:43:29  Myworkout GO Extension[79141] <Debug>: 7.0.0 - [Firebase/Core][I-COR000001] Configuring the default app.
2020-11-12 13:43:29.445378+0100 Myworkout GO Extension[79141:1893343] 7.0.0 - [Firebase/Core][I-COR000033] Data Collection flag is not set.
Nov 12 13:43:29  Myworkout GO Extension[79141] <Debug>: 7.0.0 - [Firebase/Core][I-COR000033] Data Collection flag is not set.
2020-11-12 13:43:29.452047+0100 Myworkout GO Extension[79141:1893179] [Firebase/Crashlytics] Version 7.0.0
"Myworkout/Crashlytics crashed in previous execution: No"
2020-11-12 13:46:12.288932+0100 Myworkout GO Extension[79141:1893345] 7.0.0 - [Firebase/Crashlytics][I-CLS000000] [Crashlytics] Running on watchOS Simulator, 7.1.0 (19H15)
Nov 12 13:46:12  Myworkout GO Extension[79141] <Debug>: 7.0.0 - [Firebase/Crashlytics][I-CLS000000] [Crashlytics] Running on watchOS Simulator, 7.1.0 (19H15)
2020-11-12 13:46:12.289281+0100 Myworkout GO Extension[79141:1893345] 7.0.0 - [Firebase/Crashlytics][I-CLS000000] [Crashlytics:Crash:Client] Background session uploading not supported, asynchronous uploading will be used
Nov 12 13:46:12  Myworkout GO Extension[79141] <Debug>: 7.0.0 - [Firebase/Crashlytics][I-CLS000000] [Crashlytics:Crash:Client] Background session uploading not supported, asynchronous uploading will be used
2020-11-12 13:46:12.289608+0100 Myworkout GO Extension[79141:1893345] 7.0.0 - [Firebase/Crashlytics][I-CLS000000] Root: /Users/even/Library/Developer/CoreSimulator/Devices/F1EEF3CA-FBF6-4AD3-815F-FE604B460CDE/data/Containers/Data/Application/E113A979-A2D6-4D07-9034-EDA55BA19EBC/Library/Caches/com.crashlytics.data/no.myWorkout.MyBioAge.watchkitapp.watchkitextension
Nov 12 13:46:12  Myworkout GO Extension[79141] <Debug>: 7.0.0 - [Firebase/Crashlytics][I-CLS000000] Root: /Users/even/Library/Developer/CoreSimulator/Devices/F1EEF3CA-FBF6-4AD3-815F-FE604B460CDE/data/Containers/Data/Application/E113A979-A2D6-4D07-9034-EDA55BA19EBC/Library/Caches/com.crashlytics.data/no.myWorkout.MyBioAge.watchkitapp.watchkitextension
2020-11-12 13:46:16.478258+0100 Myworkout GO Extension[79141:1893345] 7.0.0 - [Firebase/Crashlytics][I-CLS000000] Automatic data collection is enabled.
Nov 12 13:46:16  Myworkout GO Extension[79141] <Debug>: 7.0.0 - [Firebase/Crashlytics][I-CLS000000] Automatic data collection is enabled.
2020-11-12 13:46:16.478630+0100 Myworkout GO Extension[79141:1893345] 7.0.0 - [Firebase/Crashlytics][I-CLS000000] Unsent reports will be uploaded at startup
Nov 12 13:46:16  Myworkout GO Extension[79141] <Debug>: 7.0.0 - [Firebase/Crashlytics][I-CLS000000] Unsent reports will be uploaded at startup
2020-11-12 13:46:16.478964+0100 Myworkout GO Extension[79141:1893345] 7.0.0 - [Firebase/Installations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
Nov 12 13:46:16  Myworkout GO Extension[79141] <Debug>: 7.0.0 - [Firebase/Installations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
2020-11-12 13:46:19.762281+0100 Myworkout GO Extension[79141:1893179] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600002f30500> F8BB1C28-BAE8-11D6-9C31-00039315CD46
"Myworkout/Crashlytics has unsent reports: No"
2020-11-12 13:46:35.878615+0100 Myworkout GO Extension[79141:1893344] 7.0.0 - [Firebase/Installations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
Nov 12 13:46:35  Myworkout GO Extension[79141] <Debug>: 7.0.0 - [Firebase/Installations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
2020-11-12 13:46:36.079450+0100 Myworkout GO Extension[79141:1897061] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed

grEvenX avatar Nov 12 '20 12:11 grEvenX

The Invalid swift entry point is concerning. I do see there is an ongoing issue on Apple Forums with it, but this could be the cause? https://developer.apple.com/forums/thread/661727.

I just tested again with our implementation which uses SPM to install and received a crash report in the firebase console.

jostster avatar Nov 12 '20 16:11 jostster

@jostster I'm using Crashlytics from CocoaPods, I can try to see if it works any better by using SPM. Which version are you currently at just to check that?

When it comes to the Invalid swift entry point, I get that error even when just creating a new Apple Watch project from scratch through Xcode, so I would be surprised if this causes any issue with Crashlytics.

Edit: Tried now with Firebase 7.1 using SPM and it behaves exactly like when using Firebase 7.0 through CocoaPods. No change after that attempt.

grEvenX avatar Nov 12 '20 18:11 grEvenX

@michaello it's great that you have provided a sample code. It would be more helpful if you provided some guidelines on how to test the crash using it and push a commit that would actually be possible to build. It seems that it's using CocoaPods, but there's no Podfile etc. included so the project doesn't build (at least if you check out a clean copy).

grEvenX avatar Nov 12 '20 20:11 grEvenX

Any progress on this @grEvenX @michaello ?

jostster avatar Nov 19 '20 17:11 jostster

@grEvenX sorry, added Podfile to my project. Just run the watch app and tap the button.

michaello avatar Nov 19 '20 17:11 michaello

Ok, I downloaded your project and played around with it. I had trouble getting things to install but that doesn't seem to be the issue. It looks like the issue is crashes happening in SwiftUI are not being recognized. I replaced your SwiftUI with an interface controller and forced a crash that way, and the cls report was generated.

jostster avatar Nov 19 '20 18:11 jostster

@michaello Thanks @jostster No progress from my side, I don't know what to try next. Could you push the changes to a fork or something so I can see if I can get it working here on my setup?

grEvenX avatar Nov 19 '20 18:11 grEvenX

UPDATE: After debugging this it looks like SwiftUI crashes are mach-exception crashes so they will not be detected on watchOS :-(

jostster avatar Nov 19 '20 18:11 jostster

@jostster Sorry for asking, but would you be able to provide a code change that leads to a crash in the example project just so we can test and verify that it indeed works for non mach-exception crashes?

grEvenX avatar Nov 21 '20 13:11 grEvenX

Crashlytics-Test-main.zip Here is the updates I did. Basically I just used a Storyboard instead of SwiftUI. I didn't test using swiftUI that referenced swift code to see if those crashes were tracked, but I probably should since we are starting to implement more SwiftUI in my current project.

jostster avatar Nov 23 '20 17:11 jostster

I'm facing the same problems while trying to integrated Crashlytics with SPM on a watch project. No reports seems too be sent to the firebase console.

lukacs-m avatar Dec 03 '20 13:12 lukacs-m

@lukacs-m How are you generating a crash? Is it within SwiftUI?

jostster avatar Dec 03 '20 16:12 jostster

@jostster Hello, I am also facing issues with the SPM implementation to get the watch crashes in the dashboard.

  • Firebase Version: 7.5.1
  • Xcode: 12.4
  • Installation method: SPM
  • Apple Watch series 5, watch os 7.3

I am not using any SwiftUI component in the app.

  • A new app has been created in firebase for the watch. The GoogleService-Info.plist has the WatchKit extension bundle identifier: com.company.app.staging.watchkitapp.watchkitextension.
  • FirebaseApp.configure() is called in the applicationDidFinishLaunching of the watch app extension.
  • This script is called in the Wachtkit extension build scripts ${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run

I am also testing this in the applicationDidFinishLaunching, but it always comes back as false: Crashlytics.crashlytics().didCrashDuringPreviousExecution()

The same implementation is working on the iPhone app and didCrashDuringPreviousExecution returns true in iOS when building after a crash (the debugger is not attached during the crash)

I am generating a crash with fatalError()

I looked at your project and everything seems similar - except that you are using cocoa pods.

Also @lukacs-m, did you find a solution?

Thanks for your help!

JonMo avatar Feb 03 '21 16:02 JonMo

@JonMo Are you attached to the debugger?

jostster avatar Feb 03 '21 16:02 jostster

No, I am not when I trigger the crashes

JonMo avatar Feb 03 '21 16:02 JonMo

Are you running this in simulator or device? Could you reference https://github.com/firebase/firebase-ios-sdk/issues/6843#issuecomment-725660258 and let me know the details?

jostster avatar Feb 03 '21 17:02 jostster

I was testing on device but here are the results I am getting through the simulator when I follow your instructions. The debugger is not attached when I trigger the crash. I am seeing reports in the v5/reports/active folder. Each crash creates a new folder with 3 files in it:

  • metadata.clsrecord
  • binary_images.clsrecord
  • internal_incremental_kv.clsrecord

Here are the logs in the console on the next launch:

2021-02-03 23:47:59.295583-0500 TestAppWatch Extension[89935:1954982] [Firebase/Crashlytics] Version 7.5.0
2021-02-03 23:47:59.316288-0500 TestAppWatch Extension[89935:1955189] 7.5.0 - [Firebase/Core][I-COR000001] Configuring the default app.
Feb  3 23:47:59  TestAppWatch Extension[89935] <Debug>: 7.5.0 - [Firebase/Core][I-COR000001] Configuring the default app.
2021-02-03 23:47:59.316834-0500 TestAppWatch Extension[89935:1955189] 7.5.0 - [Firebase/Crashlytics][I-CLS000000] [Crashlytics] Running on watchOS Simulator, 7.2.0 (20D64)
Feb  3 23:47:59  TestAppWatch Extension[89935] <Debug>: 7.5.0 - [Firebase/Crashlytics][I-CLS000000] [Crashlytics] Running on watchOS Simulator, 7.2.0 (20D64)
2021-02-03 23:47:59.317089-0500 TestAppWatch Extension[89935:1955189] 7.5.0 - [Firebase/Core][I-COR000033] Data Collection flag is not set.
Feb  3 23:47:59  TestAppWatch Extension[89935] <Debug>: 7.5.0 - [Firebase/Core][I-COR000033] Data Collection flag is not set.
2021-02-03 23:47:59.317347-0500 TestAppWatch Extension[89935:1955189] 7.5.0 - [Firebase/Crashlytics][I-CLS000000] Root: /Users/jonathan/Library/Developer/CoreSimulator/Devices/99755E7F-5A8F-4CA0-ACD6-E76CAB779181/data/Containers/Data/Application/08F678CA-485E-4D13-B551-35A2E434E22E/Library/Caches/com.crashlytics.data/com.refineTestApp.theTestApp.staging.watchkitapp.watchkitextension
Feb  3 23:47:59  TestAppWatch Extension[89935] <Debug>: 7.5.0 - [Firebase/Crashlytics][I-CLS000000] Root: /Users/jonathan/Library/Developer/CoreSimulator/Devices/99755E7F-5A8F-4CA0-ACD6-E76CAB779181/data/Containers/Data/Application/08F678CA-485E-4D13-B551-35A2E434E22E/Library/Caches/com.crashlytics.data/com.refineTestApp.theTestApp.staging.watchkitapp.watchkitextension
2021-02-03 23:47:59.317658-0500 TestAppWatch Extension[89935:1955189] 7.5.0 - [Firebase/Crashlytics][I-CLS000000] [Crashlytics:Crash:Reports:Event] Firebase Analytics SDK not detected. Crash-free statistics and breadcrumbs will not be reported
Feb  3 23:47:59  TestAppWatch Extension[89935] <Debug>: 7.5.0 - [Firebase/Crashlytics][I-CLS000000] [Crashlytics:Crash:Reports:Event] Firebase Analytics SDK not detected. Crash-free statistics and breadcrumbs will not be reported
2021-02-03 23:47:59.317984-0500 TestAppWatch Extension[89935:1955189] 7.5.0 - [Firebase/Crashlytics][I-CLS000000] Automatic data collection is enabled.
Feb  3 23:47:59  TestAppWatch Extension[89935] <Debug>: 7.5.0 - [Firebase/Crashlytics][I-CLS000000] Automatic data collection is enabled.
2021-02-03 23:47:59.318267-0500 TestAppWatch Extension[89935:1955189] 7.5.0 - [Firebase/Crashlytics][I-CLS000000] Unsent reports will be uploaded at startup
Feb  3 23:47:59  TestAppWatch Extension[89935] <Debug>: 7.5.0 - [Firebase/Crashlytics][I-CLS000000] Unsent reports will be uploaded at startup
2021-02-03 23:47:59.318515-0500 TestAppWatch Extension[89935:1955189] 7.5.0 - [Firebase/Installations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
Feb  3 23:47:59  TestAppWatch Extension[89935] <Debug>: 7.5.0 - [Firebase/Installations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
DidCrash before: false
Crashlytics Unsent report: false

JonMo avatar Feb 04 '21 04:02 JonMo

Hey @jostster, Does it give you more info about this issue? Thanks for your help

JonMo avatar Feb 08 '21 19:02 JonMo

@jostster Hey, Still stuck on this. Do you have any update? Thanks

JonMo avatar Mar 09 '21 14:03 JonMo

@JonMo I'm not sure what the issue is. It does work in my project. Can you replicate this in a test project and post the project here?

jostster avatar Mar 09 '21 16:03 jostster

@JonMo I'm not sure what the issue is. It does work in my project. Can you replicate this in a test project and post the project here?

Have you been able to get it to detect crashed from SwiftUI? If so, can you provide your test project? It is not working for me either, I thought based on this comment it is a known issue: https://github.com/firebase/firebase-ios-sdk/issues/6843#issuecomment-730557274

carloshwa avatar Mar 10 '21 20:03 carloshwa