[ios][expo go] don't set appearancePreferene to light when userInterfaceStyle is undefined #17071
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.
Reviewers
I'm not sure who to request a review from, but I got a GitHub suggestion to add @tsapeta, and I'm also adding @Kudo because I know he's knowledgeable about this native stuff.
Why
When a user has their iOS theme set to dark, but their Expo Go theme set to automatic, closing the app after launching an Expo app and going back to the Home UI results in the theme coming from the native side becoming "light". See the attached linear issue for a video reproduction and more details.
How
I dug in and realized that we're reading the manifest for a
userInterfaceStyle
, and if it's not defined, then we set the theme to light. This then gets passed in as asColorSchemeOverride
inRCTAppearance
, and can't be changed after this happens.By not setting "light" when the style is automatic/undefined, a
sColorSchemeOverride
doesn't get set, and this bug ceases to exist.This all seems to be triggered by the fact that iOS toggles the theme when you task switch/lock the phone to capture a themed screenshot: https://linear.app/expo/issue/ENG-4572#comment-dc7a8284
We used to have a workaround for this in RN Appearance, but RN upstream doesn't have it: expo/react-native-appearance@e1896d9
We can pick this change into our RN fork to prevent any potential flashes after a user locks their phone or they open up the app switcher.
Test Plan
Set your device theme to dark and your Expo Go theme to automatic. Launch a project, go back to Home using the dev menu, and lock your device. The theme when you unlock your device should still be dark.
Video repro:
Movie.Recording.mov
Checklist
expo build
(eg: updated@expo/xdl
).expo prebuild
& EAS Build (eg: updated a module plugin).