Skip to content

feat: Xbox support #2068

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
63 changes: 63 additions & 0 deletions package-dev/Plugins/Xbox/Sentry/sentry.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 22 additions & 39 deletions package-dev/Runtime/Sentry.Unity.Native.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion package-dev/Runtime/SentryInitialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#define SENTRY_NATIVE_ANDROID
#elif UNITY_64 && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX)
#define SENTRY_NATIVE
#elif UNITY_GAMECORE
#define SENTRY_NATIVE
#elif UNITY_WEBGL
#define SENTRY_WEBGL
#endif
Expand Down Expand Up @@ -55,6 +57,10 @@ public static class SentryInitialization
#endif
public static void Init()
{
#if IL2CPP_LINENUMBER_SUPPORT
Debug.Log("should work now");
#endif

var unityInfo = new SentryUnityInfo();
// Loading the options invokes the ScriptableOption`Configure` callback. Users can disable the SDK via code.
var options = ScriptableSentryUnityOptions.LoadSentryUnityOptions(unityInfo);
Expand Down Expand Up @@ -90,6 +96,7 @@ private static void SetupNativeSdk(SentryUnityOptions options, SentryUnityInfo u
#elif SENTRY_NATIVE_ANDROID
SentryNativeAndroid.Configure(options, unityInfo);
#elif SENTRY_NATIVE
options.DiagnosticLogger?.LogDebug("Considering this a native thing!");
SentryNative.Configure(options, unityInfo);
#elif SENTRY_WEBGL
SentryWebGL.Configure(options);
Expand Down Expand Up @@ -290,7 +297,8 @@ public bool IsKnownPlatform()
platform == RuntimePlatform.OSXPlayer ||
platform == RuntimePlatform.LinuxEditor ||
platform == RuntimePlatform.LinuxPlayer ||
platform == RuntimePlatform.WebGLPlayer
platform == RuntimePlatform.WebGLPlayer ||
platform == RuntimePlatform.GameCoreXboxSeries
#if UNITY_2021_3_OR_NEWER
||
platform == RuntimePlatform.WindowsServer ||
Expand Down Expand Up @@ -325,6 +333,8 @@ public bool IsNativeSupportEnabled(SentryUnityOptions options, RuntimePlatform p
return options.MacosNativeSupportEnabled;
case RuntimePlatform.LinuxPlayer:
return options.LinuxNativeSupportEnabled;
case RuntimePlatform.GameCoreXboxSeries:
return true;
#if UNITY_2021_3_OR_NEWER
case RuntimePlatform.WindowsServer:
return options.WindowsNativeSupportEnabled;
Expand All @@ -344,6 +354,7 @@ public bool IsSupportedBySentryNative(RuntimePlatform platform)
return platform == RuntimePlatform.Android
|| platform == RuntimePlatform.LinuxPlayer
|| platform == RuntimePlatform.WindowsPlayer
|| platform == RuntimePlatform.GameCoreXboxSeries
#if UNITY_2021_3_OR_NEWER
|| platform == RuntimePlatform.WindowsServer
|| platform == RuntimePlatform.OSXServer
Expand All @@ -366,6 +377,8 @@ public string GetDebugImageType(RuntimePlatform platform)
return "elf";
case RuntimePlatform.WindowsPlayer:
return "pe";
case RuntimePlatform.GameCoreXboxSeries:
return "pe";
Comment on lines 379 to +381
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "pe";
case RuntimePlatform.GameCoreXboxSeries:
return "pe";
case RuntimePlatform.GameCoreXboxSeries:
return "pe";

#if UNITY_2021_3_OR_NEWER
case RuntimePlatform.WindowsServer:
return "pe";
Expand Down
16 changes: 12 additions & 4 deletions src/Sentry.Unity.Editor/Native/BuildPostProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ public static class BuildPostProcess
public static void OnPostProcessBuild(BuildTarget target, string executablePath)
{
var targetGroup = BuildPipeline.GetBuildTargetGroup(target);
if (targetGroup is not BuildTargetGroup.Standalone)
{
return;
}
// TODO: Is Xbox standalone?
// if (targetGroup is not BuildTargetGroup.Standalone)
// {
// return;
// }

var (options, cliOptions) = SentryScriptableObject.ConfiguredBuildTimeOptions();
var logger = options?.DiagnosticLogger ?? new UnityLogger(options ?? new SentryUnityOptions());
Expand Down Expand Up @@ -77,6 +78,7 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath)
BuildTarget.StandaloneWindows64 => options.WindowsNativeSupportEnabled,
BuildTarget.StandaloneOSX => options.MacosNativeSupportEnabled,
BuildTarget.StandaloneLinux64 => options.LinuxNativeSupportEnabled,
(BuildTarget)42 => true,
_ => false,
};

Expand All @@ -94,6 +96,9 @@ private static void AddCrashHandler(IDiagnosticLogger logger, BuildTarget target
case BuildTarget.StandaloneOSX:
// No standalone crash handler for Linux/macOS - uses built-in handlers.
return;
case (BuildTarget)42:
logger.LogDebug("I know it's Xbox but I don't know what do to with it (yet).");
break;
default:
throw new ArgumentException($"Unsupported build target: {target}");
}
Expand Down Expand Up @@ -219,6 +224,9 @@ private static void UploadDebugSymbols(IDiagnosticLogger logger, BuildTarget tar
addPath(Path.GetFileNameWithoutExtension(executableName) + "_BackUpThisFolder_ButDontShipItWithYourGame");
}
break;
case (BuildTarget)42:
logger.LogDebug("This is where I would attempt to upload stuff for Xbox to Sentry as well.");
break;
default:
logger.LogError($"Symbol upload for '{target}' is currently not supported.");
break;
Expand Down
10 changes: 5 additions & 5 deletions src/Sentry.Unity.Native/SentryNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public static void Configure(SentryUnityOptions options, ISentryUnityInfo sentry
options.NativeContextWriter = new NativeContextWriter();

// Use AnalyticsSessionInfo.userId as the default UserID in native & dotnet
options.DefaultUserId = AnalyticsSessionInfo.userId;
if (options.DefaultUserId is not null)
{
options.ScopeObserver.SetUser(new SentryUser { Id = options.DefaultUserId });
}
// options.DefaultUserId = AnalyticsSessionInfo.userId;
// if (options.DefaultUserId is not null)
// {
// options.ScopeObserver.SetUser(new SentryUser { Id = options.DefaultUserId });
// }

// Note: we must actually call the function now and on every other call use the value we get here.
// Additionally, we cannot call this multiple times for the same directory, because the result changes
Expand Down
3 changes: 2 additions & 1 deletion src/Sentry.Unity/Integrations/UnityScopeIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ private void PopulateApp(App app)

private void PopulateOperatingSystem(OperatingSystem operatingSystem)
{
operatingSystem.RawDescription = MainThreadData.OperatingSystem;
// operatingSystem.RawDescription = MainThreadData.OperatingSystem;
operatingSystem.RawDescription = "Xbox 10.0.26100";
}

private void PopulateDevice(Device device)
Expand Down
Loading