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

feat: Add screenshot at crash #1920

Merged
merged 33 commits into from Jul 6, 2022
Merged

feat: Add screenshot at crash #1920

merged 33 commits into from Jul 6, 2022

Conversation

brustolin
Copy link
Contributor

@brustolin brustolin commented Jun 27, 2022

📜 Description

Try to add a screenshot during a hard crash

💡 Motivation and Context

Close #1873

💚 How did you test it?

Unit tests

📝 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • Review from the native team if needed
  • No breaking changes

🔮 Next steps

@github-actions
Copy link

github-actions bot commented Jun 27, 2022

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against bf6008e

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

The approach makes sense to me. Good job 💯. We still miss tests.

Sources/SentryCrash/Recording/SentryCrashReportStore.h Outdated Show resolved Hide resolved
Sources/SentryCrash/Recording/SentryCrashC.h Outdated Show resolved Hide resolved
Sources/SentryCrash/Recording/SentryCrashC.c Outdated Show resolved Hide resolved
Sources/SentryCrash/Recording/SentryCrashC.c Outdated Show resolved Hide resolved
Sources/Sentry/SentryCrashReportSink.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryScreenshotIntegration.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryScreenshot.m Show resolved Hide resolved
Sources/Sentry/SentryScreenshot.m Show resolved Hide resolved
Sources/Sentry/SentryScreenshot.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryScreenshotIntegration.m Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Sources/Sentry/SentryScreenshotIntegration.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryScreenshot.m Show resolved Hide resolved
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Nice, another pass.

@brustolin brustolin marked this pull request as ready for review July 1, 2022 09:24
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Almost LGTM, thanks great job 👏 .

Sources/Sentry/SentryScreenshotIntegration.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryScreenshot.m Outdated Show resolved Hide resolved
Sources/SentryCrash/Recording/SentryCrash.m Outdated Show resolved Hide resolved
Sources/SentryCrash/Recording/SentryCrash.m Outdated Show resolved Hide resolved
Sources/SentryCrash/Recording/SentryCrashC.c Outdated Show resolved Hide resolved
Comment on lines +176 to +177
uint32_t lowerBaseID = (uint32_t)(baseID & 0xffffffff);
g_nextUniqueIDLow = lowerBaseID;
Copy link
Member

Choose a reason for hiding this comment

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

m: Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This I don't get it. But without the change it does not work and g_nextUniqueIDLow is always the same.

Copy link
Member

Choose a reason for hiding this comment

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

I just debugged it and it wasn't for me. That would be weird.

Tests/SentryTests/TestClient.swift Show resolved Hide resolved

if (report[SENTRYCRASH_REPORT_SCREENSHOT_ITEM]) {
for (NSString *ssPath in report[SENTRYCRASH_REPORT_SCREENSHOT_ITEM]) {
[scope addAttachment:[[SentryAttachment alloc] initWithPath:ssPath]];
Copy link
Member

Choose a reason for hiding this comment

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

h: When do we delete the screenshots? The attachments will be read when the SDK creates the envelope. How do we know that the screenshots are still stored on disk? Maybe it's better to read the attachments already here, and use SentryAttachment .initWithData. Then we could delete them already here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshots are deleted alongside the report. We had a code for that already.
Lets say we fail to transmit the report, on the next attempt the files won't be there, I rather have the current mechanism that deletes it.

Tests/SentryTests/SentryCrash/SentryCrashTests.m Outdated Show resolved Hide resolved
@philipphofmann
Copy link
Member

@brustolin, I think you should ping someone from the native team or maybe Andrew to get a review on the C code, please.

@brustolin brustolin requested a review from armcknight July 6, 2022 08:38
@brustolin
Copy link
Contributor Author

Hey @Swatinem and @armcknight. I had to wrote a little bit of C here, can you review that? Thanks!!

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Just one h comment to address and a review from native to merge this PR.

Comment on lines +176 to +177
uint32_t lowerBaseID = (uint32_t)(baseID & 0xffffffff);
g_nextUniqueIDLow = lowerBaseID;
Copy link
Member

Choose a reason for hiding this comment

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

I just debugged it and it wasn't for me. That would be weird.

Sources/SentryCrash/Recording/SentryCrash.m Show resolved Hide resolved
@bruno-garcia bruno-garcia merged commit b711c79 into master Jul 6, 2022
@bruno-garcia bruno-garcia deleted the feat/crash-screenshot branch July 6, 2022 19:08
@bruno-garcia
Copy link
Member

Nice! Congtats!

kevinrenskers added a commit that referenced this pull request Jul 7, 2022
* master:
  ref: Remove unused SentryCrashDeadlock (#1941)
  feat: Add screenshot at crash (#1920)
  Add code docs for SentryScope (#1942)
kevinrenskers added a commit that referenced this pull request Jul 8, 2022
* master:
  build: Remove trailing-whitespace (#1953)
  ci: Compile iOS13-Swift sample (#1951)
  release: 7.20.0
  meta: Fix changelog (#1950)
  feat: Add sample rate in the baggage header, remove Userid and Transaction (#1936)
  build: Upate Brewfile.lock and Gemfile.lock (#1947)
  meta: Add Pre Commit Hook (#1946)
  ref: Remove unused SentryCrashDeadlock (#1941)
  feat: Add screenshot at crash (#1920)
  Add code docs for SentryScope (#1942)
philipphofmann added a commit that referenced this pull request Jan 17, 2023
philipphofmann added a commit that referenced this pull request Jan 18, 2023
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.

Screenshots for crashes
5 participants