Skip to content

Commit 9e25b69

Browse files
fix(android): remove uncompilable JNI constructor from OsuGameActivity
Agent-Logs-Url: https://github.com/winnerspiros/osu/sessions/0d2f18db-d838-47aa-910e-9b6755679bca Co-authored-by: winnerspiros <1675249+winnerspiros@users.noreply.github.com>
1 parent 3e87758 commit 9e25b69

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

osu.Android/OsuGameActivity.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ protected override osu.Framework.Game CreateGame()
9898
// The explicit SDL3-CS attribute roots SDLActivity(IntPtr, JniHandleOwnership) — the actual
9999
// overload TypeManager.Activate calls — which has NO managed call-graph path and would
100100
// otherwise be silently trimmed even if the parameterless constructor chain is preserved.
101-
// See also the OsuGameActivity(IntPtr, JniHandleOwnership) constructor below, which is the
102-
// direct fix for the v2026.509.229 crash: TypeManager.Activate needs this on the concrete type.
101+
// NOTE: A (IntPtr, JniHandleOwnership) constructor on OsuGameActivity itself is intentionally
102+
// omitted: AndroidGameActivity (C# class in osu.Framework.Android) does not declare this
103+
// constructor, so calling base(javaReference, transfer) would fail to compile. TypeManager
104+
// activates Activities via the parameterless constructor path in .NET Android; the actual
105+
// cause of the v2026.509.229 crash was base-class constructor trimming, which is prevented
106+
// by AndroidLinkSkip + the [DynamicDependency] attributes below.
103107
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors,
104108
"osu.Framework.Android.AndroidGameActivity", "osu.Framework.Android")]
105109
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors,
@@ -109,19 +113,6 @@ public OsuGameActivity()
109113
game = new OsuGameAndroid(this);
110114
}
111115

112-
// Required JNI activation constructor. TypeManager.Activate performs a reflection
113-
// lookup for (IntPtr, JniHandleOwnership) on the *concrete* managed type when Android
114-
// re-instantiates this Activity from a JNI handle (process death/recreation, back-stack
115-
// restore). Inheriting this constructor from AndroidGameActivity/SDLActivity is not
116-
// sufficient — .NET Android's TypeManager resolves it via GetConstructor on the concrete
117-
// type; if the method is absent there the lookup falls through and Activate throws
118-
// NotSupportedException ("Could not activate JNI Handle ... as managed type
119-
// 'osu.Android.OsuGameActivity'"), which is the crash seen in v2026.509.229.
120-
protected OsuGameActivity(IntPtr javaReference, JniHandleOwnership transfer)
121-
: base(javaReference, transfer)
122-
{
123-
}
124-
125116
protected override void OnCreate(Bundle? savedInstanceState)
126117
{
127118
// NOTE: do NOT assign RequestedOrientation here. The `[Activity]` attribute on this

0 commit comments

Comments
 (0)