Skip to content

Crash file marker to indicate that a crash has occurred not working #5393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SayaliMalekar opened this issue Apr 16, 2020 · 12 comments
Closed

Comments

@SayaliMalekar
Copy link

SayaliMalekar commented Apr 16, 2020

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 11.3
  • Firebase SDK version: 6.22.0
  • Firebase Component: Crashlytics
  • Component version: 4.0.0-beta.6
  • Installation method: `CocoaPods'

[REQUIRED] Step 2: Describe the problem

Api Crashlytics.crashlytics().didCrashDuringPreviousExecution() is not working.

Steps to reproduce:

Application requirement is to check if app had crashed for previous app launch.

Steps:

  • Launch app.
  • Force crash
  • Launch app again.
  • Observer Crashlytics.crashlytics().didCrashDuringPreviousExecution() returns false.
    In this I was expecting api should return true.

Observation is that FIRCLSCreateCrashedMarkerFile(); is not called

Relevant Code:

// TODO(you): code here to reproduce the problem
@morganchen12
Copy link
Contributor

Potentially related to some of the issues that @samedson was investigating.

@samedson
Copy link
Contributor

Hey thanks for reaching out. Could you share an xcode project or code that crashes that reproduces this?

@google-oss-bot
Copy link

Hey @SayaliMalekar. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@SayaliMalekar
Copy link
Author

SayaliMalekar commented Apr 23, 2020

Application code is same as https://github.com/firebase/quickstart-ios/tree/master/crashlytics.

My build script: "${PODS_ROOT}/FirebaseCrashlytics/run" "find ${DWARF_DSYM_FOLDER_PATH}" -name "*.dSYM" | xargs -I \{\} "$PODS_ROOT/FirebaseCrashlytics/upload-symbols" -gsp "${PROJECT_DIR}/GoogleService-Info.plist" -p ios \{\}

Investigation is that https://github.com/firebase/firebase-ios-sdk/blob/master/Crashlytics/Crashlytics/FIRCrashlytics.m#L133 is always false.
This is as because "previously-crashed" file is never created. Also manually verified the path "crashedMarkerFileFullPath" and found that folder has never created.

I have tested this on Crashlytics 4.0.0, Xcode 11.3

Also crash is not reported immediately on console.

My requirement is to check if app was crash in previous application launch.

Tried following code :

  let crashlytics = Crashlytics.crashlytics()
        FirebaseConfiguration.shared.setLoggerLevel(.max)
        crashlytics.setCrashlyticsCollectionEnabled(false)
        
        crashlytics.checkForUnsentReports { (hasUnsent) in
           
            if hasUnsent {
                crashlytics.sendUnsentReports()
            } else {
                crashlytics.deleteUnsentReports()
            }
        }
        let x =  Crashlytics.crashlytics().didCrashDuringPreviousExecution()
        print("didCrashDuringPreviousExecution = \(x)")

@morganchen12
Copy link
Contributor

@SayaliMalekar what target platform are you running on (simulator, device, iOS version)? Are you able to see any file writing errors in the device's logs?

@SayaliMalekar
Copy link
Author

SayaliMalekar commented May 7, 2020

Hi,
With following steps, able to see correct output:

  • Build application
  • Stop application in Xcode. [Debugger shouldn't be attached].
  • launch application, crash it.
  • Open application , observe Crashlytics.crashlytics().didCrashDuringPreviousExecution() returns true.

This issue can reproduce in following case :

@morganchen12
Copy link
Contributor

Are you seeing duplicate class definition warnings in console when running your app?

@SayaliMalekar
Copy link
Author

SayaliMalekar commented May 7, 2020

Can see following logs:
`

  • objc Class FIRCrashlytics is implemented in both "Framework" and "APP" One of the two will be
    used. Which one is undefined.
  • [Firebase/Crashlytics] Failed to remove file "launchmarker"
  • [Firebase/Crashlytics] Unable to update context metadata
    `

By setting crashlytics.setCrashlyticsCollectionEnabled(false) does not solve the problem.

@paulb777
Copy link
Member

paulb777 commented May 7, 2020

@SayaliMalekar The "undefined" log is indicative of two copies of Crashlytics in the app. It should be restructured so Crashlytics is not linked twice.

@SayaliMalekar
Copy link
Author

By restructuring the code solved my issue. Will there be a work around to decide which Crashlytics to be in use?

@paulb777 @morganchen12 @samedson Thank you for listening and helping to solve the issue.

@morganchen12
Copy link
Contributor

It is not really possible to work around the duplicate class definitions at runtime issue in the SDK code itself, since it results in undefined behavior. Please let us know if you have any more questions and we'll continue to answer them in this thread.

Thanks!

@paulb777
Copy link
Member

In the next major Firebase release, we're planning to remove the static_framework constraint from the pods sources in this repo so that the Podfile can determine whether they get linked statically or dynamically. That should mitigate some of the "duplicate class definition" occurrences. See #2022

@firebase firebase locked and limited conversation to collaborators Jun 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants