Repository navigation
Android: don't start the game thread twice when recreated during setup - #8
Merged
Merged
Conversation
On first launch the assets are copied in an AsyncTask. If the activity was recreated during the copy (for example by a dark mode or wallpaper colour change), onDestroy replaced the static NH_State and the new activity started a second copy. Both copies then called startNetHack on the new state, and the second Thread.start() threw IllegalThreadStateException, crashing the app. Each copy now remembers the NH_State it was started for and only starts the game if that state is still current. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes a crash on first launch, found while taking store screenshots in the emulator.
Cause. On first launch the assets are copied in an
AsyncTask. If the activity is recreated during the copy (for example by a dark mode or wallpaper colour change, which aren't inconfigChanges),onDestroyreplaces the staticNH_Stateand the new activity starts a second copy. Both copies then callstartNetHackon the new state, and the secondThread.start()throwsIllegalThreadStateException.Fix. Each copy remembers the
NH_Stateit was started for and only starts the game if that state is still current. The copies run serially (AsyncTask.execute), so they never write the files concurrently.Testing (Android 14 emulator,
pm clear, launch witham start -W, thencmd uimode night yesduring the copy):IllegalThreadStateExceptionatNetHackIO.start.gradlew build(with lint) passes.No version bump here, to avoid conflicting with #7 (
3.6.7-6).🤖 Generated with Claude Code