Skip to content

Commit 1fa3a78

Browse files
authored
Fix warning about missing GPU crash dump attachment (#1022)
* Update gpu dump attachment handling * Fix comment * Add more crash types to demo app * Update changelog
1 parent 00d7fa3 commit 1fa3a78

File tree

11 files changed

+50
-34
lines changed

11 files changed

+50
-34
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Fixes
6+
7+
- No more warnings about missing GPU crash dump attachment when capturing non-GPU events ([#1022](https://github.com/getsentry/sentry-unreal/pull/1022))
8+
59
### Dependencies
610

711
- Bump CLI from v2.50.0 to v2.50.2 ([#1020](https://github.com/getsentry/sentry-unreal/pull/1020), [#1021](https://github.com/getsentry/sentry-unreal/pull/1021))

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ sentry_value_t FGenericPlatformSentrySubsystem::OnCrash(const sentry_ucontext_t*
177177
TryCaptureScreenshot();
178178
}
179179

180-
if (GIsGPUCrashed)
180+
if (GIsGPUCrashed && isGpuDumpAttachmentEnabled)
181181
{
182-
IFileManager::Get().Copy(*GetGpuDumpBackupPath(), *SentryFileUtils::GetGpuDumpPath());
182+
TryCaptureGpuDump();
183183
}
184184

185185
// At this point crash events are handled the same way as non-fatal ones,
@@ -238,6 +238,7 @@ FGenericPlatformSentrySubsystem::FGenericPlatformSentrySubsystem()
238238
, isStackTraceEnabled(true)
239239
, isPiiAttachmentEnabled(false)
240240
, isScreenshotAttachmentEnabled(false)
241+
, isGpuDumpAttachmentEnabled(false)
241242
{
242243
}
243244

@@ -269,18 +270,14 @@ void FGenericPlatformSentrySubsystem::InitWithSettings(const USentrySettings* se
269270
databaseParentPath = FPaths::ProjectUserDir();
270271
}
271272

272-
if (settings->AttachScreenshot)
273+
isScreenshotAttachmentEnabled = settings->AttachScreenshot;
274+
if (isScreenshotAttachmentEnabled)
273275
{
274-
isScreenshotAttachmentEnabled = true;
275-
276276
// Clear screenshot captured during previous session if any
277277
IFileManager::Get().DeleteDirectory(*FPaths::Combine(GetDatabasePath(), TEXT("screenshots")), false, true);
278278
}
279279

280-
if (settings->AttachGpuDump)
281-
{
282-
ConfigureGpuDumpAttachment(options);
283-
}
280+
isGpuDumpAttachmentEnabled = settings->AttachGpuDump;
284281

285282
if (settings->UseProxy)
286283
{
@@ -683,14 +680,19 @@ void FGenericPlatformSentrySubsystem::TryCaptureScreenshot()
683680
AddFileAttachment(ScreenshotAttachment);
684681
}
685682

686-
FString FGenericPlatformSentrySubsystem::GetGpuDumpBackupPath() const
683+
void FGenericPlatformSentrySubsystem::TryCaptureGpuDump()
687684
{
688-
static const FString DateTimeString = FDateTime::Now().ToString();
685+
const FString& GpuDumpPath = SentryFileUtils::GetGpuDumpPath();
686+
687+
if (!IFileManager::Get().FileExists(*GpuDumpPath))
688+
{
689+
return;
690+
}
689691

690-
const FString GpuDumpPath = FPaths::Combine(GetDatabasePath(), TEXT("gpudumps"), *FString::Printf(TEXT("UEAftermath-%s.nv-gpudmp"), *DateTimeString));
691-
const FString GpuDumpFullPath = FPaths::ConvertRelativePathToFull(GpuDumpPath);
692+
TSharedPtr<ISentryAttachment> GpuDumpAttachment =
693+
MakeShareable(new FGenericPlatformSentryAttachment(GpuDumpPath, FPaths::GetCleanFilename(GpuDumpPath), TEXT("application/octet-stream")));
692694

693-
return GpuDumpFullPath;
695+
AddFileAttachment(GpuDumpAttachment);
694696
}
695697

696698
FString FGenericPlatformSentrySubsystem::GetHandlerPath() const

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,13 @@ class FGenericPlatformSentrySubsystem : public ISentrySubsystem
5555
USentryBeforeBreadcrumbHandler* GetBeforeBreadcrumbHandler();
5656

5757
void TryCaptureScreenshot();
58-
59-
FString GetGpuDumpBackupPath() const;
58+
void TryCaptureGpuDump();
6059

6160
protected:
6261
virtual void ConfigureHandlerPath(sentry_options_t* Options) {}
6362
virtual void ConfigureDatabasePath(sentry_options_t* Options) {}
6463
virtual void ConfigureCertsPath(sentry_options_t* Options) {}
6564
virtual void ConfigureLogFileAttachment(sentry_options_t* Options) {}
66-
virtual void ConfigureGpuDumpAttachment(sentry_options_t* Options) {}
6765
virtual void ConfigureNetworkConnectFunc(sentry_options_t* Options) {}
6866

6967
FString GetHandlerPath() const;
@@ -100,6 +98,7 @@ class FGenericPlatformSentrySubsystem : public ISentrySubsystem
10098
bool isStackTraceEnabled;
10199
bool isPiiAttachmentEnabled;
102100
bool isScreenshotAttachmentEnabled;
101+
bool isGpuDumpAttachmentEnabled;
103102

104103
FString databaseParentPath;
105104
};

plugin-dev/Source/Sentry/Private/Linux/LinuxSentrySubsystem.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,4 @@ void FLinuxSentrySubsystem::ConfigureLogFileAttachment(sentry_options_t* Options
6060
sentry_options_add_attachment(Options, TCHAR_TO_UTF8(*FPaths::ConvertRelativePathToFull(LogFilePath)));
6161
}
6262

63-
void FLinuxSentrySubsystem::ConfigureGpuDumpAttachment(sentry_options_t* Options)
64-
{
65-
sentry_options_add_attachment(Options, TCHAR_TO_UTF8(*GetGpuDumpBackupPath()));
66-
}
67-
6863
#endif // USE_SENTRY_NATIVE

plugin-dev/Source/Sentry/Private/Linux/LinuxSentrySubsystem.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class FLinuxSentrySubsystem : public FGenericPlatformSentrySubsystem
1616
virtual void ConfigureDatabasePath(sentry_options_t* Options) override;
1717
virtual void ConfigureCertsPath(sentry_options_t* Options) override;
1818
virtual void ConfigureLogFileAttachment(sentry_options_t* Options) override;
19-
virtual void ConfigureGpuDumpAttachment(sentry_options_t* Options) override;
2019

2120
virtual FString GetHandlerExecutableName() const override { return TEXT("crashpad_handler"); }
2221
};

plugin-dev/Source/Sentry/Private/Utils/SentryFileUtils.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,15 @@ FString SentryFileUtils::GetGpuDumpPath()
5959
return FString("");
6060
}
6161

62-
if (GpuDumpFiles.Num() > 1)
62+
// By default, engine cleans up GPU dumps from the previous runs however this doesn't seem to be the case
63+
// if https://github.com/EpicGames/UnrealEngine/pull/12648 patch is applied so we just return the newest one
64+
65+
for (int i = 0; i < GpuDumpFiles.Num(); ++i)
6366
{
64-
// By default, engine should handle clean up of GPU dumps from the previous runs
65-
UE_LOG(LogSentrySdk, Log, TEXT("There are multiple GPU dump files, can't determine reliably which one to pick."));
66-
return FString("");
67+
GpuDumpFiles[i] = FPaths::ProjectLogDir() / GpuDumpFiles[i];
6768
}
6869

69-
return IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*(FPaths::ProjectLogDir() / GpuDumpFiles[0]));
70+
GpuDumpFiles.Sort(FSentrySortFileByDatePredicate());
71+
72+
return IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*GpuDumpFiles[0]);
7073
}

plugin-dev/Source/Sentry/Private/Windows/WindowsSentrySubsystem.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
#include "Windows/Infrastructure/WindowsSentryConverters.h"
1111
#include "Windows/WindowsPlatformStackWalk.h"
1212

13-
void FWindowsSentrySubsystem::ConfigureGpuDumpAttachment(sentry_options_t* Options)
14-
{
15-
sentry_options_add_attachmentw(Options, *GetGpuDumpBackupPath());
16-
}
17-
1813
static void PrintCrashLog(const sentry_ucontext_t* uctx)
1914
{
2015
#if !UE_VERSION_OLDER_THAN(5, 0, 0)

plugin-dev/Source/Sentry/Private/Windows/WindowsSentrySubsystem.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
class FWindowsSentrySubsystem : public FMicrosoftSentrySubsystem
1010
{
1111
protected:
12-
virtual void ConfigureGpuDumpAttachment(sentry_options_t* Options) override;
1312
virtual FString GetHandlerExecutableName() const override { return TEXT("crashpad_handler.exe"); }
1413

1514
virtual sentry_value_t OnCrash(const sentry_ucontext_t* uctx, sentry_value_t event, void* closure) override;
7.33 KB
Binary file not shown.

sample/Source/SentryPlayground/SentryPlaygroundUtils.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "SentryPlaygroundUtils.h"
44

5+
#include "Engine/Engine.h"
56
#include "HAL/FileManager.h"
67
#include "Misc/FileHelper.h"
78
#include "Misc/Paths.h"
@@ -44,6 +45,22 @@ void USentryPlaygroundUtils::Terminate(ESentryAppTerminationType Type)
4445
UE_LOG(LogTemp, VeryVerbose, TEXT("Stack addr: %p"), &buffer);
4546
Terminate(Type);
4647
break;
48+
case ESentryAppTerminationType::OutOfMemory:
49+
{
50+
size_t Count = 1024;
51+
while (true)
52+
{
53+
void* _ = FMemory::Malloc(Count);
54+
Count *= 2;
55+
}
56+
}
57+
break;
58+
case ESentryAppTerminationType::RenderThreadCrash:
59+
GEngine->Exec(nullptr, TEXT("Debug RenderCrash"));
60+
break;
61+
case ESentryAppTerminationType::GpuDebugCrash:
62+
GEngine->Exec(nullptr, TEXT("GPUDebugCrash platformbreak"));
63+
break;
4764
case ESentryAppTerminationType::FastFail:
4865
{
4966
#if PLATFORM_MICROSOFT

0 commit comments

Comments
 (0)