Skip to content

Conversation

@tustanivsky
Copy link
Collaborator

@tustanivsky tustanivsky commented Apr 17, 2025

This PR fixes an issue where the game log file from the current session was being attached to a captured crash event before sending it to Sentry instead of attaching the log file from the previous session in which the crash occurred.

It leverages the same approach used for screenshots (#849) by sending the log file in a separate envelope within the onCrashedLastRun handler.

Closes #302

Also, supersedes #732

@tustanivsky tustanivsky marked this pull request as ready for review April 23, 2025 06:11
Comment on lines +43 to +44
isScreenshotAttachmentEnabled = settings->AttachScreenshot;
isGameLogAttachmentEnabled = settings->EnableAutoLogAttachment;
Copy link
Contributor

@bitsandfoxes bitsandfoxes Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these go on the actual options? We're starting to mix settings. with options. here. I'd really prefer the options to be the source of truth of:

  1. What options exist?
  2. What options does the SDK use.

This will also make it easier for users to browse and explore and for us to reason through the SDK's behaviour.

Copy link
Collaborator Author

@tustanivsky tustanivsky Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two flags are cached separately here since they don't necessarily have a direct representation in Cocoa SDK options:

  • isGameLogAttachmentEnabled is Unreal-specific feature
  • isScreenshotAttachmentEnabled can't be just set via options.attachScreenshot as it's an iOS-only thing in sentry-cocoa

Accessing them using FSentryModule::Get().GetSettings() could cause unwanted ensures when called from a non-game thread.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attachScreenshot

This option (with this name) also exists on Android, .NET, Godot, Unity.

Copy link
Collaborator Author

@tustanivsky tustanivsky Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing the concern here. settings properties are passed to the Cocoa SDK’s options within the startWithConfigureOptions block right after we make copies of these flags here (mainly for convenience as we use them in a few other places beyond initialization). Or is this about the naming?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I never realized we call it 'settings', where everywhere else we call options in Sentry .. options.
Is this a UE thing to call stuff settings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a common naming convention for Unreal - ISettingsModule::RegisterSettings

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned that we have no tests for this. Do we have iOS device tests we could verify this change and avoid regressions?

### Fixes

- Fix warnings caused by deprecated Cocoa SDK API usages ([#868](https://github.com/getsentry/sentry-unreal/pull/868))
- Fix invalid log file being attached to crash events on Mac/iOS ([#873](https://github.com/getsentry/sentry-unreal/pull/873))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section on the changelog is already "Fixes" so we could (going forward, from the next release perhaps) avoid starting the message with Fix.

Personally I'd be more interested in which platform the fix relates to. So this is a iOS/Mac, could be:

  • iOS/macOS: Correct log file now attached to crashes. Since crashes are sent on restart, the SDK now looks at the previous run's log files to attach. Leaving the current run's log file untouched

Or something like that.

Comment on lines +43 to +44
isScreenshotAttachmentEnabled = settings->AttachScreenshot;
isGameLogAttachmentEnabled = settings->EnableAutoLogAttachment;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attachScreenshot

This option (with this name) also exists on Android, .NET, Godot, Unity.

@tustanivsky
Copy link
Collaborator Author

I'm concerned that we have no tests for this. Do we have iOS device tests we could verify this change and avoid regressions?

At the moment we don’t have a way to automate testing on mobile so manual testing is our only option for now.

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets ship this to unblock folks, and follow up with device tests if we can

Comment on lines +43 to +44
isScreenshotAttachmentEnabled = settings->AttachScreenshot;
isGameLogAttachmentEnabled = settings->EnableAutoLogAttachment;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I never realized we call it 'settings', where everywhere else we call options in Sentry .. options.
Is this a UE thing to call stuff settings?

@tustanivsky tustanivsky merged commit cbbca84 into main May 1, 2025
30 checks passed
@tustanivsky tustanivsky deleted the fix/log-attachment branch May 1, 2025 06:29
@tustanivsky tustanivsky mentioned this pull request May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crashes captured on Android/iOS have incorrect game log file attached

4 participants