Skip to content
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

Library is not able to load pending crash report and throwing an error Domain=PLCrashReporterErrorDomain Code=2 #305

Closed
1 of 2 tasks
dhawal-aeq opened this issue Apr 9, 2024 · 6 comments
Labels

Comments

@dhawal-aeq
Copy link

Description

We have integrated CrashReporter into our project and trying to capture crash reports but somehow it's not able to load report and throwing below error:
failed to load and parse with error: Error Domain=PLCrashReporterErrorDomain Code=2 "An unknown error occured decoding the crash report" UserInfo={NSLocalizedDescription=An unknown error occured decoding the crash report}

However, when we use the same configuration with sample app then it works fine, seems like something in the project which is causing an issue but we are not able to figure out.

Repro Steps

Here is the code that we have added in the didFinishLaunching to verify the crashes:

      let config = PLCrashReporterConfig(signalHandlerType: .mach, symbolicationStrategy: .all)

      guard let crashReporter = PLCrashReporter(configuration: config) else {
        print("Could not create an instance of PLCrashReporter")
        return true
      }

    // Enable the Crash Reporter.
      do {
        try crashReporter.enableAndReturnError()
      } catch let error {
        print("Warning: Could not enable crash reporter: \(error)")
      }

    DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
        fatalError("Crashed")
    }
    
    // Try loading the crash report.
      if crashReporter.hasPendingCrashReport() {
        do {
          let data = try crashReporter.loadPendingCrashReportDataAndReturnError()
            print("CrashReporter: Loaded data")
          // Retrieving crash reporter data.
          let report = try PLCrashReport(data: data)
            print("CrashReporter: Loaded report")
          // We could send the report from here, but we'll just print out some debugging info instead.
          if let text = PLCrashReportTextFormatter.stringValue(for: report, with: PLCrashReportTextFormatiOS) {
            print(text)
          } else {
            print("CrashReporter: can't convert report to text")
          }
        } catch let error {
          print("CrashReporter: failed to load and parse with error: \(error)")
        }
      } else {
          print("CrashReporter: No pending reports")
      }

Details

  1. Which SDK version are you using? Latest
  2. Which OS version did you experience the issue on? 17.2
  3. Which CocoaPods/Carthage/Xcode version are you using? CocoaPods
  4. What device version did you see this error on? Were you using an emulator or a physical device? Simulator
  5. What language are you using?
    • Objective C
    • Swift
  6. What third party libraries are you using?
pod 'Firebase/Analytics'
pod 'Firebase/Messaging'
pod 'Firebase/Crashlytics'
pod 'Introspect'
pod 'XMLCoder', '~> 0.14.0'
pod 'Factory', '2.1.5'
pod 'DatadogCore'
pod 'DatadogRUM'
pod 'DatadogSessionReplay'
pod 'DatadogCrashReporting'
pod` 'SwiftLint'

and some private third party libraries from Backbase

For your information, we have also tried to disable Firebase in case it is creating an issue but same error.

Please find attachments for crashReport data that we gathered from APP's cache folder, we believe this is the place where CrashReport is capturing the crashes and also .ips file that the system generated for the crash.
[com.plausiblelabs.crashreporter.data.zip]
Ent dev2-2024-04-09-110918.ips.zip
(https://github.com/microsoft/plcrashreporter/files/14922709/com.plausiblelabs.crashreporter.data.zip)

@grigorye
Copy link
Contributor

I do believe that it may be the same issue that we encountered on our side. Basically, in our case it was narrowed-down to the fact that the crash report generated exceeded the limit hardcoded in the library. You can check that by trying to look up for the saved crash report in the app container and checking its size. If it's 262144 (that's 256KB), then it's probably the same issue.

The workaround is implemented in #308 (increasing the limit from 256KB to 1MB).

After lifting the limit, in our case the real size of the crash report generated was 289858 bytes.

@DmitriyKirakosyan
Copy link
Contributor

Hi @dhawal-aeq, could you please check if you are experiencing the same issue that @grigorye has described?

@grigorye, thanks for your contribution! How frequently does such a big crash occur? Is it a constant issue or does it occur only under specific circumstances? You've increased the limit to 1MB. Is this amount necessary? Perhaps 512KB might suffice. The limit is intended to prevent excessive disk usage, see this link.

Have you tested your changes by integrating the patched version into your app? How do you integrate PLCRashReporter? SPM, Pods?

@grigorye
Copy link
Contributor

@grigorye, thanks for your contribution! How frequently does such a big crash occur? Is it a constant issue or does it occur only under specific circumstances? You've increased the limit to 1MB. Is this amount necessary? Perhaps 512KB might suffice. The limit is intended to prevent excessive disk usage, see this link.

Well, it's 100% reproducible in our case, with nothing but a typical setup for our UI implementation.

Have you tested your changes by integrating the patched version into your app?

Yes.

How do you integrate PLCRashReporter? SPM, Pods?

We're in fact integrating it implicitly as part of DatadogCrashReporting, via CocoaPods. To integrate the patched version (until the official version is released here), we (temporarily) employed a fork (preview of the changes) (beware that it branches of 1.11.1 (the last officially released version)).

OTOH, as far as I can see, the fix has been already merged and folks are preparing 1.11.2, so I'm looking forward to the new official version that addresses the issue.

@grigorye
Copy link
Contributor

grigorye commented Apr 17, 2024

Is this amount necessary? Perhaps 512KB might suffice. The limit is intended to prevent excessive disk usage, see this link.

Tbh, I'm not sure I understand the rationale behind this limit to the end, but at quick glance it looks like addressing "internal safety" issue vs something specific. From that perspective the difference between 1M or 512K sounds irrelevant to me - if it lands in that kind of situation, whether it stops at 1M or 512K does not matter?

Also, I followed the rationale that they had in the documentation with the current limit: 256K was used when the largest observed crash report was around 97K, that is 2.5x larger than the observation. Here we have the case with 290K crash report that we observed in real life, so 512K would be less than 2x, hence my proposal was to use 1M, just to be on the safe side of the things.

@dhawal-aeq
Copy link
Author

@DmitriyKirakosyan Seems like this is the same issue that @grigorye is having, I can see my crash report is 262KB and that explains why CrashReporter is not able to load the crash report. I agree with @gimsvc we should have limit set to 2.5x larger than observation as there might be lot of cases where we could end up in big report.

Do you have any timeline for the release of 1.11.2

@DmitriyKirakosyan
Copy link
Contributor

The fix was released, so I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants