Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9ac7e0c
build and use sentry-native on macos
bitsandfoxes May 20, 2026
80de807
fix targets, fix buildpostprocess
bitsandfoxes May 20, 2026
be90a21
Merge branch 'main' into feat/macos-native
bitsandfoxes May 22, 2026
78e285d
meta data
bitsandfoxes May 22, 2026
c80ad0b
closing
bitsandfoxes May 22, 2026
c47d1ad
CI
bitsandfoxes May 22, 2026
176209d
make backend experimental
bitsandfoxes May 22, 2026
6e21b3c
rebased on top of feat/macos-native
bitsandfoxes May 22, 2026
6dafbf1
updated snapshot
bitsandfoxes May 22, 2026
f64e5e1
Merge branch 'feat/macos-native' into feat/windows-native-backend
bitsandfoxes May 22, 2026
786ba8d
fallback to branch for downloading the native sdk
bitsandfoxes May 22, 2026
558843c
cleanup
bitsandfoxes May 22, 2026
598d6c8
updated changelog
bitsandfoxes May 22, 2026
1578bf6
upsi. merge-derp
bitsandfoxes May 22, 2026
cc6cb37
clean up with every build
bitsandfoxes May 22, 2026
5a756d6
permissions
bitsandfoxes May 28, 2026
a2cc9a1
refactor buildpostprocess
bitsandfoxes May 28, 2026
e1babe7
floor the shutdown timeout
bitsandfoxes May 28, 2026
f20242e
reverted change to samples
bitsandfoxes May 28, 2026
138641d
updated options .asset file
bitsandfoxes May 28, 2026
ec2b258
ismacos
bitsandfoxes May 28, 2026
c933961
merged macos-native feature
bitsandfoxes May 28, 2026
12dc60d
simplified native sdk download fallbacks
bitsandfoxes May 28, 2026
96db359
merged main
bitsandfoxes May 28, 2026
442b943
updated changelog
bitsandfoxes May 28, 2026
10f5ab3
crashpad with no pdb
bitsandfoxes May 29, 2026
8b5af5b
.
bitsandfoxes May 29, 2026
03bcc20
Merge branch 'main' into feat/windows-native-backend
bitsandfoxes May 29, 2026
a9e598a
updated snapshot
bitsandfoxes May 29, 2026
ad1c58e
revert unrelated changelog changes
bitsandfoxes Jun 1, 2026
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
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@ jobs:
uses: ./.github/actions/wait-for-artifact
with:
name: Windows-sdk
path: package-dev/Plugins/Windows
path: package-dev/Plugins/Windows/Sentry~

- name: Download WindowsNative SDK
uses: ./.github/actions/wait-for-artifact
with:
name: WindowsNative-sdk
path: package-dev/Plugins/Windows/SentryNative~

- name: Build Sentry.Unity Solution
run: docker exec unity dotnet build -c Release -v:d
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
host: ubuntu-latest
- target: Windows
host: windows-latest
- target: WindowsNative
host: windows-latest
- target: Cocoa
host: macos-latest
- target: MacOSNative
Expand Down Expand Up @@ -409,18 +411,20 @@ jobs:
platform: linux

test-run-windows:
name: Run Windows ${{ matrix.unity-version }} Integration Test
name: Run Windows ${{ matrix.backend }} ${{ matrix.unity-version }} Integration Test
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
needs: [test-build-windows, create-unity-matrix]
secrets: inherit
strategy:
fail-fast: false
matrix:
unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }}
backend: ["crashpad", "native"]
uses: ./.github/workflows/test-run-desktop.yml
with:
unity-version: ${{ matrix.unity-version }}
platform: windows
backend: ${{ matrix.backend }}

test-run-macos:
name: Run macOS ${{ matrix.backend }} ${{ matrix.unity-version }} Integration Test
Expand Down
18 changes: 17 additions & 1 deletion .github/workflows/sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,23 @@ jobs:
retention-days: 14

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ env.TARGET != 'Cocoa' && env.TARGET != 'MacOSNative' }}
if: ${{ env.TARGET == 'Windows' }}
with:
name: ${{ env.TARGET }}-sdk
path: package-dev/Plugins/Windows/Sentry~
# Lower retention period - we only need this to retry CI.
retention-days: 14

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ env.TARGET == 'WindowsNative' }}
with:
name: ${{ env.TARGET }}-sdk
path: package-dev/Plugins/Windows/SentryNative~
# Lower retention period - we only need this to retry CI.
retention-days: 14

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ env.TARGET != 'Cocoa' && env.TARGET != 'MacOSNative' && env.TARGET != 'Windows' && env.TARGET != 'WindowsNative' }}
with:
name: ${{ env.TARGET }}-sdk
path: package-dev/Plugins/${{ env.TARGET }}
Expand Down
32 changes: 28 additions & 4 deletions .github/workflows/test-build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
env:
SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }}

