Skip to content

Conversation

@alexvanyo
Copy link
Contributor

@alexvanyo alexvanyo commented Sep 24, 2021

Removes the subscription to currentWindowMetrics flow, in favor of always performing the synchronous calculation.

The currently released version of WindowManager (1.0.0-beta02) has an issue with currentWindowMetrics flow, where the new window metrics won't be properly propagated after a configuration change, if the activity is handling the configuration change.

This is reproducible with JetNews on Chrome OS, if the activity is adjusted to handle all configuration changes:
Resizing the window never propagates a new window metrics value, so the app doesn't change layouts.

This bug was fixed with a workaround, but this workaround uses an onLayoutChange listener, which means that the window metrics changes are delayed by a frame: they first need to be laid out at the new size, before the change is received. This can be reproduced by using the snapshot version of WindowManager, which results in the wrong window class being displayed for a frame.

Per a recommendation from @ianhanniballake, since there is a synchronous way to get the window metrics, we can bypass the WindowManager provided asynchronous flow and just call the synchronous getter directly guarded against a configuration change (which we were doing already for the initial value sine currentWindowMetrics is asynchronous).

This avoids both issues (with and without the workaround), and ends up being simpler as well, since we don't touch any Flows.

@alexvanyo alexvanyo merged commit 08d50d0 into ls Sep 27, 2021
@alexvanyo alexvanyo deleted the av/fix-currentWindowMetrics branch September 27, 2021 15:12
manuelvicnt pushed a commit that referenced this pull request Oct 13, 2021
* [Jetnews] Snackbars large screens support (#631) * [Jetnews] Add WindowSize breakpoints (#632) * [Jetnews] Add NavRail for large screens (#636) * Add initial large screen exploration * PR feedback and refine integration with navrail * Fix formatting and tests * Use rememberUpdatedState for notifyInput * Add remember for windowSize * [Jetnews] Interests screen LS support (#639) * [Jetnews] Large screen support for the Interests tab (#641) * [JetNews] Fix state saving with drawer (#653) * [JetNews] Fix state saving with drawer * Extract into rememberSizeAwareDrawerState * [JetNews] Convert navrail/drawer decision to use currentWindowMetrics (#654) * [JetNews] Convert navrail/drawer decision to use currentWindowMetrics * Move window metrics helpers to WindowSize.kt * [Jetnews] Better TopAppBar in large screens (#650) * [Jetnews] Move NavRail to top level component (#655) * [JetNews] Update window size breakpoints (#658) * [JetNews] Adjust medium behavior (#657) * [JetNews] Adjust medium behavior * Move column decision out of BoxWithConstraints * Follow my own rule for isDrawerActive * Update for PR feedback * Spotless apply * Add TODO for BoxWithConstraints usage * [JetNews] Replace currentWindowMetrics flow with synchronous calculation (#660) * [Jetnews] Consolidate compact and medium layouts (#659) * [Jetnews] Add space between NavRail icons (#663) * [Jetnews] Custom interests layout (#665) * [JetNews] Move window size calculation to activity level (#667) * [JetNews] Move window size calculation to activity level * Re-order WindowSize functions * Fix formatting * Merge main into ls (#672) * Implemented swipe to delete for Jetsnack cart * Replace logic for SwipeToDismiss composable Added Animated visibility as well * Requested adjustments * Removed Opt in * Spotless apply * PR fixes * Swipe to delete polish * Spotless * Removed unnecessary Row * Code polish * feat : improve UX by setting Button semantic role to play image button fix : fix not beeing able to move from CategoryPodcast to EpisodeList with Talkback feat: merge podcast category card with podcast title * Break long lines * Content to trailing lambda, added comments * Fix invalid neutral color #591 * [Jetnews] Showcase PreviewParameterProvider usage. * [Jetnews] Move PostPreviewParameterProvider.kt and add documentation * Fix kdoc format * [Jetsnack] Snackbar support (#645) * Finish checksum.sh sentence (#622) * [All] Update to Compose 1.0.2 * Spotless apply * [All] Revert to previous version of ktlint * [Jetsnack] Add state holder to JetsnackApp (#646) * fix : fixing formating issue * Update Compose Material Catalog AOSP link (#656) * [Crane] Use createEmptyComposeRule for test with injection * [All] Update to Compose 1.0.3 (#671) * [Jetnews] Update to Compose 1.1.0-alpha05 * [Jetnews] Spotless Co-authored-by: Angeles <angeles.bilbao6@gmail.com> Co-authored-by: DEMEY Fanny <fanny.pluvinage@gmail.com> Co-authored-by: Chris Sinco <csinco@google.com> Co-authored-by: Jolanda Verhoef <JolandaVerhoef@users.noreply.github.com> Co-authored-by: Jose Alcérreca <JoseAlcerreca@users.noreply.github.com> Co-authored-by: Alex Vanyo <vanyo@google.com> Co-authored-by: Nick Rout <nickrout@google.com> * [Jetcaster] Add tabletop posture support to the Player screen (#676) Co-authored-by: Alex Vanyo <vanyo@google.com> Co-authored-by: Angeles <angeles.bilbao6@gmail.com> Co-authored-by: DEMEY Fanny <fanny.pluvinage@gmail.com> Co-authored-by: Chris Sinco <csinco@google.com> Co-authored-by: Jolanda Verhoef <JolandaVerhoef@users.noreply.github.com> Co-authored-by: Jose Alcérreca <JoseAlcerreca@users.noreply.github.com> Co-authored-by: Nick Rout <nickrout@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4 participants