Marshal SetSustainedPerformanceMode onto the Android UI thread - #240
Merged
Merged
Conversation
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>
Copilot created this pull request from a session on behalf of
winnerspiros
April 22, 2026 14:49
View session
winnerspiros
marked this pull request as ready for review
April 22, 2026 15:01
There was a problem hiding this comment.
Pull request overview
Fixes an Android threading violation where Window.SetSustainedPerformanceMode(true) was being invoked off the UI thread during OsuGameAndroid.LoadComplete(), leading to CalledFromWrongThreadException and (on some devices) destabilising the active Vulkan surface.
Changes:
- Dispatch
SetSustainedPerformanceMode(true)viagameActivity.RunOnUiThread(...). - Add structured
try/catchhandling to preserve best-effort behaviour while avoiding unhandled exceptions. - Document the underlying Android
ViewRootImpl.checkThread()constraint and the observed Vulkan crash chain.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OsuGameAndroid.LoadCompleteinvokedWindow.SetSustainedPerformanceMode(true)from the load thread.ViewRootImpl.checkThread()threwCalledFromWrongThreadExceptionafter window private flags had already been partially mutated, leaving the activeVkSurfaceKHRpointing at freed driver state — the next frame crashed insideqglinternal::vkCmdBeginRendering(vulkan.adreno.so + 0x4,fault_addr=0x28), followed by an input-dispatch ANR.Changes
osu.Android/OsuGameAndroid.cs— wrap theSetSustainedPerformanceModecall ingameActivity.RunOnUiThread(...), matching the pattern already used by every otherWindow/Window.Attributesmutator in this file (applyPerformanceOptimizations,applyDeXImmersiveMode,applyDisplayMode,RequestUnbufferedDispatch). Outertry/catchguards the dispatch itself; innertry/catchpreserves the existing best-effort semantics.Notes
osu-frameworkchanges required; the offending call lives entirely in this repo.