Skip to content

fix: overlay hangup - #205

Merged
ArthurKun21 merged 3 commits into
masterfrom
fix/overlay-hangup
Sep 1, 2026
Merged

fix: overlay hangup#205
ArthurKun21 merged 3 commits into
masterfrom
fix/overlay-hangup

Conversation

@ArthurKun21

Copy link
Copy Markdown
Owner

No description provided.

Two independent root causes produced frozen overlay UIs:

1. The recomposer was created with View.createLifecycleAwareWindowRecomposer,
   which cancels the recomposer the moment its view detaches (its contract
   treats detach as permanent destruction). hide() detaches the ComposeView
   after its fade-out, so the first hide()/show() cycle left the composition
   on a dead recomposer and recomposition never ran again.

   Replace it with a window-owned recomposer that survives WindowManager
   detach/reattach cycles: its runner is launched into the window's
   lifecycle scope and cancelled only when content is replaced or the
   window is closed. The composition frame clock is paused while the
   window is stopped and resumed while started, mirroring androidx, and
   the recomposer honors the system animator duration scale.

2. Overlay windows added through WindowManager.addView are software-
   rendered by default (only Activity windows inherit hardware
   acceleration from the theme). On recent Compose versions, RenderNode-
   backed layers in a software-rendered window can leave recomposed
   content stale on screen until something forces a window traversal
   such as updateViewLayout during a drag. Request
   FLAG_HARDWARE_ACCELERATED in the default layout parameters.

Additionally:
- Advance the window lifecycle to RESUMED while shown and the screen is
  interactive so repeatOnLifecycle(RESUMED) and
  collectAsStateWithLifecycle(RESUMED) collect inside the overlay;
  pause lifecycle-aware work while the screen is off via a
  SCREEN_ON/OFF receiver.
- Fix the show-during-hide race where the fade-out end action detached a
  view that show() had just reused, and reset stale frame callbacks.
- Only clamp coordinates for top-start gravity in onSizeChanged.
- Add instrumented regression tests for recomposition after hide/show,
  show-during-hide attachment and layout reapplication, lifecycle
  reaching RESUMED, and animator duration scale observation.
@ArthurKun21
ArthurKun21 marked this pull request as ready for review September 1, 2026 18:57
@ArthurKun21
ArthurKun21 merged commit d900380 into master Sep 1, 2026
5 checks passed
@ArthurKun21
ArthurKun21 deleted the fix/overlay-hangup branch September 1, 2026 18:58
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