getsentry / sentry-native

Sentry SDK for C, C++ and native applications.
MIT License
403 stars 169 forks source link

Add GDK support to `sentry-native` #1068

Open bruno-garcia opened 1 week ago

bruno-garcia commented 1 week ago

Microsoft has open sourced the GDK: https://github.com/microsoft/gdk

Using the MIT-licensed code from that repo, we could have sentry-native support the GDK on PC and make it easier for folks on Xbox to build on top of that to get access to closed-source/NDA protected platforms (i.e: Xbox Series S|X)

Testing must be done only with the Windows GDK. To be clear, only code from the open source GDK (https://github.com/microsoft/gdk) can be used here and CI won't involve devices other than the GHA Windows VM.

General references to the Xbox Extensions is OK btw, we just can't have any code from it here. So if that helps with the CMake files, that's fine.

supervacuus commented 1 week ago

I am still not sure I understand the distinction here:

Using the MIT-licensed code from that repo, we could have sentry-native support the GDK on PC and make it easier for folks on Xbox to build on top of that to get access to closed-source/NDA protected platforms (i.e: Xbox Series S|X)

Testing must be done only with the Windows GDK. To be clear, only code from the open source GDK (https://github.com/microsoft/gdk) can be used here and CI won't involve devices other than the GHA Windows VM.

Does this mean we can use the PGDK.exe installer from https://github.com/microsoft/gdk to build out in the open? Does it have the Scarlett-relevant headers? The only difference is that we cannot deploy the resulting binaries to a device?

PlasmaDev5 commented 1 week ago

PGDK is a windows focused SDK for developing with UWP applications. By chance Xbox allows consumers to load UWP apps but this is a minimal sandbox with many restrictions so not useful for most games. GDKX is the Xbox specific version that includes new/extra and modified headers specific to Xbox. The idea is the are at least largely compatible so GDK can give you at least some progress towards goals

supervacuus commented 1 week ago

PGDK is a windows focused SDK for developing with UWP applications. By chance Xbox allows consumers to load UWP apps but this is a minimal sandbox with many restrictions so not useful for most games. GDKX is the Xbox specific version that includes new/extra and modified headers specific to Xbox.

That is also my state of knowledge, but it conflicts with what was written above.

The idea is the are at least largely compatible so GDK can give you at least some progress towards goals

Using pdgx.exe would be helpful only if we could use it to build the configuration targeting Xbox (because the changes I applied followed that goal of targeting Scarlett). Otherwise, I would prefer only to apply my source changes and have a closed build outside the public GitHub infra.

By the way, the changes on the private repo have been available for more than a year, and missing ownership, legal questions, and clear goals primarily inhibited progress toward releasing the changes under MIT.

The ownership and legal topics are now clarified. Thanks to @bruno-garcia. I am still missing clarity on the goal because, to me, what @bruno-garcia wrote here, https://discord.com/channels/621778831602221064/1299749883254673410/1301610082852933743, doesn't match the use of https://github.com/microsoft/gdk. It is totally possible that I am not getting it.

But it sounded like the build (and anything following it) must still happen in a closed environment. If a pgdx installation does not provide a Scarlett build target, I need help understanding the following reference to https://github.com/microsoft/gdk:

Testing must be done only with the Windows GDK. To be clear, only code from the open source GDK (https://github.com/microsoft/gdk) can be used here and CI won't involve devices other than the GHA Windows VM.

bruno-garcia commented 1 week ago

By chance Xbox allows consumers to load UWP apps but this is a minimal sandbox with many restrictions so not useful for most games.

It's not really by chance. It was an effort from Microsoft to align the APIs to make it easier for developers to use a single API regardless what they are targeting. We're not building games here, so we need to see if it's enough for our use case (basic verification that things compile). Additional/further CI/CD we can do on a separate repo. But that assumes the diff between what's private and sentry-native/master will be reduced through this ticket.

The idea is the are at least largely compatible so GDK can give you at least some progress towards goals

Right, this is the idea. Is that feasible?

Otherwise, I would prefer only to apply my source changes and have a closed build outside the public GitHub infra.

For changes that relate to GDKX we would indeed need to do on a separate repo.

By the way, the changes on the private repo have been available for more than a year, and missing ownership, legal questions, and clear goals primarily inhibited progress toward releasing the changes under MIT.

I need help understanding the following reference to https://github.com/microsoft/gdk: Testing must be done only with the Windows GDK.

We can only leverage MIT-licensed GDK code in this repo. And downloading the GDKX on a public GHA runner isn't something we can do at this time. I'm not sure what would be the best route for us here, I'd appreciate suggestions. The goal was to only close the gap between our main branch here, and what a user targeting Xbox will need to have by having any GDK dependency happen against the OSS code base, but if there's not enough value in that please clarify

bruno-garcia commented 1 week ago

Some ideas of GDK based integrations that could be event or breadcrumbs:

Some of these might manifest with a system popup, or a crash(?) or user needs to handle the failure and programatically call Sentry. But what/how could we hook and make this easier to give visibility to developers of what's going wrong?

if there are no hooks, can we contribute a hook upstream to the GDK?

We could also leverage it get additional context or tags. For example our protocol has Device part where we take device storage, RAM etc.

There's a lot more on the GDK docs, I just pulled a few links to give some ideas.

Surely some of these won't help with Unreal when they don't rely on GDK but rather direct OS APIs, but at least for those on GDK directly on PC and Xbox will benefit from it.

bruno-garcia commented 2 days ago

A lot of what it takes to build sentry-native on Xbox is available here: https://github.com/search?q=repo%3Amicrosoft%2FXbox-GDK-Samples%20scarlett&type=code

The repo is MIT licensed, and we have an agreement in place that lets us use it.