Skip to content

fix(android): fix Atmosphere NPE on no-props and wrong removeFromMap#4173

Closed
mfazekas wants to merge 1 commit intomainfrom
repro/atmosphere-null-reactstyle
Closed

fix(android): fix Atmosphere NPE on no-props and wrong removeFromMap#4173
mfazekas wants to merge 1 commit intomainfrom
repro/atmosphere-null-reactstyle

Conversation

@mfazekas
Copy link
Contributor

Summary

Two bugs fixed in RNMBXAtmosphere.kt on Android:

  • NPE in addStyles() when <Atmosphere /> has no propsmReactStyle!! throws NullPointerException because setReactStyle() is never called (no props = no call), while addToMap() still calls addStyles(). Replaced !! force-unwraps with safe null early-returns. This subsumes the fix in PR fix: prevent NullPointerException in RNMBXAtmosphere.addStyles() #4171.
  • removeFromMap() called removeTerrain() instead of removeAtmosphere() — a copy-paste bug causing terrain to disappear when toggling <Atmosphere> off, while the atmosphere itself stayed. Also clears mAtmosphere on removal for clean state.

Also adds atmosphere toggle + color cycling buttons to TerrainSkyAtmosphere and QueryTerrainElevation examples to make the behavior easy to test, and updates BugReportExampleTS with the race repro from PR #4171.

Test plan

  • Run TerrainSkyAtmosphere on Android — toggle atmosphere on/off, confirm atmosphere (not terrain) disappears
  • Cycle atmosphere colors — confirm color changes visibly
  • Run BugReportExampleTS on Android — confirm no crash on load, remount works
  • Verify terrain remains unaffected when toggling atmosphere

🤖 Generated with Claude Code

Two bugs fixed in RNMBXAtmosphere:

1. NPE in addStyles() when <Atmosphere /> is used with no props —
   mReactStyle!! throws NullPointerException because setReactStyle()
   is never called before addToMap(). Replaced !! with safe null
   early-returns. (related to PR #4171)

2. removeFromMap() was calling removeTerrain() instead of
   removeAtmosphere() (copy-paste bug), causing terrain to disappear
   when toggling Atmosphere off while the atmosphere itself stayed.
   Also now nulls mAtmosphere on removal for clean state.

Also adds atmosphere toggle + color cycling to TerrainSkyAtmosphere
and QueryTerrainElevation examples, and updates BugReportExampleTS
with the AtmosphereRaceRepro test case from PR #4171.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mfazekas mfazekas closed this Mar 15, 2026
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