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

No automatic Crash upload #2975

Closed
rakuyoMo opened this issue Apr 28, 2023 · 17 comments · Fixed by #3005
Closed

No automatic Crash upload #2975

rakuyoMo opened this issue Apr 28, 2023 · 17 comments · Fixed by #3005

Comments

@rakuyoMo
Copy link

rakuyoMo commented Apr 28, 2023

Platform

iOS

Installed

CocoaPods

Version

8.5.0

Steps to Reproduce

  1. First, I registered the SentrySDK in the first line of the application(_:, didFinishLaunchingWithOptions:) method:
public func start(environment: String? = nil, release: String? = nil) {
    guard !SentrySDK.isEnabled else { return }

    SentrySDK.start {
        $0.dsn = Config.sentry.dsn
        $0.debug = !Bool.isRelease
        $0.attachScreenshot = true
        $0.attachViewHierarchy = true
        $0.releaseName = release ?? Bundle.sak.shortVersionString()
        $0.dist = Bundle.sak.bundleVersionString()
        
        if let environment = environment {
            $0.environment = environment
        }
     }
}
  1. Running App on iPhone XS Max with 14.7.1.
  2. Click a pre-set button that executes the SentrySDK.crash() method after the button is clicked.

Expected Result

App crashes and receives a crash log in our self-built Sentry panel.

Actual Result

The app crashes, but the web panel is empty.


I've tried calling the capture() method and manually reporting an NSError, and it shows up immediately in the web panel.

I also get WatchdogTermination in the web panel, but the only thing that doesn't show up is the crash.

Are there any configurations that would affect this behavior? Any help would be appreciated, thanks.

@philipphofmann
Copy link
Member

@rakuyoMo, did you detach the debugger? The SDK can't report crashes when the debugger is attached.

@rakuyoMo
Copy link
Author

rakuyoMo commented Apr 28, 2023

did you detach the debugger? The SDK can't report crashes when the debugger is attached.

What is debugger? Where can I find it?

@philipphofmann
Copy link
Member

philipphofmann commented Apr 28, 2023

The debugger of Xcode. Please try to run your app without a debugger attached.

@philipphofmann
Copy link
Member

I just opened a PR to clarify this in the code docs #2976.

@rakuyoMo
Copy link
Author

The debugger of Xcode. Please try to run your app without a debugger attached.

I built a test environment ipa using the Debug certificate, installed it and ran my app off Xcode, clicking the button triggered a crash, but still nothing in the web panel.

After triggering the flashback, I have opened the app again.

If I'm not "out of the debugger" by doing this, can you tell me how to get out of the debugger? I'm sorry, I really don't know what to do to get out of the debugger.

@philipphofmann
Copy link
Member

No worries. Xcode attached the debugger when you run the app by default. You can disable it by clicking on Edit Scheme
Screenshot 2023-04-28 at 10 03 44

And then uncheck the Debug executable
Screenshot 2023-04-28 at 10 04 36

@rakuyoMo
Copy link
Author

No worries. Xcode attached the debugger when you run the app by default. You can disable it by clicking on Edit Scheme

And then uncheck the Debug executable

Thank you for your explanation. But

  1. I turned off this option, connected my phone to my computer, ran my app through Xcode, triggered the crash, reopened the app, opened the web panel, and still didn't see any crash message.

  2. ipa should not contain this option. But I run the app through ipa, trigger a flashback, and still don't see a crash message in the web panel.

I think the problem maybe lies elsewhere?

@philipphofmann
Copy link
Member

Can you turn set debug = true of your options and tell us what the log output is printing? Does captureMessage or captureError work?

@rakuyoMo
Copy link
Author

Can you turn set debug = true of your options and tell us what the log output is printing? Does captureMessage or captureError work?

The logs are very voluminous and I have added a log.zip file. It contains two parts of logs before and after the crash is triggered.

@rakuyoMo
Copy link
Author

rakuyoMo commented Apr 28, 2023

I found this #2851, they could be the same problem, But my code doesn't delete any local files (there are created, could it be related?) . I hope the above log will be of some help.

@philipphofmann
Copy link
Member

philipphofmann commented Apr 28, 2023

Yep #2851 could be related. The crash log shows

ERROR: SentryCrashFileUtils.c (414): _Bool sentrycrashfu_openBufferedWriter(SentryCrashBufferedWriter *, const char *const, char *, int): Could not open crash report file /var/mobile/Containers/Data/Application/3AC1B135-C7E4-42DE-B9B2-D9BD8E9D1749/Library/Caches/SentryCrash/千络助手/Test/Reports/千络助手/Test-report-0000000000800000.json: No such file or directory

It seems like you maybe delete some folders while the app is starting. Does this https://docs.sentry.io/platforms/apple/troubleshooting/#sentryfilemanager-failed-to-write-data-to-path help?

@rakuyoMo
Copy link
Author

Yep #2851 could be related. Does this https://docs.sentry.io/platforms/apple/troubleshooting/#sentryfilemanager-failed-to-write-data-to-path help?

I saw the documentation, but by looking at the logs, I see that during initialization, SentrySDK doesn't seem to create any files in the Library/Caches/SentryCrash/<AppName>/Reports/ directory? I'm not even sure if this directory was created.

If the relevant file is created when initializing SentrySDK, is there any log output? I am not aware of any related logs at the moment.

@rakuyoMo
Copy link
Author

rakuyoMo commented Apr 28, 2023

I run the application through the emulator so I can track the status of the files more easily. I find that the files in the Data folder are present and the Reports folder is always empty.

Maybe I'm missing some configuration?


UPDATE:

Again, to add, after the crash was triggered, the screenshot file existed in the Reports folder, but the critical .json file is still missing.

This JSON file in the Reports folder was created when the SDK was initialized? I don't think I've ever seen this file before.

I tried downgrading the SDK to version 8.3.0 and the problem persists.

@philipphofmann
Copy link
Member

@rakuyoMo, can you try disabling both

$0.attachScreenshot = false
$0.attachViewHierarchy = false

The SDK saves the screenshot and the view hierarchy after creating the crash report. It could be that the screenshot and view hierarchy files somehow interfere crash report. As signal handlers are notoriously difficult to work with and the restrictions placed on us are quite limiting we have to partially bend the rules of what is acceptable for making these features work, but we didn't have any issues so far.

@rakuyoMo
Copy link
Author

rakuyoMo commented May 5, 2023

@philipphofmann I finally found the problem, our app name with the environment identifier on it. For example: "AppName/Test", "AppName/Debug", etc. The backslash character / was the culprit.

The solution is simple, luckily the symbol is irrelevant and we can use - instead.

But I think this should be a bug, right? Because there may be cases where the backslash character in the App name is not replaceable.

Or, expect the SDK to detect such times and throw targeted exceptions or logs. For example, explicitly tell the developer that the error is caused by an illegal character (or some other more accurate name) on the App name.

@philipphofmann
Copy link
Member

philipphofmann commented May 5, 2023

Thanks a lot for the update, @rakuyoMo. To be on the same page, please be more specific about what you mean by app name. Is it the project name in Xcode, or where precisely in Xcode do you specify the app name? And yes, this seems like a bug. Thanks for finding it 😃.

@rakuyoMo
Copy link
Author

rakuyoMo commented May 5, 2023

Thanks a lot for the update, @rakuyoMo. To be on the same page, please be more specific about what you mean by app name. Is it the project name in Xcode, or where precisely in Xcode do you specify the app name? And yes, this seems like a bug. Thanks for finding it 😃.

CFBundleDisplayName and CFBundleName. One of the possible CFBundleName is the key factor.

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

Successfully merging a pull request may close this issue.

2 participants