fix: overlay hangup - #205
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.