Skip to content

Commit 96f2f65

Browse files
authored
feat: PlayStation native support (#2433)
1 parent adc6bda commit 96f2f65

22 files changed

+235
-150
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
### Features
1313

14+
- Added PlayStation Native Support. The SDK now automatically syncs the scope - tags, breadcrumbs, context - to the native layer, so native crashes have the same rich context as managed events. ([#2433](https://github.com/getsentry/sentry-unity/pull/2433))
1415
- On Windows, and with screenshot capture enabled, the SDK will now also capture and attach a screenshot to native crashes ([#2434](https://github.com/getsentry/sentry-unity/pull/2434))
1516
- Added `SetBeforeSendScreenshot(Func<Texture2D, SentryEvent, Texture2D?>)` callback that provides the captured screenshot as a
1617
`Texture2D` before JPEG compression. ([#2428](https://github.com/getsentry/sentry-unity/pull/2428))
@@ -21,7 +22,7 @@
2122
- Access to the event context for conditional processing
2223
- Added `SetBeforeSendViewHierarchy(Func<ViewHierarchy, SentryEvent, ViewHierarchy?>)` callback that provides the captured
2324
`ViewHierarchy` to be modified before compression. ([#2429](https://github.com/getsentry/sentry-unity/pull/2429))
24-
25+
2526
### Dependencies
2627

2728
- Bump Cocoa SDK from v8.57.2 to v8.57.3 ([#2424](https://github.com/getsentry/sentry-unity/pull/2424), [#2427](https://github.com/getsentry/sentry-unity/pull/2427))
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <stdarg.h>
2+
#include <stdio.h>
3+
4+
/**
5+
* Wrapper around vsnprintf for Unity C# IL2CPP interop.
6+
*
7+
* This function provides a stable ABI entry point for Unity to call
8+
* vsnprintf functionality across Windows, Linux, and PlayStation platforms.
9+
*
10+
* This wrapper is compiled as native C code where va_list is properly
11+
* understood, then IL2CPP calls this wrapper with generic pointers.
12+
*/
13+
int vsnprintf_sentry(char *buffer, size_t size, const char *format, va_list args)
14+
{
15+
return vsnprintf(buffer, size, format, args);
16+
}

package-dev/Runtime/Sentry.Unity.Native.Console.dll.meta renamed to package-dev/Plugins/PS5/sentry_utils.c.meta

Lines changed: 7 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-dev/Runtime/Sentry.Unity.Native.PlayStation.dll.meta

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-dev/Runtime/Sentry.Unity.Native.dll.meta

Lines changed: 29 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-dev/Runtime/SentryInitialization.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#define SENTRY_NATIVE
88
#elif UNITY_GAMECORE
99
#define SENTRY_NATIVE
10+
#elif UNITY_PS5
11+
#define SENTRY_NATIVE
1012
#elif UNITY_WEBGL
1113
#define SENTRY_WEBGL
1214
#endif
@@ -131,7 +133,7 @@ private Il2CppMethods _il2CppMethods
131133
return null;
132134
}
133135

134-
#if UNITY_ANDROID || UNITY_STANDALONE_LINUX
136+
#if UNITY_ANDROID || UNITY_STANDALONE_LINUX || UNITY_PS5
135137
// For ELF platforms, the 20-byte `NT_GNU_BUILD_ID` needs to be
136138
// turned into a "little-endian GUID", which means the first three
137139
// components need to be byte-swapped appropriately.

package-dev/Runtime/io.sentry.unity.dev.runtime.asmdef

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"LinuxStandalone64",
1212
"Lumin",
1313
"macOSStandalone",
14+
"PS5",
1415
"Stadia",
1516
"Switch",
1617
"WSA",

package/Runtime/io.sentry.unity.runtime.asmdef

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"LinuxStandalone64",
1212
"Lumin",
1313
"macOSStandalone",
14+
"PS5",
1415
"Stadia",
1516
"Switch",
1617
"WSA",

src/Sentry.Unity.Editor/ConfigurationWindow/AdvancedTab.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,12 @@ internal static void Display(ScriptableSentryUnityOptions options, SentryCliOpti
141141
GUILayout.Label("Console", EditorStyles.boldLabel);
142142

143143
options.XboxNativeSupportEnabled = EditorGUILayout.Toggle(
144-
new GUIContent("Xbox", "Whether to enable native crashes support on Xbox."),
144+
new GUIContent("Xbox", "Whether to enable native crash support on Xbox."),
145145
options.XboxNativeSupportEnabled);
146+
147+
options.PlayStationNativeSupportEnabled = EditorGUILayout.Toggle(
148+
new GUIContent("PlayStation", "Whether to enable native crash support on PlayStation."),
149+
options.PlayStationNativeSupportEnabled);
146150
}
147151

148152
EditorGUI.indentLevel--;

src/Sentry.Unity.Editor/Native/BuildPostProcess.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Sentry.Extensibility;
44
using Sentry.Unity.Editor.ConfigurationWindow;
55
using System.Text.RegularExpressions;
6-
using Microsoft.Extensions.FileSystemGlobbing;
76
using UnityEngine;
87
using UnityEditor;
98
using UnityEditor.Build;
@@ -18,7 +17,9 @@ public static class BuildPostProcess
1817
public static void OnPostProcessBuild(BuildTarget target, string executablePath)
1918
{
2019
var targetGroup = BuildPipeline.GetBuildTargetGroup(target);
21-
if (targetGroup is not BuildTargetGroup.Standalone and not BuildTargetGroup.GameCoreXboxSeries)
20+
if (targetGroup is not BuildTargetGroup.Standalone
21+
and not BuildTargetGroup.GameCoreXboxSeries
22+
and not BuildTargetGroup.PS5)
2223
{
2324
return;
2425
}
@@ -47,10 +48,12 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath)
4748
// The executable path resolves to the following when pointing Unity into a `build/platform/` directory:
4849
// - Desktop: `./samples/unity-of-bugs/builds/windows/unityofbugs.exe`
4950
// - Xbox: `./samples/unity-of-bugs/builds/xsx/`
51+
// - PlayStation: `./samples/unity-of-bugs/builds/ps5/`
5052
var buildOutputDir = targetGroup switch
5153
{
5254
BuildTargetGroup.Standalone => Path.GetDirectoryName(executablePath),
5355
BuildTargetGroup.GameCoreXboxSeries => executablePath,
56+
BuildTargetGroup.PS5 => executablePath,
5457
_ => string.Empty
5558
};
5659

@@ -87,6 +90,7 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath)
8790
BuildTarget.StandaloneOSX => options.MacosNativeSupportEnabled,
8891
BuildTarget.StandaloneLinux64 => options.LinuxNativeSupportEnabled,
8992
BuildTarget.GameCoreXboxSeries or BuildTarget.GameCoreXboxOne => options.XboxNativeSupportEnabled,
93+
BuildTarget.PS5 => options.PlayStationNativeSupportEnabled,
9094
_ => false,
9195
};
9296

@@ -108,6 +112,9 @@ private static void AddCrashHandler(IDiagnosticLogger logger, BuildTarget target
108112
case BuildTarget.GameCoreXboxOne:
109113
// No standalone crash handler for Xbox - comes with Breakpad
110114
return;
115+
case BuildTarget.PS5:
116+
// No standalone crash handler for PlayStation
117+
return;
111118
default:
112119
throw new ArgumentException($"Unsupported build target: {target}");
113120
}
@@ -158,6 +165,13 @@ private static void UploadDebugSymbols(IDiagnosticLogger logger, BuildTarget tar
158165
paths += $" \"{xboxSentryPluginPath}\"";
159166
}
160167
break;
168+
case BuildTarget.PS5:
169+
var playstationSentryPluginPath = Path.GetFullPath("Assets/Plugins/Sentry/");
170+
if (Directory.Exists(playstationSentryPluginPath))
171+
{
172+
paths += $" \"{playstationSentryPluginPath}\"";
173+
}
174+
break;
161175
case BuildTarget.StandaloneLinux64:
162176
var linuxSentryDbg = Path.GetFullPath($"Packages/{SentryPackageInfo.GetName()}/Plugins/Linux/Sentry/libsentry.dbg.so");
163177
if (File.Exists(linuxSentryDbg))

0 commit comments

Comments
 (0)