Skip to content

Commit 2642851

Browse files
Fix Android startup crash: don't take OsuConfigManager as BDL param in OsuGameAndroid
OsuConfigManager is cached by OsuGameBase.load into the child dependency container (via dependencies.CacheAs(LocalConfig) on the container returned by CreateChildDependencies). The dependency activator, however, resolves BDL parameters from the parent container passed to InjectDependencies, so requesting OsuConfigManager as a parameter throws DependencyNotRegisteredException before the BDL method body runs - crashing the APK on launch. Use the inherited OsuGameBase.LocalConfig field instead. SetHost creates it before any BDL runs, so it is guaranteed non-null at this point. Agent-Logs-Url: https://github.com/winnerspiros/osu/sessions/81483282-2d9a-4cc8-a6a6-ef10f6020f42 Co-authored-by: winnerspiros <1675249+winnerspiros@users.noreply.github.com>
1 parent 476c398 commit 2642851

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

osu.Android/OsuGameAndroid.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,18 @@ public override Version AssemblyVersion
152152
/// to drive <see cref="applyAndroidFrameSyncMigrationOnce"/>, the one-shot Android
153153
/// FrameSync default migration; everything else here is unrelated init wiring.
154154
/// </summary>
155+
/// <remarks>
156+
/// We must NOT take <see cref="OsuConfigManager"/> as a BDL parameter here. The
157+
/// dependency activator resolves BDL parameters from the parent dependency
158+
/// container, but <see cref="OsuGameBase.load"/> caches <c>LocalConfig</c> into
159+
/// the child container (the one returned from <c>CreateChildDependencies</c>).
160+
/// Resolving <c>OsuConfigManager</c> as a parameter therefore throws
161+
/// <c>DependencyNotRegisteredException</c> before this method body even runs.
162+
/// Use the inherited <see cref="OsuGameBase.LocalConfig"/> field instead — it is
163+
/// guaranteed to be non-null because <c>SetHost</c> creates it before any BDL.
164+
/// </remarks>
155165
[BackgroundDependencyLoader]
156-
private void load(FrameworkConfigManager frameworkConfig, OsuConfigManager osuConfig)
166+
private void load(FrameworkConfigManager frameworkConfig)
157167
{
158168
LocalConfig.BindWith(OsuSetting.AndroidPerformanceMode, performanceMode);
159169
LocalConfig.BindWith(OsuSetting.AndroidLowLatencyAudio, lowLatencyAudio);
@@ -171,9 +181,9 @@ private void load(FrameworkConfigManager frameworkConfig, OsuConfigManager osuCo
171181
// AndroidStartupFlags in the activity.
172182
try
173183
{
174-
osuConfig.BindWith(OsuSetting.AndroidCleanupStaleRealmFifos, cleanupStaleRealmFifos);
175-
osuConfig.BindWith(OsuSetting.AndroidDeferStartupNativeInit, deferStartupNativeInit);
176-
osuConfig.BindWith(OsuSetting.AndroidStartupFrameSyncMigrationEnabled, startupFrameSyncMigrationEnabled);
184+
LocalConfig.BindWith(OsuSetting.AndroidCleanupStaleRealmFifos, cleanupStaleRealmFifos);
185+
LocalConfig.BindWith(OsuSetting.AndroidDeferStartupNativeInit, deferStartupNativeInit);
186+
LocalConfig.BindWith(OsuSetting.AndroidStartupFrameSyncMigrationEnabled, startupFrameSyncMigrationEnabled);
177187

178188
// sentinelOnDisable=true → presence ⇒ "feature disabled". The
179189
// safety nets default to ON, so the sentinel is created only

0 commit comments

Comments
 (0)