fix: Always update height to avoid races. #919
Merged
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.
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):
After backgrounding and foregrounding, and missing a change to the shared value: