fix(game): tolerate a configuration change before the controller exists - #277
Merged
Conversation
Launching a stream with the device held in portrait rotates the Game activity to landscape while the connection is still being established, and onConfigurationChanged then reached controllerHandler through a force-unwrap before the connection had created it. Nova crashed on the main thread with a NullPointerException at Game.kt:2310 before a single frame arrived. Both sensor toggles in that path now use safe calls; the handler enables its sensors itself once it exists. A source guard pins the two safe calls and forbids a force-unwrap anywhere in that function. Found on the Retroid Pocket 6 while smoking the 1.4.2 release APK; the code predates 1.4.1 and is not a regression.
4 tasks
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.
Summary
Nova crashes on the main thread when a stream is started with the device held in portrait. The Game activity rotates to landscape while the connection is still being established, and
onConfigurationChangedforce-unwrappedcontrollerHandler(Game.kt:2310,controllerHandler!!.enableSensors()in the not-in-PiP branch) before the connection had created it. Found on the Retroid Pocket 6 while smoking the published 1.4.2 APK; the code dates from the July import, so 1.4.1 has it too and it is not a regression. Held sideways, the same launch streams normally.onConfigurationChanged(PiP entry and exit) use safe calls. The handler enables its own sensors when it is created, so nothing is lost when it does not exist yet.GameConfigurationChangeSourceGuardTestpins the two safe calls and forbids anycontrollerHandler!!in that function.Exact candidate
Commit:cdfda3a137f80fc8cad8227e3635fbb0f2dbb1b6Tree:210ed4fcb8342d974f22856ab6e1f184eb5f2c1cParent:4f50967a281385a0366650e76b0a5f528b85efcdBase:4f50967a281385a0366650e76b0a5f528b85efcdVerification
GameConfigurationChangeSourceGuardTest: fails against master'sGame.kt(force-unwrap present), passes with this change (JUnit report on disk)bash scripts/check-public-docs.sh,bash scripts/check-public-surface.sh,git diff --check: cleanFATAL EXCEPTION: main ... Game.onConfigurationChanged), and the same launch streams at 120 FPS in landscapeNot covered: a device run of this exact build from portrait; the full JVM suite and lint run in CI.