Skip to content

Skip closing the Android and Cocoa SDKs without options - #2931

Draft
bitsandfoxes wants to merge 4 commits into
mainfrom
fix/native-close-null-options
Draft

bitsandfoxes wants to merge 4 commits into
mainfrom
fix/native-close-null-options

Conversation

@bitsandfoxes

Copy link
Copy Markdown
Contributor

On Android and iOS, the SDK no longer throws a NullReferenceException during startup when it can't load its options.

SentryInitialization closes the native SDK whenever the C# SDK doesn't initialize, and it passes along the options it loaded. When the options asset can't be loaded, for example when the configuration lives in an OBB file that isn't available yet, those options are null. SentryNativeAndroid.Close and SentryNativeCocoa.Close read native support settings from them and threw.

Both now return early on null options, as SentryNativeMacos.Close already did. The native SDK stays as it is, since there are no options saying whether it should be closed. All three Close methods now take SentryUnityOptions?.

Each Close gets an internal overload that takes the platform, as SentryNativeCocoa.Configure does. In the Editor, the platform check returns early without reading the options, so the tests pass Android or iPhone explicitly to reach the code that read them.

Tests: Close_OptionsNull_DoesNotCloseSentryJava (Android) and Close_OptionsNull_DoesNotThrow (Cocoa).

🤖 Generated with Claude Code

@bitsandfoxes bitsandfoxes reopened this Nov 4, 2026
@bitsandfoxes
bitsandfoxes force-pushed the fix/native-close-null-options branch from b72d090 to 330303d Compare November 4, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant