Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

- Fix incorrect game log attachment on Android ([#743](https://github.com/getsentry/sentry-unreal/pull/743))
- Fix assertion during screenshot capturing in a thread that can't use Slate ([#756](https://github.com/getsentry/sentry-unreal/pull/756))
- Fix stack overflow when calling `beforeSend` during object post-loading on mobile ([#782](https://github.com/getsentry/sentry-unreal/pull/782))
- Fix invalid syntax in symbol upload batch script ([#801](https://github.com/getsentry/sentry-unreal/pull/801))

### Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
#include "Android/SentrySamplingContextAndroid.h"

#include "Android/AndroidJNI.h"
#include "UObject/GarbageCollection.h"

#include "SentryDefines.h"
#include "SentryEvent.h"
#include "SentryHint.h"
#include "SentryBeforeSendHandler.h"
#include "SentryTraceSampler.h"
#include "SentrySamplingContext.h"
#include "UObject/GarbageCollection.h"
#include "UObject/UObjectThreadContext.h"

JNI_METHOD void Java_io_sentry_unreal_SentryBridgeJava_onConfigureScope(JNIEnv* env, jclass clazz, jlong callbackId, jobject scope)
{
Expand All @@ -33,12 +35,20 @@ JNI_METHOD jobject Java_io_sentry_unreal_SentryBridgeJava_onBeforeSend(JNIEnv* e
{
FGCScopeGuard GCScopeGuard;

if (FUObjectThreadContext::Get().IsRoutingPostLoad)
{
UE_LOG(LogSentrySdk, Log, TEXT("Executing `beforeSend` handler is not allowed when post-loading."));
return event;
}

USentryBeforeSendHandler* handler = reinterpret_cast<USentryBeforeSendHandler*>(objAddr);

USentryEvent* EventToProcess = USentryEvent::Create(MakeShareable(new SentryEventAndroid(event)));
USentryHint* HintToProcess = USentryHint::Create(MakeShareable(new SentryHintAndroid(hint)));

return handler->HandleBeforeSend(EventToProcess, HintToProcess) ? event : nullptr;
USentryEvent* ProcessedEvent = handler->HandleBeforeSend(EventToProcess, HintToProcess);

return ProcessedEvent ? event : nullptr;
}

JNI_METHOD jfloat Java_io_sentry_unreal_SentryBridgeJava_onTracesSampler(JNIEnv* env, jclass clazz, jlong objAddr, jobject samplingContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "GenericPlatform/GenericPlatformOutputDevices.h"
#include "HAL/FileManager.h"
#include "UObject/GarbageCollection.h"
#include "UObject/UObjectThreadContext.h"
#include "Utils/SentryLogUtils.h"

void FAppleSentrySubsystem::InitWithSettings(const USentrySettings* settings, USentryBeforeSendHandler* beforeSendHandler, USentryTraceSampler* traceSampler)
Expand Down Expand Up @@ -62,8 +63,18 @@ void FAppleSentrySubsystem::InitWithSettings(const USentrySettings* settings, US
};
options.beforeSend = ^SentryEvent* (SentryEvent* event) {
FGCScopeGuard GCScopeGuard;

if (FUObjectThreadContext::Get().IsRoutingPostLoad)
{
UE_LOG(LogSentrySdk, Log, TEXT("Executing `beforeSend` handler is not allowed when post-loading."));
return event;
}

USentryEvent* EventToProcess = USentryEvent::Create(MakeShareable(new SentryEventApple(event)));
return beforeSendHandler->HandleBeforeSend(EventToProcess, nullptr) ? event : nullptr;

USentryEvent* ProcessedEvent = beforeSendHandler->HandleBeforeSend(EventToProcess, nullptr);

return ProcessedEvent ? event : nullptr;
};
for (auto it = settings->InAppInclude.CreateConstIterator(); it; ++it)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,16 @@ sentry_value_t FGenericPlatformSentrySubsystem::OnBeforeSend(sentry_value_t even

FGCScopeGuard GCScopeGuard;

USentryEvent* EventToProcess = USentryEvent::Create(Event);

USentryEvent* ProcessedEvent = EventToProcess;
if (!FUObjectThreadContext::Get().IsRoutingPostLoad)
if (FUObjectThreadContext::Get().IsRoutingPostLoad)
{
// Executing UFUNCTION is allowed only when not post-loading
ProcessedEvent = GetBeforeSendHandler()->HandleBeforeSend(EventToProcess, nullptr);
UE_LOG(LogSentrySdk, Log, TEXT("Executing `beforeSend` handler is not allowed when post-loading."));
return event;
}

USentryEvent* EventToProcess = USentryEvent::Create(Event);

USentryEvent* ProcessedEvent = GetBeforeSendHandler()->HandleBeforeSend(EventToProcess, nullptr);

return ProcessedEvent ? event : sentry_value_new_null();
}

Expand Down
Loading