fix: prevent ComposeUiClusterRenderer crash on fast back gesture with compose-ui 1.10+#930
Draft
kikoso wants to merge 1 commit into
Draft
fix: prevent ComposeUiClusterRenderer crash on fast back gesture with compose-ui 1.10+#930kikoso wants to merge 1 commit into
kikoso wants to merge 1 commit into
Conversation
… compose-ui 1.10+ Addresses issue #875: IllegalStateException "Composed into the View which doesn't propagate ViewTreeLifecycleOwner!" when navigating back while DefaultClusterRenderer's MarkerModifier handler is still processing. - Add scope.isActive guards in getDescriptorForCluster and onBeforeClusterItemRendered so that after the Compose scope is cancelled (e.g. on back navigation), render callbacks fall through to the default super implementation instead of attempting to create new ComposeViews with a disposed CompositionContext. - Set ViewTreeSavedStateRegistryOwner alongside ViewTreeLifecycleOwner on off-screen views for full compose-ui 1.10+ compatibility.
Contributor
Code Coverage
|
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.
Fixes #875
Summary
DefaultClusterRenderer'sMarkerModifieruses an AndroidHandlerqueue that continues processing render tasks after the Compose scope is cancelled (e.g. fast back gesture). When a newComposeViewis created at that point, it attempts composition using an already-disposedCompositionContext, triggering the crash.ViewTreeLifecycleOwnerfix shipped in v8.3.0 addressed the static case (no lifecycle owner on detached views) but not this dynamic teardown case.Changes
scope.isActiveguard at the top ofgetDescriptorForClusterandonBeforeClusterItemRendered. When the coroutine scope is cancelled, these methods fall through to the defaultsuperimplementation (standard Google Maps rendering) instead of creating new off-screenComposeViews with a stale/disposedCompositionContext.ViewTreeSavedStateRegistryOwneralongside the existingViewTreeLifecycleOwneron off-screen views, providing full compose-ui 1.10+ compatibility for cluster content that usesrememberSaveableor other saved-state APIs.Test plan
Clustering()using customclusterContent/clusterItemContentand many markers (soMarkerModifieris still actively rendering)