fix: avoid zero-size crash in rememberComposeBitmapDescriptor when used inside Clustering - #963
Open
kikoso wants to merge 1 commit into
Open
fix: avoid zero-size crash in rememberComposeBitmapDescriptor when used inside Clustering#963kikoso wants to merge 1 commit into
kikoso wants to merge 1 commit into
Conversation
…ed inside Clustering rememberComposeBitmapDescriptor hosted its throwaway rendering ComposeView on LocalView.current, which can itself be mid-attach with no Android layout pass performed on it yet -- notably when this is called from content composed inside Clustering's clusterItemContent, whose InvalidatingComposeView is still being attached to its own parent at that point. That caused measure() to return a 0x0 size and throw IllegalStateException. Host the throwaway view on the window's root view instead, which is already laid out by the time any marker/cluster content is composed. setParentCompositionContext keeps the composition correctly scoped to the caller regardless of which Android View it's physically parented under, so this is safe. Fixes #694
kikoso
marked this pull request as ready for review
August 14, 2026 06:38
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.
Summary
rememberComposeBitmapDescriptorhosted its throwaway renderingComposeViewonLocalView.current, which can itself be mid-attach with no Android layout pass performed on it yet — this happens when the function is called from content composed insideClustering'sclusterItemContent, since theInvalidatingComposeViewhosting that content is still being attached to its own parent at that exact point.measure()returned a 0x0 size and the function threwIllegalStateException.setParentCompositionContextkeeps the composition correctly scoped to the caller regardless of which AndroidViewit's physically parented under, so this is safe.rememberComposeBitmapDescriptoritself. Nesting the fullMarkerComposable(not justrememberComposeBitmapDescriptor) insideClustering'sclusterItemContentis a separate, unsupported combination —MarkerComposablealso places aMarkernode viaMapApplier, which doesn't exist in that composition context, and will still throwIllegalStateException: Invalid applierregardless of this fix.Fixes #694
Test plan
testClusterItemContentUsingRememberComposeBitmapDescriptorDoesNotCrashtoGoogleMapViewClusteringTests, callingrememberComposeBitmapDescriptorfrom insideclusterItemContent— reproduces the crash pre-fix, passes post-fix.GoogleMapViewClusteringTestson a physical device (Pixel 4, API 33): all 3 tests pass.IllegalStateException: The ComposeView was measured to have a width or height of zero) and confirmed it no longer occurs after the fix.