Skip to content

Commit abe964e

Browse files
Remove assertion/ensure callstack modification logic (#744)
* Remove custom assertion capturing * Add callstack for ensure event on desktop * Update changelog * Fix class name * Fix another class name * Update CHANGELOG.md Co-authored-by: Stefan Jandl <[email protected]> --------- Co-authored-by: Stefan Jandl <[email protected]>
1 parent 0f3758e commit abe964e

13 files changed

+12
-116
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
- Fix incorrect game log attachment on Android ([#743](https://github.com/getsentry/sentry-unreal/pull/743))
2323
- Fix assertion during screenshot capturing in a thread that can't use Slate ([#756](https://github.com/getsentry/sentry-unreal/pull/756))
24+
- Due to improvements to the server-side grouping logic, the SDK no longer relies on client side manipulation of the callstack for assertions and ensures. ([#744](https://github.com/getsentry/sentry-unreal/pull/744))
2425
- Fix invalid native method name for Android `User` class ([#800](https://github.com/getsentry/sentry-unreal/pull/800))
2526
- Fix stack overflow when calling `beforeSend` during object post-loading on mobile ([#782](https://github.com/getsentry/sentry-unreal/pull/782))
2627
- Fix invalid syntax in symbol upload batch script ([#801](https://github.com/getsentry/sentry-unreal/pull/801))

plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.cpp

-20
Original file line numberDiff line numberDiff line change
@@ -165,26 +165,6 @@ TSharedPtr<ISentryId> FAndroidSentrySubsystem::CaptureEventWithScope(TSharedPtr<
165165
return MakeShareable(new SentryIdAndroid(*id));
166166
}
167167

168-
TSharedPtr<ISentryId> FAndroidSentrySubsystem::CaptureException(const FString& type, const FString& message, int32 framesToSkip)
169-
{
170-
return nullptr;
171-
}
172-
173-
TSharedPtr<ISentryId> FAndroidSentrySubsystem::CaptureAssertion(const FString& type, const FString& message)
174-
{
175-
const int32 framesToSkip = GetAssertionFramesToSkip();
176-
177-
// add marker tags specific for Unreal assertions
178-
SetTag(TEXT("sentry_unreal_exception"), TEXT("assert"));
179-
SetTag(TEXT("sentry_unreal_exception_skip_frames"), FString::Printf(TEXT("%d"), framesToSkip));
180-
SetTag(TEXT("sentry_unreal_exception_type"), type);
181-
SetTag(TEXT("sentry_unreal_exception_message"), message);
182-
183-
PLATFORM_BREAK();
184-
185-
return nullptr;
186-
}
187-
188168
TSharedPtr<ISentryId> FAndroidSentrySubsystem::CaptureEnsure(const FString& type, const FString& message)
189169
{
190170
auto id = FSentryJavaObjectWrapper::CallStaticObjectMethod<jobject>(SentryJavaClasses::SentryBridgeJava, "captureException", "(Ljava/lang/String;Ljava/lang/String;)Lio/sentry/protocol/SentryId;",

plugin-dev/Source/Sentry/Private/Android/AndroidSentrySubsystem.h

-6
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ class FAndroidSentrySubsystem : public ISentrySubsystem
1818
virtual TSharedPtr<ISentryId> CaptureMessageWithScope(const FString& message, const FSentryScopeDelegate& onConfigureScope, ESentryLevel level) override;
1919
virtual TSharedPtr<ISentryId> CaptureEvent(TSharedPtr<ISentryEvent> event) override;
2020
virtual TSharedPtr<ISentryId> CaptureEventWithScope(TSharedPtr<ISentryEvent> event, const FSentryScopeDelegate& onConfigureScope) override;
21-
virtual TSharedPtr<ISentryId> CaptureException(const FString& type, const FString& message, int32 framesToSkip) override;
22-
virtual TSharedPtr<ISentryId> CaptureAssertion(const FString& type, const FString& message) override;
2321
virtual TSharedPtr<ISentryId> CaptureEnsure(const FString& type, const FString& message) override;
2422
virtual void CaptureUserFeedback(TSharedPtr<ISentryUserFeedback> userFeedback) override;
2523
virtual void SetUser(TSharedPtr<ISentryUser> user) override;
@@ -36,10 +34,6 @@ class FAndroidSentrySubsystem : public ISentrySubsystem
3634
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContextAndTimestamp(TSharedPtr<ISentryTransactionContext> context, int64 timestamp) override;
3735
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContextAndOptions(TSharedPtr<ISentryTransactionContext> context, const TMap<FString, FString>& options) override;
3836
virtual TSharedPtr<ISentryTransactionContext> ContinueTrace(const FString& sentryTrace, const TArray<FString>& baggageHeaders) override;
39-
40-
protected:
41-
virtual int32 GetAssertionFramesToSkip() const override { return 8; }
42-
virtual int32 GetEnsureFramesToSkip() const override { return -1; }
4337
};
4438

4539
typedef FAndroidSentrySubsystem FPlatformSentrySubsystem;

plugin-dev/Source/Sentry/Private/Android/Java/SentryBridgeJava.java

-19
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public void configure(SentryAndroidOptions options) {
6060
options.setBeforeSend(new SentryOptions.BeforeSendCallback() {
6161
@Override
6262
public SentryEvent execute(SentryEvent event, Hint hint) {
63-
preProcessEvent(event);
6463
return onBeforeSend(beforeSendHandler, event, hint);
6564
}
6665
});
@@ -97,24 +96,6 @@ public Double sample(SamplingContext samplingContext) {
9796
});
9897
}
9998

100-
private static void preProcessEvent(SentryEvent event) {
101-
if (event.getTags().containsKey("sentry_unreal_exception")) {
102-
SentryException exception = event.getUnhandledException();
103-
if (exception != null) {
104-
exception.setType(event.getTag("sentry_unreal_exception_type"));
105-
exception.setValue(event.getTag("sentry_unreal_exception_message"));
106-
SentryStackTrace trace = exception.getStacktrace();
107-
int numFramesToSkip = Integer.parseInt(event.getTag("sentry_unreal_exception_skip_frames"));
108-
List<SentryStackFrame> frames = trace.getFrames();
109-
trace.setFrames(frames.subList(0, frames.size() - numFramesToSkip));
110-
}
111-
event.removeTag("sentry_unreal_exception_type");
112-
event.removeTag("sentry_unreal_exception_message");
113-
event.removeTag("sentry_unreal_exception_skip_frames");
114-
event.removeTag("sentry_unreal_exception");
115-
}
116-
}
117-
11899
public static void addBreadcrumb(final String message, final String category, final String type, final HashMap<String, String> data, final SentryLevel level) {
119100
Breadcrumb breadcrumb = new Breadcrumb();
120101
breadcrumb.setMessage(message);

plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.cpp

+2-22
Original file line numberDiff line numberDiff line change
@@ -187,39 +187,19 @@ TSharedPtr<ISentryId> FAppleSentrySubsystem::CaptureEventWithScope(TSharedPtr<IS
187187
return MakeShareable(new SentryIdApple(id));
188188
}
189189

190-
TSharedPtr<ISentryId> FAppleSentrySubsystem::CaptureException(const FString& type, const FString& message, int32 framesToSkip)
190+
TSharedPtr<ISentryId> FAppleSentrySubsystem::CaptureEnsure(const FString& type, const FString& message)
191191
{
192-
auto StackFrames = FGenericPlatformStackWalk::GetStack(framesToSkip);
193-
194192
SentryException *nativeException = [[SENTRY_APPLE_CLASS(SentryException) alloc] initWithValue:message.GetNSString() type:type.GetNSString()];
195193
NSMutableArray *nativeExceptionArray = [NSMutableArray arrayWithCapacity:1];
196194
[nativeExceptionArray addObject:nativeException];
197195

198196
SentryEvent *exceptionEvent = [[SENTRY_APPLE_CLASS(SentryEvent) alloc] init];
199197
exceptionEvent.exceptions = nativeExceptionArray;
200-
exceptionEvent.stacktrace = SentryConvertersApple::CallstackToNative(StackFrames);
201-
198+
202199
SentryId* id = [SENTRY_APPLE_CLASS(SentrySDK) captureEvent:exceptionEvent];
203200
return MakeShareable(new SentryIdApple(id));
204201
}
205202

206-
TSharedPtr<ISentryId> FAppleSentrySubsystem::CaptureAssertion(const FString& type, const FString& message)
207-
{
208-
int32 framesToSkip = GetAssertionFramesToSkip();
209-
210-
SentryLogUtils::LogStackTrace(*message, ELogVerbosity::Error, framesToSkip);
211-
212-
return CaptureException(type, message, framesToSkip);
213-
}
214-
215-
TSharedPtr<ISentryId> FAppleSentrySubsystem::CaptureEnsure(const FString& type, const FString& message)
216-
{
217-
int32 framesToSkip = GetEnsureFramesToSkip();
218-
219-
SentryLogUtils::LogStackTrace(*message, ELogVerbosity::Error, framesToSkip);
220-
221-
return CaptureException(type, message, framesToSkip);
222-
}
223203

224204
void FAppleSentrySubsystem::CaptureUserFeedback(TSharedPtr<ISentryUserFeedback> userFeedback)
225205
{

plugin-dev/Source/Sentry/Private/Apple/AppleSentrySubsystem.h

-6
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ class FAppleSentrySubsystem : public ISentrySubsystem
1818
virtual TSharedPtr<ISentryId> CaptureMessageWithScope(const FString& message, const FSentryScopeDelegate& onConfigureScope, ESentryLevel level) override;
1919
virtual TSharedPtr<ISentryId> CaptureEvent(TSharedPtr<ISentryEvent> event) override;
2020
virtual TSharedPtr<ISentryId> CaptureEventWithScope(TSharedPtr<ISentryEvent> event, const FSentryScopeDelegate& onConfigureScope) override;
21-
virtual TSharedPtr<ISentryId> CaptureException(const FString& type, const FString& message, int32 framesToSkip) override;
22-
virtual TSharedPtr<ISentryId> CaptureAssertion(const FString& type, const FString& message) override;
2321
virtual TSharedPtr<ISentryId> CaptureEnsure(const FString& type, const FString& message) override;
2422
virtual void CaptureUserFeedback(TSharedPtr<ISentryUserFeedback> userFeedback) override;
2523
virtual void SetUser(TSharedPtr<ISentryUser> user) override;
@@ -36,8 +34,4 @@ class FAppleSentrySubsystem : public ISentrySubsystem
3634
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContextAndTimestamp(TSharedPtr<ISentryTransactionContext> context, int64 timestamp) override;
3735
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContextAndOptions(TSharedPtr<ISentryTransactionContext> context, const TMap<FString, FString>& options) override;
3836
virtual TSharedPtr<ISentryTransactionContext> ContinueTrace(const FString& sentryTrace, const TArray<FString>& baggageHeaders) override;
39-
40-
protected:
41-
virtual int32 GetAssertionFramesToSkip() const override { return -1; }
42-
virtual int32 GetEnsureFramesToSkip() const override { return 6; }
4337
};

plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.cpp

+3-18
Original file line numberDiff line numberDiff line change
@@ -370,34 +370,19 @@ TSharedPtr<ISentryId> FGenericPlatformSentrySubsystem::CaptureEventWithScope(TSh
370370
return Id;
371371
}
372372

373-
TSharedPtr<ISentryId> FGenericPlatformSentrySubsystem::CaptureException(const FString& type, const FString& message, int32 framesToSkip)
373+
TSharedPtr<ISentryId> FGenericPlatformSentrySubsystem::CaptureEnsure(const FString& type, const FString& message)
374374
{
375375
sentry_value_t exceptionEvent = sentry_value_new_event();
376376

377-
auto StackFrames = FGenericPlatformStackWalk::GetStack(framesToSkip);
378-
sentry_value_set_by_key(exceptionEvent, "stacktrace", FGenericPlatformSentryConverters::CallstackToNative(StackFrames));
379-
380377
sentry_value_t nativeException = sentry_value_new_exception(TCHAR_TO_ANSI(*type), TCHAR_TO_ANSI(*message));
381378
sentry_event_add_exception(exceptionEvent, nativeException);
382379

380+
sentry_value_set_stacktrace(exceptionEvent, nullptr, 0);
381+
383382
sentry_uuid_t id = sentry_capture_event(exceptionEvent);
384383
return MakeShareable(new FGenericPlatformSentryId(id));
385384
}
386385

387-
TSharedPtr<ISentryId> FGenericPlatformSentrySubsystem::CaptureAssertion(const FString& type, const FString& message)
388-
{
389-
int32 framesToSkip = GetAssertionFramesToSkip();
390-
391-
SentryLogUtils::LogStackTrace(*message, ELogVerbosity::Error, framesToSkip);
392-
393-
return CaptureException(type, message, GetAssertionFramesToSkip());
394-
}
395-
396-
TSharedPtr<ISentryId> FGenericPlatformSentrySubsystem::CaptureEnsure(const FString& type, const FString& message)
397-
{
398-
return CaptureException(type, message, GetEnsureFramesToSkip());
399-
}
400-
401386
void FGenericPlatformSentrySubsystem::CaptureUserFeedback(TSharedPtr<ISentryUserFeedback> InUserFeedback)
402387
{
403388
TSharedPtr<FGenericPlatformSentryUserFeedback> userFeedback = StaticCastSharedPtr<FGenericPlatformSentryUserFeedback>(InUserFeedback);

plugin-dev/Source/Sentry/Private/GenericPlatform/GenericPlatformSentrySubsystem.h

-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class FGenericPlatformSentrySubsystem : public ISentrySubsystem
2929
virtual TSharedPtr<ISentryId> CaptureMessageWithScope(const FString& message, const FSentryScopeDelegate& onScopeConfigure, ESentryLevel level) override;
3030
virtual TSharedPtr<ISentryId> CaptureEvent(TSharedPtr<ISentryEvent> event) override;
3131
virtual TSharedPtr<ISentryId> CaptureEventWithScope(TSharedPtr<ISentryEvent> event, const FSentryScopeDelegate& onScopeConfigure) override;
32-
virtual TSharedPtr<ISentryId> CaptureException(const FString& type, const FString& message, int32 framesToSkip) override;
33-
virtual TSharedPtr<ISentryId> CaptureAssertion(const FString& type, const FString& message) override;
3432
virtual TSharedPtr<ISentryId> CaptureEnsure(const FString& type, const FString& message) override;
3533
virtual void CaptureUserFeedback(TSharedPtr<ISentryUserFeedback> userFeedback) override;
3634
virtual void SetUser(TSharedPtr<ISentryUser> user) override;
@@ -66,8 +64,6 @@ class FGenericPlatformSentrySubsystem : public ISentrySubsystem
6664
FString GetHandlerPath() const;
6765
FString GetDatabasePath() const;
6866
FString GetScreenshotPath() const;
69-
virtual int32 GetAssertionFramesToSkip() const override { return 5; }
70-
virtual int32 GetEnsureFramesToSkip() const override { return 7; }
7167
virtual FString GetHandlerExecutableName() const { return TEXT("invalid"); }
7268

7369
virtual sentry_value_t OnBeforeSend(sentry_value_t event, void* hint, void* closure);

plugin-dev/Source/Sentry/Private/IOS/IOSSentrySubsystem.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
class FIOSSentrySubsystem : public FAppleSentrySubsystem
66
{
7-
protected:
8-
virtual int32 GetAssertionFramesToSkip() const override { return 5; }
7+
98
};
109

1110
typedef FIOSSentrySubsystem FPlatformSentrySubsystem;

plugin-dev/Source/Sentry/Private/Interface/SentrySubsystemInterface.h

-6
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ class ISentrySubsystem
3737
virtual TSharedPtr<ISentryId> CaptureMessageWithScope(const FString& message, const FSentryScopeDelegate& onConfigureScope, ESentryLevel level) = 0;
3838
virtual TSharedPtr<ISentryId> CaptureEvent(TSharedPtr<ISentryEvent> event) = 0;
3939
virtual TSharedPtr<ISentryId> CaptureEventWithScope(TSharedPtr<ISentryEvent> event, const FSentryScopeDelegate& onConfigureScope) = 0;
40-
virtual TSharedPtr<ISentryId> CaptureException(const FString& type, const FString& message, int32 framesToSkip = 0) = 0;
41-
virtual TSharedPtr<ISentryId> CaptureAssertion(const FString& type, const FString& message) = 0;
4240
virtual TSharedPtr<ISentryId> CaptureEnsure(const FString& type, const FString& message) = 0;
4341
virtual void CaptureUserFeedback(TSharedPtr<ISentryUserFeedback> userFeedback) = 0;
4442
virtual void SetUser(TSharedPtr<ISentryUser> user) = 0;
@@ -55,8 +53,4 @@ class ISentrySubsystem
5553
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContextAndTimestamp(TSharedPtr<ISentryTransactionContext> context, int64 timestamp) = 0;
5654
virtual TSharedPtr<ISentryTransaction> StartTransactionWithContextAndOptions(TSharedPtr<ISentryTransactionContext> context, const TMap<FString, FString>& options) = 0;
5755
virtual TSharedPtr<ISentryTransactionContext> ContinueTrace(const FString& sentryTrace, const TArray<FString>& baggageHeaders) = 0;
58-
59-
protected:
60-
virtual int32 GetAssertionFramesToSkip() const = 0;
61-
virtual int32 GetEnsureFramesToSkip() const = 0;
6256
};

plugin-dev/Source/Sentry/Private/Mac/MacSentrySubsystem.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class FMacSentrySubsystem : public FAppleSentrySubsystem
66
{
77
protected:
8-
virtual int32 GetAssertionFramesToSkip() const override { return 6; }
8+
99
};
1010

1111
typedef FMacSentrySubsystem FPlatformSentrySubsystem;

plugin-dev/Source/Sentry/Private/Microsoft/MicrosoftSentrySubsystem.h

-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ class FMicrosoftSentrySubsystem : public FGenericPlatformSentrySubsystem
2020
virtual void ConfigureDatabasePath(sentry_options_t* Options) override;
2121
virtual void ConfigureLogFileAttachment(sentry_options_t* Options) override;
2222
virtual void ConfigureScreenshotAttachment(sentry_options_t* Options) override;
23-
24-
#if !UE_VERSION_OLDER_THAN(5, 3, 0)
25-
virtual int32 GetEnsureFramesToSkip() const override { return 8; }
26-
#endif // !UE_VERSION_OLDER_THAN(5, 3, 0)
27-
virtual int32 GetAssertionFramesToSkip() const override { return 7; }
2823
};
2924

3025
#endif // USE_SENTRY_NATIVE

plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -693,14 +693,11 @@ void USentrySubsystem::ConfigureOutputDeviceError()
693693
if (OutputDeviceError)
694694
{
695695
OnAssertDelegate = OutputDeviceError->OnAssert.AddLambda([this](const FString& Message)
696-
697696
{
698-
SubsystemNativeImpl->CaptureAssertion(TEXT("Assertion failed"), Message);
699-
700-
// Shut things down before exiting to ensure all the outgoing events are sent to Sentry
701-
Close();
702-
703-
FPlatformMisc::RequestExit( true);
697+
#if PLATFORM_ANDROID
698+
GError->HandleError();
699+
PLATFORM_BREAK();
700+
#endif
704701
});
705702

706703
GError = OutputDeviceError.Get();

0 commit comments

Comments
 (0)