Skip to content

Fix stale adaptive window metrics after delayed bounds updates - #66

Merged
Moriafly merged 1 commit into
mainfrom
fix/window-metrics-layout-refresh
Oct 26, 2026
Merged

Moriafly merged 1 commit into
mainfrom
fix/window-metrics-layout-refresh

Conversation

@Moriafly

Copy link
Copy Markdown
Owner

After rotation, the pending configuration update can be consumed before the native window bounds change. The adaptive window cache can then retain portrait dimensions inside a landscape window, leaving applications in the wrong layout. This follows up on #64.

Changes

  • Track root geometry and the Resources Configuration used by WindowMetrics independently of configuration callbacks.
  • Refresh during pre-draw when bounds arrive after the final global-layout callback.
  • Keep native WindowMetrics as the size source, resolve the current supported Context for each refresh, and register/remove both listeners together across View attachment changes.
  • Preserve the existing API < 33 compatibility path. Unchanged frames only compare cached inputs.

Validation

  • SaltUI :salt-adaptive-window:check and the SPA debug build passed; all 438 existing SPA unit tests passed.
  • Controlled callback/source-lag scenarios passed on API 30, 31 and 32 emulator windows, comparing cached dimensions with native WindowMetrics.
  • Same-View lifecycle checks covered an initial zero-sized root, detach/rotate/reattach, ComposeView reattachment, and MutableContextWrapper rebasing to another Activity after detach.
  • Actual fold/unfold, rotation and extreme display sizes passed 43 target-size checks. Folding was verified to change the native display from 1768×2208 to 884×2208 pixels.
  • SPA's normal Overview/split-screen/drag-to-exit/rotation path passed 52 native/cache observations without crashes.
  • Stable-frame diagnostics observed zero native metric reads across 140 sampled frames. Without a debugger, ABBA scrolling comparisons had the same P90/P95 values of 18/19 ms; display-resize measurements were noisy.

Runtime validation used temporary diagnostic hosts and real platform input; no new automated UI test sources were added. The controlled reproductions demonstrate cache invalidation holes, while confirmation on the reported Huawei Mate 40 Pro/EMUI 13 hardware remains pending.

Invalidate the size cache when root geometry or the Resources Configuration
used by WindowMetrics changes, in addition to the pending configuration flag.
Observe pre-draw so bounds arriving after the final global-layout callback
can refresh the cached size.

Keep native WindowMetrics as the size source and resolve the current supported
Context for each refresh. Register and remove both layout listeners together
across View detach and reattach. Unchanged frames do not query native metrics.

Validation:
- SaltUI adaptive-window checks and SPA debug build succeeded; all 438 existing
  SPA unit tests passed.
- Controlled callback/source-lag scenarios and same-View attachment lifecycle
  checks passed on API 30, 31 and 32 emulator windows.
- Real fold/unfold, rotation and extreme display sizes passed 43 target-size
  checks. SPA's normal split-screen exit and rotation passed 52 size checks
  without crashes.
- Without a debugger, ABBA scrolling comparisons had identical P90/P95 values
  of 18/19 ms. Display-resize measurements showed substantial emulator noise.
- Huawei Mate 40 Pro hardware confirmation remains outstanding.
@Moriafly

Copy link
Copy Markdown
Owner Author

用户已验证 HUAWEI Mate 40 Pro EMUI 13 Android 12 修复

@Moriafly
Moriafly merged commit 3471be3 into main Oct 26, 2026
3 checks passed
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.

1 participant