File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments