You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Programmatic Configuration and Native Support on Mobile
Background
The SDKs current approach let's the native SDKs self-initialize when targeting mobile. This approach guarantees the SDK to capture all errors (even Unity engine crashes) but it also creates a lot of friction for users during onboarding and setup.
Having to explain the different layers is a non-trivial task.
Example:
A user wants to set the environment:
For that they have to implement both, the Runtime and the BuildTime configuration. Even with the unified approach of having only one configure callback, they are still limited to setting a static string and are not able to compute the value at runtime. That limitation has to somehow be explained again.
Current State
The Unity SDK currently handles native support differently across platforms:
Mobile Platforms (Android, iOS)
Current Implementation: Native SDKs self-initialize outside Unity runtime
Mechanism: Configured through Gradle (Android) and Xcode (iOS) project modifications
Advantages:
Can capture Unity crashes
Challenges:
Configuration gets "baked" into the project at build time
Complex configuration layers confuse users.
Inconsistent runtime/build time configuration patterns even with the unified configure callback
Desktop Platforms (Windows/Linux/macOS)
Current Implementation: Native SDKs initialize within Unity runtime
Behavior: Uses Configure callback consistently across C# Unity SDK and native layers. The options at the end of Configure are the ones that initialize the native layer
Proposed Solution
1. Unified Configuration API (mostly done already)
Replace separate Runtime/BuildTime configuration with single Configure method
Instead of handling filecopy ourselves we can mark .framework for targeting iOS.
Unity will handle that for us since we'll never know whether we'll need it. The SDK can and will be initialized during runtime.
We will have to rely on the already built Xcode setup functionality to copy the framework and bridge. Unty does not recognize .xcframework on versions 2020 and older.
Initialization:
Use native bridge for SDK initialization. We've already got a working example for macOS.
We can rely on the Cocoa SDK's isEnabled property to avoid reinitialization.
Android Implementation
Package handling:
Instead of handling filecopy ourselves we can mark the .jar and `.aar for targeting Android.
Unity handles file copying automatically. We can drop parts of the Gradle modifications.
Initialization:
Leverage Unity Java wrapper
We'll have to check on the scope sync to extend this to the Init call
We can rely on the Android SDK's isEnabled property to avoid reinitialization.
3. Mobile Platform Auto-Initialization
Convert current auto-initialization to opt-in feature. This way we maintain crash capture capabilities for users who need it.
4. Future Enhancement
Implement native callback support. I.e. enable code/snippet injection for native SDK events (e.g., BeforeSend)
Benefits
Simplified Configuration
Single, consistent configuration pattern
Eliminates confusion around runtime/build time configuration
Improved Initialization Flow
Consistent initialization across all platforms
Predictable option handling
Enhanced Flexibility
Optional auto-initialization for mobile platforms. So those users that need it can make the educated decision to work with/around the limitations
Better UaaL (Unity as a Library) support
Migration Path
We're going to have to make sure to let users know about the behavioural change. I.e. a popup notice during package update?
The text was updated successfully, but these errors were encountered:
We need to handle three distinct scenarios for native support:
Runtime: (Default) The native SDK will be set up in the Xcode/Gradle project but gets initialized by the C# layer
Native Standalone: The native SDK will be configured at build-time and auto-initializes
Disabled: This helps unblock users in case of UaaL or similar usecases where we cannot modify the generated project
Currently, this would require multiple boolean flags that are confusing and can create invalid combinations i.e.
IosNativeSupportEnabled: Checked at runtime whether the C# layer should initialize the native SDK
IosNativeStandaloneInit: Checked at build time whether the options should get baked into the Xcode project
IosDontModifyXcode?: To disable all native support?
Proposed Solution
Replace multiple flags with a single enum:
// If false, do not modify the Xcode/Gradle project. If set to `false` at build time but `true` at runtime // we can check whether we can find the native SDK and log a configuration error.publicboolIsNativeSupportEnabled=true;// Default: RuntimepublicenumNativeInitializationType{Runtime,// Copy the native SDK, allow runtime configuration, initialize through the C# layerBuildTime,// Copy the native SDK, bake options into the project, set up auto-init outside of Unity// UaaL, // (For the future) Don't copy the SDK but attempt to sync scope with the surrounding native SDK}
This:
Makes the available options explicit and mutually exclusive
We'd need to put some checks in place to not attempt to init if there is no native SDK. I.e. the NoOp bridge should get a method to validate the setup.
I think this separates build-time from runtime behavior. Users have to opt-in the advanced behaviour. And we stay forward compatible with additional usecases (UaaL).
Eliminates invalid configuration combinations. I.e. DontModifyProject = true and at runtime the NativeSupport = true.?
Programmatic Configuration and Native Support on
Mobile
Background
The SDKs current approach let's the native SDKs self-initialize when targeting
mobile
. This approach guarantees the SDK to capture all errors (even Unity engine crashes) but it also creates a lot of friction for users during onboarding and setup.Having to explain the different layers is a non-trivial task.
Example:
For that they have to implement both, the Runtime and the BuildTime configuration. Even with the unified approach of having only one configure callback, they are still limited to setting a static
string
and are not able to compute the value at runtime. That limitation has to somehow be explained again.Current State
The Unity SDK currently handles native support differently across platforms:
Mobile Platforms (Android, iOS)
Desktop Platforms (Windows/Linux/macOS)
Configure
are the ones that initialize the native layerProposed Solution
1. Unified Configuration API (mostly done already)
Configure
methodOptionConfiguration
to replaceRuntime/BuildTime
#1888: Implement unified scriptable object for configuration callback2. Unified SDK Initialization
iOS Implementation
Instead of handling filecopy ourselves we can mark.framework
for targeting iOS.Unity will handle that for us since we'll never know whether we'll need it. The SDK can and will be initialized during runtime..xcframework
on versions 2020 and older.isEnabled
property to avoid reinitialization.Android Implementation
.jar
and `.aar for targeting Android.Init
callisEnabled
property to avoid reinitialization.3. Mobile Platform Auto-Initialization
Convert current auto-initialization to opt-in feature. This way we maintain crash capture capabilities for users who need it.
4. Future Enhancement
Implement native callback support. I.e. enable code/snippet injection for native SDK events (e.g.,
BeforeSend
)Benefits
Simplified Configuration
Improved Initialization Flow
Enhanced Flexibility
Migration Path
We're going to have to make sure to let users know about the behavioural change. I.e. a popup notice during package update?
The text was updated successfully, but these errors were encountered: