-
-
Notifications
You must be signed in to change notification settings - Fork 49
Add runtime attachments support for Windows/Linux #982
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d7c4cf3
Add attachment desktop-specific class
tustanivsky 0158151
Add attachments support for desktop scope
tustanivsky a18bbdf
Adopt wide char version of the attachment API for Microsoft platforms…
tustanivsky bd08967
Add functions to add/remove attachments in global scope
tustanivsky 781288a
Fix build error
tustanivsky 76477e0
Fix lint errors
tustanivsky 8c609ce
Fix comments
tustanivsky 98cbc93
Update changelog
tustanivsky d7c4506
Update snapshot
tustanivsky a28ebc5
Resert attachment native object reference after it was removed
tustanivsky 591c735
Remove reference
tustanivsky 099d054
Return attachment byte data by ref during adding
tustanivsky 19da3b2
Add function allowing to clear all attachments from the global scope
tustanivsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) 2025 Sentry. All Rights Reserved. | ||
|
||
#include "GenericPlatformSentryAttachment.h" | ||
|
||
#if USE_SENTRY_NATIVE | ||
|
||
FGenericPlatformSentryAttachment::FGenericPlatformSentryAttachment(const TArray<uint8>& data, const FString& filename, const FString& contentType) | ||
: Data(data), Filename(filename), ContentType(contentType), Attachment(nullptr) | ||
{ | ||
} | ||
|
||
FGenericPlatformSentryAttachment::FGenericPlatformSentryAttachment(const FString& path, const FString& filename, const FString& contentType) | ||
: Path(path), Filename(filename), ContentType(contentType), Attachment(nullptr) | ||
{ | ||
} | ||
|
||
FGenericPlatformSentryAttachment::~FGenericPlatformSentryAttachment() | ||
{ | ||
// Put custom destructor logic here if needed | ||
} | ||
|
||
void FGenericPlatformSentryAttachment::SetNativeObject(sentry_attachment_t* attachment) | ||
{ | ||
Attachment = attachment; | ||
} | ||
|
||
sentry_attachment_t* FGenericPlatformSentryAttachment::GetNativeObject() | ||
{ | ||
return Attachment; | ||
} | ||
|
||
TArray<uint8> FGenericPlatformSentryAttachment::GetData() const | ||
{ | ||
return Data; | ||
} | ||
|
||
FString FGenericPlatformSentryAttachment::GetPath() const | ||
{ | ||
return Path; | ||
} | ||
|
||
FString FGenericPlatformSentryAttachment::GetFilename() const | ||
{ | ||
return Filename; | ||
} | ||
|
||
FString FGenericPlatformSentryAttachment::GetContentType() const | ||
{ | ||
return ContentType; | ||
} | ||
|
||
const TArray<uint8>& FGenericPlatformSentryAttachment::GetDataByRef() const | ||
{ | ||
return Data; | ||
} | ||
|
||
#endif |
39 changes: 39 additions & 0 deletions
39
plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentryAttachment.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) 2025 Sentry. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include "Convenience/GenericPlatformSentryInclude.h" | ||
|
||
#include "Interface/SentryAttachmentInterface.h" | ||
|
||
#if USE_SENTRY_NATIVE | ||
|
||
class FGenericPlatformSentryAttachment : public ISentryAttachment | ||
{ | ||
public: | ||
FGenericPlatformSentryAttachment(const TArray<uint8>& data, const FString& filename, const FString& contentType); | ||
FGenericPlatformSentryAttachment(const FString& path, const FString& filename, const FString& contentType); | ||
virtual ~FGenericPlatformSentryAttachment() override; | ||
|
||
void SetNativeObject(sentry_attachment_t* attachment); | ||
sentry_attachment_t* GetNativeObject(); | ||
|
||
virtual TArray<uint8> GetData() const override; | ||
virtual FString GetPath() const override; | ||
virtual FString GetFilename() const override; | ||
virtual FString GetContentType() const override; | ||
|
||
const TArray<uint8>& GetDataByRef() const; | ||
|
||
private: | ||
TArray<uint8> Data; | ||
FString Path; | ||
FString Filename; | ||
FString ContentType; | ||
|
||
sentry_attachment_t* Attachment; | ||
}; | ||
|
||
typedef FGenericPlatformSentryAttachment FPlatformSentryAttachment; | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may become a gotcha moment for users. Maybe this should be raised internally. Is it necessary to have the
removeAttachment
method on a global scope? If so, should it also be included in the underlying SDKs?Same issue in Godot SDK: getsentry/sentry-godot#205 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the discrepancies between Native, Android, and Cocoa in terms of attachment API support it looks like we have the following options:
clearAttachments
method to Native which is already available for Android/Cocoa and expose that for global scope instead of giving user the ability to remove individual attachmentsremoveAttachment
to Android/Cocoa to enable removing individual attachments on mobileaddAttachment
for global scope without the ability to remove itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any problems with adding a new sentry-native method to clear attachments in the global scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good - we can expose only the
AddAttachment
andClearAttachments
methods for the global scope to align with the mobile SDKs.This could also simplify the
FGenericPlatformSentryAttachment
implementation as we’d no longer need to store asentry_attachment_t
reference there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't clear_attachments() also nuke a screenshot attachment? I wonder if it's going to be an unfortunate side-effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem kind of bubbles up. Crashpad doesn't know which attachments are special from sentry-native's perspective. Likewise, sentry-native might not know which attachments are special from a downstream SDKs perspective.
I like the idea of making a distinction between fixed attachments added via options vs. dynamic attachments added via the new API, even though during sentry-native attachment API reviews it was proposed that the old options API could be removed when the missing Crashpad IPC was implemented for macOS. Not sure if it's going to happen anytime soon for macOS using rather complicated Mach ports for IPC, though. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I’ve worked around this by implementing
ClearAttachments
for Win/Linux on the Unreal side of things (see commit).The idea is to store user-defined attachments in an internal vector and remove them one by one using the native
sentry_remove_attachment
wheneverClearAttachments
is called. This way, we avoid accidentally removing any attachments that were added during initialization.@jpnurmi wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds ok. In principle,
sentry_clear_attachments()
works the same way with Crashpad to avoid removing the internal__sentry-event
and__sentry-breadcrumbN
attachments.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, not saying we can't or shouldn't improve this later on! 🙂 But I think this is fine for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I believe we're no longer blocked here and can proceed with the merge. Further improvements related to handling attachments may come in subsequent PRs.