- name: Build with Sentry SDK
- name: Build with Sentry SDK (Crashpad backend)
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform Windows -UnityVersion "$env:UNITY_VERSION"

- name: Compare build sizes
Expand All @@ -101,15 +101,39 @@ jobs:
retention-days: 1

# We create tar explicitly because upload-artifact is slow for many files.
- name: Create archive
- name: Create archive (Crashpad backend)
run: |
Remove-Item -Recurse -Force samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame -ErrorAction SilentlyContinue
tar -cvzf test-app-desktop.tar.gz samples/IntegrationTest/Build

- name: Upload test app
- name: Upload test app (Crashpad backend)
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: testapp-desktop-compiled-${{ env.UNITY_VERSION }}-windows
name: testapp-desktop-compiled-${{ env.UNITY_VERSION }}-windows-crashpad
if-no-files-found: error
path: test-app-desktop.tar.gz
retention-days: 14

- name: Overwrite IntegrationOptionsConfiguration for Native backend
run: |
$optionsPath = "samples/IntegrationTest/Assets/Scripts/IntegrationOptionsConfiguration.cs"
$content = Get-Content $optionsPath -Raw
$content = $content -replace 'WindowsBackend = WindowsBackend.Crashpad', 'WindowsBackend = WindowsBackend.Native'
Set-Content $optionsPath $content

- name: Build with Sentry SDK (Native backend)
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform Windows -UnityVersion "$env:UNITY_VERSION"

- name: Create archive (Native backend)
run: |
Remove-Item -Recurse -Force samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame -ErrorAction SilentlyContinue
Remove-Item -Force test-app-desktop.tar.gz -ErrorAction SilentlyContinue
tar -cvzf test-app-desktop.tar.gz samples/IntegrationTest/Build

- name: Upload test app (Native backend)
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: testapp-desktop-compiled-${{ env.UNITY_VERSION }}-windows-native
if-no-files-found: error
path: test-app-desktop.tar.gz
retention-days: 14
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-run-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
required: false
type: string
default: ""
description: "macOS only: native or cocoa"
description: "macOS: native or cocoa. Windows: native or crashpad."

