Skip to content

Fix transient stale layouts during window rotation - #68

Merged
Moriafly merged 1 commit into
mainfrom
fix/rotation-intermediate-frame
Oct 26, 2026
Merged

Moriafly merged 1 commit into
mainfrom
fix/rotation-intermediate-frame

Conversation

@Moriafly

Copy link
Copy Markdown
Owner

Rotating a window can draw the previous adaptive layout in the new window bounds before Compose recomposes. In SPA, the cover briefly shrinks or disappears before the player settles into the correct layout. This follows up on #66.

Record native window orientation changes until pre-draw, send pending snapshot apply notifications, and cancel that drawing pass so the next frame can recompose. The flag also covers changes first observed during global layout. Limit cancellation to orientation changes, and clear it when observation stops. The native size source and API < 33 compatibility scope remain the same.

Validation

  • Adaptive-window Android compilation and SPA Official Debug/Release builds passed, including the release R8 reflection check.
  • Actual draw diagnostics without a debugger: 20 rotations on API 30, 10 on API 31, and 20 on API 32 without observed mismatches. The original API 31 build drew stale layouts on all six observed rotations.
  • Passed View/ComposeView reattachment, zero-sized initialization, context rebasing, and controlled delayed-metrics recovery checks.
  • Passed 43 final native-window size assertions across fold/unfold and resize operations. These check settled dimensions, not every intermediate resize frame.
  • Compared actual SPA playback recordings before and after: the transient tiny-cover/empty-cover layout was no longer observed.

Runtime checks used temporary diagnostics outside tracked source. Confirmation on the reported Huawei Mate 40 Pro/EMUI 13 device is still pending.

Window metrics can change orientation after Compose has already laid out the
current frame. Track that transition until pre-draw, including changes first
observed during global layout, and cancel the stale drawing pass after sending
pending snapshot apply notifications so the next frame can recompose.

Restrict draw cancellation to orientation changes to preserve drawing during
same-orientation resizing. Route refresh and reattachment through the same
size update method, and clear the pending draw flag when observation stops.

Validation:
- Adaptive-window Android compilation and SPA Official Debug/Release builds
  passed, including the release R8 reflection check.
- Without a debugger, actual draw diagnostics passed 20 rotations on API 30,
  10 on API 31, and 20 on API 32 after the original API 31 build reproduced
  stale-layout draws on all six observed rotations.
- View/ComposeView reattachment, zero-sized initialization, context rebasing,
  and the existing controlled delayed-metrics recovery paths passed.
- Fold/unfold and resize checks passed 43 final native-window size assertions.
- SPA playback recordings no longer showed the transient tiny-cover layout
  seen before this change. Huawei Mate 40 Pro hardware verification is pending.
@Moriafly
Moriafly merged commit 41de153 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