Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Always update height to avoid races. #919

Merged
merged 1 commit into from
Apr 21, 2022

Conversation

elan
Copy link
Contributor

@elan elan commented Apr 20, 2022

Updating a shared values is an asynchronous operation, so if two layouts happen in quick succession, we can miss an update.

Please provide enough information so that others can review your pull request:

Motivation

On iOS devices, when backgrounding an app, the OS takes two screenshots (normal, and then rotated) so it can display thumbnail in the app switcher regardless of orientation. Apps see a rather confusing success of two screen rotations (and thus layouts).

What would happen is in some cases (it's a race), the container height would end up changing only once to the landscape height, so when you foregrounded the app again your displayed sheet would suddenly be cropped.

So here's the sheet showing properly (full screen player in Plexamp):

Simulator Screen Shot - iPad Pro (11-inch) (3rd generation) - 2022-04-20 at 10 59 40

After backgrounding and foregrounding, and missing a change to the shared value:

Simulator Screen Shot - iPad Pro (11-inch) (3rd generation) - 2022-04-20 at 11 00 11

Updating a shared values is an asynchronous operation, so if two layouts happen in quick succession, we can miss an update.
@elan
Copy link
Contributor Author

elan commented Apr 20, 2022

Quote from the Reanimated docs:

We can make updates to the state, but the updates are not immediate, and in order to read the data we need to wait till the next re-render.

@gorhom
Copy link
Owner

gorhom commented Apr 21, 2022

@elan thanks for spotting this issue and submitting a PR !

@gorhom gorhom merged commit 3245b23 into gorhom:master Apr 21, 2022
jakobo added a commit to jakobo/react-native-bottom-sheet that referenced this pull request Apr 22, 2022
…SheetBackdrop_defaults

* upstream/master:
  chore: updated react native portal library
  fix: always update container height to avoid races. (gorhom#919)(by @elan)
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.

None yet

2 participants