defaults:
run:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ modules/sentry-native-ndk
# Android SDK files
package-dev/Plugins/Android/Sentry~/*

# Windows SDK files
package-dev/Plugins/Windows/Sentry~/*
package-dev/Plugins/Windows/SentryNative~/*

# CLI
package-dev/Editor/sentry-cli

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Features

- Introduce `sentry-native` on macOS as experimental backend. This is an opt-in and accessible programmatically via the `options.Experimental`. The `sentry-native` backend allows for crashes to be sent immediately and will enable further updates, like `AppHangTracking` support ([#2687](https://github.com/getsentry/sentry-unity/pull/2687))
- Introduce `sentry-native` as an experimental backend on macOS and Windows. Opt in via `options.Experimental.MacosBackend = MacosBackend.Native` or `options.Experimental.WindowsBackend = WindowsBackend.Native`. The `sentry-native` backend uploads crashes immediately and enables further updates such as `AppHangTracking` support ([#2687](https://github.com/getsentry/sentry-unity/pull/2687), [#2692](https://github.com/getsentry/sentry-unity/pull/2692))

### Fixes

Expand Down
60 changes: 58 additions & 2 deletions build/native-sdks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<!-- Native (Windows / Linux) -->
<SentryNativeRoot>$(RepoRoot)modules/sentry-native/</SentryNativeRoot>
<SentryLinuxArtifactsDestination>$(SentryArtifactsDestination)Linux/Sentry/</SentryLinuxArtifactsDestination>
<SentryWindowsArtifactsDestination>$(SentryArtifactsDestination)Windows/Sentry/</SentryWindowsArtifactsDestination>
<SentryWindowsArtifactsDestination>$(SentryArtifactsDestination)Windows/Sentry~/</SentryWindowsArtifactsDestination>
<SentryWindowsNativeArtifactsDestination>$(SentryArtifactsDestination)Windows/SentryNative~/</SentryWindowsNativeArtifactsDestination>
</PropertyGroup>

<!--
Expand Down Expand Up @@ -104,21 +105,25 @@
<RemoveDir Directories="$(SentryNativeRoot)build" ContinueOnError="true" />
<Delete Files="$(SentryWindowsArtifactsDestination)crashpad_handler.exe" ContinueOnError="true" />
<Delete Files="$(SentryWindowsArtifactsDestination)crashpad_wer.dll" ContinueOnError="true" />
<Delete Files="$(SentryWindowsArtifactsDestination)crashpad_wer.pdb" ContinueOnError="true" />
<Delete Files="$(SentryWindowsArtifactsDestination)sentry.dll" ContinueOnError="true" />
<Delete Files="$(SentryWindowsArtifactsDestination)sentry.pdb" ContinueOnError="true" />

<Exec WorkingDirectory="$(SentryNativeRoot)" Command="cmake -B build -D SENTRY_BACKEND=crashpad -D SENTRY_SDK_NAME=sentry.native.unity -D SENTRY_BUILD_RUNTIMESTATIC=ON -S ." />
<Exec WorkingDirectory="$(SentryNativeRoot)" Command="cmake --build build --target sentry --config RelWithDebInfo --parallel" />
<Exec WorkingDirectory="$(SentryNativeRoot)" Command="cmake --build build --target crashpad_handler --config Release --parallel" />

<MakeDir Directories="$(SentryWindowsArtifactsDestination)" />

<ItemGroup>
<NativeSdkArtifacts Include="$(SentryNativeRoot)build/crashpad_build/handler/Release/crashpad_handler.exe" />
<NativeSdkArtifacts Include="$(SentryNativeRoot)build/crashpad_build/handler/RelWithDebInfo/crashpad_wer.dll" />
<NativeSdkArtifacts Include="$(SentryNativeRoot)build/crashpad_build/handler/RelWithDebInfo/crashpad_wer.pdb" />
<NativeSdkArtifacts Include="$(SentryNativeRoot)build/RelWithDebInfo/sentry.dll" />
<NativeSdkArtifacts Include="$(SentryNativeRoot)build/RelWithDebInfo/sentry.pdb" />
</ItemGroup>

<Copy SourceFiles="@(NativeSdkArtifacts)" DestinationFiles="@(NativeSdkArtifacts->'$(SentryWindowsArtifactsDestination)%(Filename)%(Extension)')" />
<Copy SourceFiles="@(NativeSdkArtifacts)" DestinationFolder="$(SentryWindowsArtifactsDestination)" />

<Error Condition="!Exists('$(SentryWindowsArtifactsDestination)sentry.dll')" Text="Failed to set up the Windows SDK." />
</Target>
Expand All @@ -132,6 +137,57 @@
<CallTarget Targets="BuildWindowsSDK" />
</Target>

<!--
Build the Sentry Native SDK for Windows (sentry-native's new native backend):
dotnet msbuild /t:BuildWindowsNativeSDK src/Sentry.Unity
Always wipes prior outputs and rebuilds. Produces sentry.dll, sentry-crash.exe,
and sentry-wer.dll plus their .pdb sidecars.
-->
<Target Name="BuildWindowsNativeSDK" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'">
<Error Condition="!$([MSBuild]::IsOSPlatform('Windows'))" Text="BuildWindowsNativeSDK can only run on Windows." />
<Error Condition="!Exists('$(SentryNativeRoot)')" Text="sentry-native submodule not checked out at $(SentryNativeRoot). Run: git submodule update --init modules/sentry-native" />

<Message Importance="High" Text="Building Sentry Native SDK for Windows (native backend, clean rebuild)." />

<!-- Wipe prior outputs -->
<RemoveDir Directories="$(SentryNativeRoot)build_native" ContinueOnError="true" />
<Delete Files="$(SentryWindowsNativeArtifactsDestination)sentry.dll" ContinueOnError="true" />
<Delete Files="$(SentryWindowsNativeArtifactsDestination)sentry.pdb" ContinueOnError="true" />
<Delete Files="$(SentryWindowsNativeArtifactsDestination)sentry-crash.exe" ContinueOnError="true" />
<Delete Files="$(SentryWindowsNativeArtifactsDestination)sentry-crash.pdb" ContinueOnError="true" />
<Delete Files="$(SentryWindowsNativeArtifactsDestination)sentry-wer.dll" ContinueOnError="true" />
<Delete Files="$(SentryWindowsNativeArtifactsDestination)sentry-wer.pdb" ContinueOnError="true" />

<Exec WorkingDirectory="$(SentryNativeRoot)" Command="cmake -B build_native -D SENTRY_BACKEND=native -D SENTRY_SDK_NAME=sentry.native.unity -D SENTRY_BUILD_RUNTIMESTATIC=ON -S ." />
<Exec WorkingDirectory="$(SentryNativeRoot)" Command="cmake --build build_native --target sentry --config RelWithDebInfo --parallel" />
<Exec WorkingDirectory="$(SentryNativeRoot)" Command="cmake --build build_native --target sentry-crash --config RelWithDebInfo --parallel" />
<Exec WorkingDirectory="$(SentryNativeRoot)" Command="cmake --build build_native --target sentry-wer --config RelWithDebInfo --parallel" />

<MakeDir Directories="$(SentryWindowsNativeArtifactsDestination)" />

<ItemGroup>
<WindowsNativeSdkArtifacts Include="$(SentryNativeRoot)build_native/RelWithDebInfo/sentry.dll" />
<WindowsNativeSdkArtifacts Include="$(SentryNativeRoot)build_native/RelWithDebInfo/sentry.pdb" />
<WindowsNativeSdkArtifacts Include="$(SentryNativeRoot)build_native/RelWithDebInfo/sentry-crash.exe" />
<WindowsNativeSdkArtifacts Include="$(SentryNativeRoot)build_native/RelWithDebInfo/sentry-crash.pdb" />
<WindowsNativeSdkArtifacts Include="$(SentryNativeRoot)build_native/RelWithDebInfo/sentry-wer.dll" />
<WindowsNativeSdkArtifacts Include="$(SentryNativeRoot)build_native/RelWithDebInfo/sentry-wer.pdb" />
</ItemGroup>

<Copy SourceFiles="@(WindowsNativeSdkArtifacts)" DestinationFolder="$(SentryWindowsNativeArtifactsDestination)" />

<Error Condition="!Exists('$(SentryWindowsNativeArtifactsDestination)sentry.dll')" Text="Failed to set up the Windows Native SDK." />
</Target>

<!-- Hooks into 'dotnet build' so a missing Windows Native plugin auto-triggers BuildWindowsNativeSDK. -->
<Target Name="EnsureWindowsNativeSDK"
BeforeTargets="BeforeBuild"
Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'
And $([MSBuild]::IsOSPlatform('Windows'))
And !Exists('$(SentryWindowsNativeArtifactsDestination)sentry.dll')">
<CallTarget Targets="BuildWindowsNativeSDK" />
</Target>
Comment on lines +183 to +189

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The EnsureWindowsNativeSDK build target runs on every Windows build if sentry.dll is missing, even when the native backend is disabled, causing unnecessary build failures.
Severity: MEDIUM

Suggested Fix

Modify the condition for the EnsureWindowsNativeSDK target to also check if the native backend is enabled for the current build. This could be done by checking a property that indicates the selected backend, preventing the target from running when it's not needed.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: build/native-sdks.targets#L183-L189

Potential issue: The MSBuild target `EnsureWindowsNativeSDK` in
`build/native-sdks.targets` is triggered on every Windows build where `sentry.dll` is
not present. The condition for this target only checks the OS and the existence of the
DLL, but not whether the native backend is actually enabled for the build. Consequently,
developers on Windows without the C++ build environment (CMake, submodules) will face a
build failure when running `dotnet build` on a fresh checkout, even if they don't intend
to use the native backend. This blocks development for a valid use case.

Did we get this right? 👍 / 👎 to inform future reviews.


<!--
Build the Sentry Native SDK for macOS:
dotnet msbuild /t:BuildMacOSNativeSDK src/Sentry.Unity
Expand Down
90 changes: 0 additions & 90 deletions package-dev/Plugins/Windows/Sentry/sentry.dll.meta

This file was deleted.

Loading
Loading