Skip to content

Commit c00f32b

Browse files
authored
Add native backend support for Mac (#1333)
1 parent bdbea44 commit c00f32b

59 files changed

Lines changed: 551 additions & 137 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,20 @@ jobs:
2222
target: IOS
2323
runsOn: ubuntu-latest
2424

25-
macos-sdk:
25+
macos-cocoa-sdk:
2626
uses: ./.github/workflows/sdk-download.yml
2727
with:
2828
target: Mac
29+
backend: cocoa
2930
runsOn: ubuntu-latest
3031

32+
macos-native-sdk:
33+
uses: ./.github/workflows/sdk-build.yml
34+
with:
35+
target: Mac
36+
backend: native
37+
runsOn: macos-latest
38+
3139
linux-sdk-crashpad:
3240
uses: ./.github/workflows/sdk-build.yml
3341
with:
@@ -116,8 +124,15 @@ jobs:
116124
runsOn: ubuntu-latest
117125
runtimeId: linux-arm64
118126

127+
crash-reporter-mac:
128+
uses: ./.github/workflows/crash-reporter-build.yml
129+
with:
130+
target: Mac
131+
runsOn: macos-latest
132+
runtimeId: osx-arm64
133+
119134
package-preparation:
120-
needs: [android-sdk, ios-sdk, macos-sdk, linux-sdk-crashpad, linux-sdk-native, linux-arm64-sdk-crashpad, linux-arm64-sdk-native, windows-sdk-crashpad, windows-sdk-native, windows-arm64-sdk-crashpad, windows-arm64-sdk-native, crash-reporter-win64, crash-reporter-win-arm64, crash-reporter-linux, crash-reporter-linux-arm64]
135+
needs: [android-sdk, ios-sdk, macos-cocoa-sdk, macos-native-sdk, linux-sdk-crashpad, linux-sdk-native, linux-arm64-sdk-crashpad, linux-arm64-sdk-native, windows-sdk-crashpad, windows-sdk-native, windows-arm64-sdk-crashpad, windows-arm64-sdk-native, crash-reporter-win64, crash-reporter-win-arm64, crash-reporter-linux, crash-reporter-linux-arm64, crash-reporter-mac]
121136
name: Package
122137
runs-on: ubuntu-latest
123138
steps:
@@ -142,9 +157,14 @@ jobs:
142157

143158
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
144159
with:
145-
name: Mac-sdk
160+
name: Mac-cocoa-sdk
146161
path: plugin-dev/Source/ThirdParty/Mac
147162

163+
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
164+
with:
165+
name: Mac-native-sdk
166+
path: plugin-dev/Source/ThirdParty/Mac/Native
167+
148168
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
149169
with:
150170
name: Linux-crashpad-sdk
@@ -205,6 +225,11 @@ jobs:
205225
name: CrashReporter-LinuxArm64
206226
path: plugin-dev/Source/ThirdParty/LinuxArm64
207227

228+
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
229+
with:
230+
name: CrashReporter-Mac
231+
path: plugin-dev/Source/ThirdParty/Mac
232+
208233
# Workaround for https://github.com/actions/download-artifact/issues/14
209234
# Adding execute permission for crashpad before preparing final packages
210235
# allows to avoid issues with plugin initialization on Unix-based systems.
@@ -217,6 +242,8 @@ jobs:
217242
chmod +x plugin-dev/Source/ThirdParty/LinuxArm64/Crashpad/bin/crashpad_handler
218243
chmod +x plugin-dev/Source/ThirdParty/LinuxArm64/Native/bin/sentry-crash
219244
chmod +x plugin-dev/Source/ThirdParty/LinuxArm64/Sentry.CrashReporter
245+
chmod +x plugin-dev/Source/ThirdParty/Mac/Native/bin/sentry-crash
246+
chmod +x plugin-dev/Source/ThirdParty/Mac/Sentry.CrashReporter
220247
221248
- name: Prepare Sentry packages for release
222249
shell: pwsh

.github/workflows/sdk-download.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
target:
88
required: true
99
type: string
10+
backend:
11+
required: false
12+
type: string
13+
default: ""
1014

1115
jobs:
1216
download:
@@ -22,6 +26,7 @@ jobs:
2226
id: env
2327
env:
2428
TARGET: ${{ inputs.target }}
29+
BACKEND: ${{ inputs.backend }}
2530
run: |
2631
if [[ "$TARGET" == "IOS" || "$TARGET" == "Mac" ]]; then
2732
echo "cacheLocation=modules/sentry-cocoa" >> $GITHUB_OUTPUT
@@ -30,6 +35,12 @@ jobs:
3035
fi
3136
echo "path=plugin-dev/Source/ThirdParty/$TARGET" >> $GITHUB_OUTPUT
3237
38+
if [[ -n "$BACKEND" ]]; then
39+
echo "artifactName=${TARGET}-${BACKEND}-sdk" >> $GITHUB_OUTPUT
40+
else
41+
echo "artifactName=${TARGET}-sdk" >> $GITHUB_OUTPUT
42+
fi
43+
3344
- uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
3445
id: cache
3546
with:
@@ -49,6 +60,6 @@ jobs:
4960
5061
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
5162
with:
52-
name: ${{ inputs.target }}-sdk
63+
name: ${{ steps.env.outputs.artifactName }}
5364
path: ${{ steps.env.outputs.path }}
5465
retention-days: ${{ github.ref_name == 'main' && 14 || 1 }}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Features
66

77
- Add out-of-process screenshot capturing on Windows ([#1325](https://github.com/getsentry/sentry-unreal/pull/1325))
8+
- Add native backend support for Mac ([#1333](https://github.com/getsentry/sentry-unreal/pull/1333))
89

910
### Fixes
1011

integration-test/Integration.Desktop.Tests.ps1

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@ BeforeDiscovery {
4343
# Detect native backend by checking which crash handler binary exists in the packaged build
4444
function Test-NativeBackend {
4545
$appDir = Split-Path $env:SENTRY_UNREAL_TEST_APP_PATH
46-
$pluginBinDir = Join-Path $appDir "SentryPlayground/Plugins/sentry/Binaries"
46+
if ($IsMacOS) {
47+
$pluginBinDir = Join-Path (Split-Path $appDir) "UE/SentryPlayground/Plugins/sentry/Binaries"
48+
} else {
49+
$pluginBinDir = Join-Path $appDir "SentryPlayground/Plugins/sentry/Binaries"
50+
}
4751
if ($IsWindows) {
4852
return Test-Path (Join-Path $pluginBinDir "Win64/sentry-crash.exe")
4953
} elseif ($IsLinux) {
5054
return Test-Path (Join-Path $pluginBinDir "Linux/sentry-crash")
55+
} elseif ($IsMacOS) {
56+
return Test-Path (Join-Path $pluginBinDir "Mac/sentry-crash")
5157
} else {
5258
return $false
5359
}
@@ -59,7 +65,7 @@ BeforeDiscovery {
5965
$currentPlatform | Should -Not -Be $null
6066
$TestTargets += Get-TestTarget -Platform $currentPlatform -ProviderName $currentPlatform
6167

62-
$IsNativeBackend = Test-NativeBackend
68+
$script:IsNativeBackend = Test-NativeBackend
6369

6470
# Define crash types to test
6571
$TestCrashTypes = @(
@@ -70,8 +76,8 @@ BeforeDiscovery {
7076
@{ Name = 'OutOfMemory'; Arg = '-crash-oom'; Type = 'OutOfMemory' }
7177
)
7278

73-
if ($IsLinux) {
74-
# Memory overcommit makes OOM conditions unreliable to trigger in tests on Linux
79+
if ($IsLinux -or ($IsMacOS -and $IsNativeBackend)) {
80+
# Memory overcommit makes OOM conditions unreliable to trigger in tests on Linux and macOS with native backend
7581
$TestCrashTypes = $TestCrashTypes | Where-Object { $_.Name -ne 'OutOfMemory' }
7682
}
7783
}
@@ -164,10 +170,11 @@ Describe "Sentry Unreal Desktop Integration Tests (<Platform>)" -ForEach $TestTa
164170
# $crashTypeArg triggers specific crash type scenario in the sample app
165171
$script:CrashResult = Invoke-DeviceApp -ExecutablePath $script:AppPath -Arguments ((@($crashTypeArg) + $appArgs) -join ' ')
166172

167-
# On macOS, the crash is captured but not uploaded immediately (due to Cocoa's behavior),
173+
# On macOS with Cocoa backend, the crash is captured but not uploaded immediately,
168174
# so we need to run the test app again to send it to Sentry.
169-
# -init-only allows starting the app to flush captured events and quit right after
170-
if ($Platform -eq 'MacOS') {
175+
# -init-only allows starting the app to flush captured events and quit right after.
176+
# With native backend, crashes are uploaded out-of-process so no relaunch is needed.
177+
if ($Platform -eq 'MacOS' -and -not $IsNativeBackend) {
171178
Invoke-DeviceApp -ExecutablePath $script:AppPath -Arguments ((@('-init-only') + $appArgs) -join ' ')
172179
}
173180

@@ -211,7 +218,7 @@ Describe "Sentry Unreal Desktop Integration Tests (<Platform>)" -ForEach $TestTa
211218

212219
It "Should have correct event type and platform" {
213220
$script:CrashEvent.type | Should -Be 'error'
214-
if ($Platform -eq 'MacOS') {
221+
if ($Platform -eq 'MacOS' -and -not $IsNativeBackend) {
215222
$script:CrashEvent.platform | Should -Be 'cocoa'
216223
}
217224
else {
@@ -242,7 +249,7 @@ Describe "Sentry Unreal Desktop Integration Tests (<Platform>)" -ForEach $TestTa
242249
($tags | Where-Object { $_.key -eq 'test.suite' }).value | Should -Be 'integration'
243250
}
244251

245-
It "Should have CrashType tag" -Skip:($Name -in @('OutOfMemory', 'MemoryCorruption') -or $Platform -eq 'MacOS') {
252+
It "Should have CrashType tag" -Skip:($Name -in @('OutOfMemory', 'MemoryCorruption') -or ($Platform -eq 'MacOS' -and -not $IsNativeBackend)) {
246253
$tags = $script:CrashEvent.tags
247254
($tags | Where-Object { $_.key -eq 'CrashType' }).value | Should -Be $Type
248255
}
@@ -331,7 +338,7 @@ Describe "Sentry Unreal Desktop Integration Tests (<Platform>)" -ForEach $TestTa
331338

332339
It "Should have correct event type and platform" {
333340
$script:EnsureEvent.type | Should -Be 'error'
334-
if ($Platform -eq 'MacOS') {
341+
if ($Platform -eq 'MacOS' -and -not $IsNativeBackend) {
335342
$script:EnsureEvent.platform | Should -Be 'cocoa'
336343
}
337344
else {
@@ -365,7 +372,7 @@ Describe "Sentry Unreal Desktop Integration Tests (<Platform>)" -ForEach $TestTa
365372
($tags | Where-Object { $_.key -eq 'test.suite' }).value | Should -Be 'integration'
366373
}
367374

368-
It "Should have CrashType tag" -Skip:($Platform -eq 'MacOS') {
375+
It "Should have CrashType tag" -Skip:($Platform -eq 'MacOS' -and -not $IsNativeBackend) {
369376
$tags = $script:EnsureEvent.tags
370377
($tags | Where-Object { $_.key -eq 'CrashType' }).value | Should -Be 'Ensure'
371378
}
@@ -538,7 +545,7 @@ Describe "Sentry Unreal Desktop Integration Tests (<Platform>)" -ForEach $TestTa
538545
}
539546

540547
It "Should have correct platform" {
541-
if ($Platform -eq 'MacOS') {
548+
if ($Platform -eq 'MacOS' -and -not $IsNativeBackend) {
542549
$script:MessageEvent.platform | Should -Be 'cocoa'
543550
}
544551
else {
@@ -551,7 +558,7 @@ Describe "Sentry Unreal Desktop Integration Tests (<Platform>)" -ForEach $TestTa
551558
$script:MessageEvent.message.formatted | Should -Match 'Integration test message'
552559
}
553560

554-
It "Should have overridden release" -Skip:($Platform -eq 'MacOS') {
561+
It "Should have overridden release" -Skip:($Platform -eq 'MacOS' -and -not $IsNativeBackend) {
555562
$script:MessageEvent.release.version | Should -Be 'test-release@1.0.0'
556563
}
557564

@@ -744,8 +751,8 @@ Describe "Sentry Unreal Desktop Integration Tests (<Platform>)" -ForEach $TestTa
744751
}
745752
}
746753

747-
# Metrics are not supported on Apple platforms (macOS/iOS)
748-
Context "Metrics Capture Tests" -Skip:$IsMacOS {
754+
# Metrics are not supported on macOS with Cocoa backend
755+
Context "Metrics Capture Tests" -Skip:($IsMacOS -and -not $IsNativeBackend) {
749756
BeforeAll {
750757
$script:MetricResult = $null
751758
$script:CapturedCounterMetrics = @()

plugin-dev/Source/Sentry/Private/Apple/AppleSentryAttachment.cpp

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

33
#include "AppleSentryAttachment.h"
44

5+
#if !USE_SENTRY_NATIVE
6+
57
#include "Infrastructure/AppleSentryConverters.h"
68

79
#include "Convenience/AppleSentryInclude.h"
@@ -50,3 +52,5 @@ FString FAppleSentryAttachment::GetContentType() const
5052
{
5153
return FString(AttachmentApple.contentType);
5254
}
55+
56+
#endif // !USE_SENTRY_NATIVE

plugin-dev/Source/Sentry/Private/Apple/AppleSentryAttachment.h

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

33
#pragma once
44

5+
#if !USE_SENTRY_NATIVE
6+
57
#include "Interface/SentryAttachmentInterface.h"
68

79
@class SentryAttachment;
@@ -25,3 +27,5 @@ class FAppleSentryAttachment : public ISentryAttachment
2527
};
2628

2729
typedef FAppleSentryAttachment FPlatformSentryAttachment;
30+
31+
#endif // !USE_SENTRY_NATIVE

plugin-dev/Source/Sentry/Private/Apple/AppleSentryBreadcrumb.cpp

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

33
#include "AppleSentryBreadcrumb.h"
44

5+
#if !USE_SENTRY_NATIVE
6+
57
#include "Infrastructure/AppleSentryConverters.h"
68

79
#include "Convenience/AppleSentryInclude.h"
@@ -76,3 +78,5 @@ ESentryLevel FAppleSentryBreadcrumb::GetLevel() const
7678
{
7779
return FAppleSentryConverters::SentryLevelToUnreal(BreadcrumbApple.level);
7880
}
81+
82+
#endif // !USE_SENTRY_NATIVE

plugin-dev/Source/Sentry/Private/Apple/AppleSentryBreadcrumb.h

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

33
#pragma once
44

5+
#if !USE_SENTRY_NATIVE
6+
57
#include "Interface/SentryBreadcrumbInterface.h"
68

79
@class SentryBreadcrumb;
@@ -31,3 +33,5 @@ class FAppleSentryBreadcrumb : public ISentryBreadcrumb
3133
};
3234

3335
typedef FAppleSentryBreadcrumb FPlatformSentryBreadcrumb;
36+
37+
#endif // !USE_SENTRY_NATIVE

plugin-dev/Source/Sentry/Private/Apple/AppleSentryEvent.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Copyright (c) 2025 Sentry. All Rights Reserved.
22

33
#include "AppleSentryEvent.h"
4+
5+
#if !USE_SENTRY_NATIVE
6+
47
#include "AppleSentryId.h"
58

69
#include "Infrastructure/AppleSentryConverters.h"
@@ -212,3 +215,5 @@ bool FAppleSentryEvent::IsAnr() const
212215

213216
return isErrorLevel && isAppHangException && isAppHangMechanism && isAppHangMessage;
214217
}
218+
219+
#endif // !USE_SENTRY_NATIVE

plugin-dev/Source/Sentry/Private/Apple/AppleSentryEvent.h

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

33
#pragma once
44

5+
#if !USE_SENTRY_NATIVE
6+
57
#include "Interface/SentryEventInterface.h"
68

79
@class SentryEvent;
@@ -46,3 +48,5 @@ class FAppleSentryEvent : public ISentryEvent
4648
};
4749

4850
typedef FAppleSentryEvent FPlatformSentryEvent;
51+
52+
#endif // !USE_SENTRY_NATIVE

0 commit comments

Comments
 (0)