Skip to content

Commit ae71430

Browse files
Fix Adreno SIGSEGV: marshal SetSustainedPerformanceMode onto UI thread
The call in OsuGameAndroid.LoadComplete ran on the load thread, which made ViewRootImpl.checkThread() throw CalledFromWrongThreadException after the window state had already been partially mutated. On Adreno this invalidated the active VkSurfaceKHR and crashed the driver inside vkCmdBeginRendering on the next frame (SIGSEGV at vulkan.adreno.so +0x4, fault_addr=0x28). Wrap the call in gameActivity.RunOnUiThread(...) like every other Window mutator in this file already is. Agent-Logs-Url: https://github.com/winnerspiros/osu/sessions/f3d3c197-120b-4c7d-b2ef-fca9776d19d2 Co-authored-by: winnerspiros <1675249+winnerspiros@users.noreply.github.com>
1 parent 4d73c09 commit ae71430

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

osu.Android/OsuGameAndroid.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,29 @@ protected override void LoadComplete()
267267

268268
// Always enable sustained performance mode for consistent frame delivery.
269269
// This prevents thermal throttling from causing sudden FPS drops.
270-
try { gameActivity.Window?.SetSustainedPerformanceMode(true); }
271-
catch { }
270+
//
271+
// This MUST run on the Android UI thread: SetSustainedPerformanceMode mutates
272+
// window state through ViewRootImpl, which enforces single-threaded access via
273+
// checkThread() and throws CalledFromWrongThreadException otherwise. On some
274+
// OEM frameworks (observed on Samsung One UI / Adreno) that exception unwinds
275+
// through setPrivateFlags after the underlying Surface has already been
276+
// partially reconfigured, invalidating the active VkSurfaceKHR and crashing the
277+
// Vulkan driver inside vkCmdBeginRendering on the next frame.
278+
try
279+
{
280+
gameActivity.RunOnUiThread(() =>
281+
{
282+
try { gameActivity.Window?.SetSustainedPerformanceMode(true); }
283+
catch (Exception e)
284+
{
285+
Debug.WriteLine($"[osu!] Failed to enable sustained performance mode: {e.Message}");
286+
}
287+
});
288+
}
289+
catch (Exception e)
290+
{
291+
Debug.WriteLine($"[osu!] Failed to dispatch sustained performance mode toggle to UI thread: {e.Message}");
292+
}
272293

273294
base.LoadComplete();
274295

0 commit comments

Comments
 (0)