Skip to content

Conversation

FiberJW
Copy link
Member

@FiberJW FiberJW commented Apr 14, 2022

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 a sColorSchemeOverride in RCTAppearance, 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

  • Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md).
  • This diff will work correctly for expo build (eg: updated @expo/xdl).
  • This diff will work correctly for expo prebuild & EAS Build (eg: updated a module plugin).

@FiberJW FiberJW added the Expo Go The client distributed on app stores label Apr 14, 2022
@FiberJW FiberJW requested review from Kudo and tsapeta April 14, 2022 23:04
@linear
Copy link

linear bot commented Apr 14, 2022

ENG-4572 Incorrect color scheme reported in Expo Go for iOS

From @FiberJW

I’ve run into an iOS React Native bug in Expo Go:
After launching a project, going back to Home, and locking your device (or sometimes opening the multitasking/recent apps view), the React native useColorScheme hook returns 'light' even when my system them is dark.
In the video below, the transition between dark and light is caused by me locking my iPad, but the recording doesn’t pick that up.
I can confirm this behavior through development logs.

7c2efefe-3549-4810-acc8-4fee17f27d91

@expo-bot expo-bot added the bot: passed checks ExpoBot has nothing to complain about label Apr 14, 2022
Copy link
Contributor

@tsapeta tsapeta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for fixing it! 🙏

Copy link
Contributor

@Kudo Kudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix. the change makes sense to me. i'm wondering for the flash issue. will further investigate how it happen and what we can do in our react-native fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: passed checks ExpoBot has nothing to complain about Expo Go The client distributed on app stores
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants