Skip to content

Cocoa: Apple native-client update - #303

Merged
melekr merged 6 commits into
masterfrom
cocoa/apple_native_client
Sep 16, 2026
Merged

melekr merged 6 commits into
masterfrom
cocoa/apple_native_client

Conversation

@melekr

@melekr melekr commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Integrate Cocoa 2.2.0 across Unity's Apple native clients

Summary

Update Backtrace Unity to backtrace-cocoa ver. 2.2.0, fix macOS native pending-report isolation, and use one managed interop/lifecycle implementation for macOS and iOS.

Why

The previous macOS integration used PLCrashReporter's default pending-report namespace, which Unity also inspects during startup. Backtrace reports could be consumed before the SDK initialized. The affected Unity 6000.3 reproduction could also crash during relaunch in CrashReporting::CrashReporter::CheckPendingNativeCrash.

The old macOS plugin additionally depended on symlinks in a nested versioned framework. The new plugin is a flat, self-contained universal bundle.

The iOS update consumes the dedicated device/simulator Cocoa XCFrameworks and brings the managed/native boundary under the same explicit allocation and lifecycle rules, while preserving the existing iOS pending-report path and OOM Light behavior.

Implementation

Shared managed Apple integration

  • Use AppleNativeBridge, AppleNativeSession, and AppleNativeClient. Retain the platform-specific factories and small macOS/iOS adapters.
  • Require ABI V3, explicit UTF-8 argument allocations, Cdecl, and one-byte C Boolean marshalling.
  • Propagate ReportPerMin, including 0 for unlimited native admission.
  • Release native GetAttributes memory through native FreeAttributes, including failure paths; do not free native-owned allocations with the managed allocator.
  • Initialize native capture independently of the managed offline database.
  • Do not construct a cached inert wrapper when capture is initially disabled.
  • Retain an existing owner across repeated Refresh() calls.
  • Coordinate admitted operations and shutdown without replacing a potentially installed process-wide fatal handler.
  • Preserve watchdog heartbeat/ANR behavior and restore crash classification after a native ANR attempt.

macOS

  • Replace the old nested framework with the approved flat arm64/x86_64 BacktraceMacUnity.bundle.
  • Retain the BTUnity-prefixed PLCrashReporter implementation, Foundation-derived private payload base, and cooperative capture lease.
  • Keep the capture lease for the process lifetime once handler installation may have occurred. A second cooperating same-ID process does not take over that native capture slot; managed reporting remains independent.
  • Does NOT add a runtime shared-cache rename/restore callback or automatic legacy migration. Existing old shared-cache payloads require the separate controlled prelaunch recovery procedure when applicable.

iOS

  • Replace both iOS XCFramework trees with the approved dedicated device/simulator archive, preserving the native bytes, importer GUIDs, resources and included debug symbols.
  • Add a result-returning local V3 Objective-C++ bridge and retain the previously shipped void startup export for older callers.
  • Preserve the existing PLCrashReporter storage path and OOM Light mode; do not copy the macOS path/lease policy to iOS.
  • Allocate and free returned attribute entries safely, including partial allocation failure.
  • Retain the reporter once process-wide handler installation may have begun. Native shutdown runs outside the bridge state monitor.
  • Compile only the bridge source with -fobjc-arc -fobjc-exceptions -fno-autolink.

iOS Xcode integration

  • Retain one required postprocessor. Link the dynamic Backtrace framework to UnityFramework and embed it in the application.
  • Use SDK-specific CrashReporter headers without linking or embedding a second static PLCrashReporter copy.
  • Normalize only SDK-owned link/embed entries on repeated processing.
  • Preserve host runpaths, including quoted paths and app-only configurations.
  • Package static-runtime privacy declarations and attribution separately, without modifying the host application's privacy manifest.
  • Resolve attribution resources from Assets or PackageCache using the preserved source-asset GUID.
  • Reject an iOS app minimum below 15.0 instead of silently raising it.

Packaging, tooling and tests

  • Preserve existing native importer identities and signed source bytes. The Mac importer disables Editor loading and preloading as part of this integration.
  • Keep direct Apple native-artifact and package validation in CI.
  • Retain existing platform coverage and add real macOS Mono/IL2CPP builds and iOS IL2CPP device/ARM64 Simulator exports followed by Xcode compilation.
  • Add shared-runtime and iOS Editor integration regression tests. Run the Editor tests synchronously with the active iOS target before export in both existing modern iOS CI lanes, retain XML/logs even after failure and require all named cases to pass using the existing result checker.

ref: BT-7562
ref: BT-7522

- Use the backtrace-cocoa native artifacts and the shared V3 Apple bridge, UTF-8 allocation handling, and process-lifetime session ownership.
- Isolate new macOS pending reports with the flat universal plugin while preserving the existing iOS pending store and OOM Light behaviour.
- Initialize native capture independently of the managed offline database.
- Wire iOS framework linking, embedding, privacy resources, and bridge-only compiler flags without linking a second static PLCrashReporter runtime.
- Preserve native bytes, importer identities, and host project settings.
- Cover shared ownership, UTF-8 interop, shutdown, and repeated iOS postprocessing with focused runtime and Editor regression tests.
- Validate approved native inputs and the packaged artifact round trip.
- Build macOS Mono/IL2CPP players and compile device/ARM64 Simulator iOS exports with the explicit Apple toolchain configuration.
- Run iOS EditMode tests in the existing iOS build path, retain their XML and logs, and fail when required tests are absent or skipped.
- Preserve all existing non-Apple CI lanes and the generic result checker.
@melekr melekr self-assigned this Sep 15, 2026
@melekr melekr added the enhancement New feature or request label Sep 15, 2026
- Append .app when GameCI supplies output basename without an an extension.
- Preserve direct .app paths and existing build validation.
- Select Test Framework 1.4.6 for Unity 2022.3 and 1.6.0 for Unity 6 so the iOS fixtures support SaveResultToFile.
- Queue build and test jobs sharing UNITY_SERIAL without cancelling pending matrix entries.
@melekr
melekr marked this pull request as ready for review September 16, 2026 01:14
@melekr
melekr merged commit 5c431b7 into master Sep 16, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant