Skip to content

fix(game): tolerate a configuration change before the controller exists - #277

Merged
papi-ux merged 1 commit into
masterfrom
fix/portrait-launch-config-change
Sep 5, 2026
Merged

fix(game): tolerate a configuration change before the controller exists#277
papi-ux merged 1 commit into
masterfrom
fix/portrait-launch-config-change

Conversation

@papi-ux

@papi-ux papi-ux commented Sep 5, 2026

Copy link
Copy Markdown
Owner

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 onConfigurationChanged force-unwrapped controllerHandler (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.

  • Both sensor toggles in 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.
  • GameConfigurationChangeSourceGuardTest pins the two safe calls and forbids any controllerHandler!! in that function.
  • CHANGELOG Unreleased entry.

Exact candidate

Commit: cdfda3a137f80fc8cad8227e3635fbb0f2dbb1b6
Tree: 210ed4fcb8342d974f22856ab6e1f184eb5f2c1c
Parent: 4f50967a281385a0366650e76b0a5f528b85efcd
Base: 4f50967a281385a0366650e76b0a5f528b85efcd

Verification

  • GameConfigurationChangeSourceGuardTest: fails against master's Game.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: clean
  • Crash reproduced on the RP6 with the 1.4.2 release APK from portrait (FATAL EXCEPTION: main ... Game.onConfigurationChanged), and the same launch streams at 120 FPS in landscape

Not covered: a device run of this exact build from portrait; the full JVM suite and lint run in CI.

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.
@papi-ux
papi-ux merged commit bdee264 into master Sep 5, 2026
6 checks passed
@papi-ux
papi-ux deleted the fix/portrait-launch-config-change branch September 5, 2026 04:06
@papi-ux papi-ux mentioned this pull request Sep 5, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant