Skip to content

fix: avoid re-parenting crash for MarkerInfoWindowContent/MarkerInfoWindowComposable - #953

Open
kikoso wants to merge 1 commit into
mainfrom
fix/info-window-content-crash
Open

fix: avoid re-parenting crash for MarkerInfoWindowContent/MarkerInfoWindowComposable#953
kikoso wants to merge 1 commit into
mainfrom
fix/info-window-content-crash

Conversation

@kikoso

@kikoso kikoso commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Fixes #950

Summary

PR #931 fixed #913 (empty info window content on compose-ui 1.10+) by keeping the ComposeView permanently attached to the library's own container while the info window is shown. That works around compose-ui's attachment requirement for drawing, but it means the view handed back from getInfoContents()/getInfoWindow() already has a parent. The Maps SDK internally re-parents that view into its own default info window frame, so calling addView() on an already-parented view throws:

java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

This crash reproduces on device every time a MarkerInfoWindowContent marker is tapped, matching what is reported in #950.

Fix

Render the Compose content into a plain Bitmap up front (attach, measure, layout, draw, detach), the same technique already used and proven for MarkerComposable icon bitmaps, and hand the Maps SDK a fresh, unattached ImageView wrapping that bitmap instead of the live ComposeView.

This keeps the compose-ui 1.10+ fix from #931 (content is fully rendered before we let go of it) while avoiding the double parent crash, since the returned view was never attached anywhere for the SDK to conflict with.

Test plan

…indowComposable

Fixes #950

PR #931 fixed #913 (empty info window content on compose-ui 1.10+) by
keeping the ComposeView permanently attached to the library's own
container while the info window is shown. That works around
compose-ui's attachment requirement for drawing, but it means the view
handed back from getInfoContents()/getInfoWindow() already has a
parent. The Maps SDK internally re-parents that view into its own
default info window frame, so calling addView() on an already-parented
view throws:

java.lang.IllegalStateException: The specified child already has a
parent. You must call removeView() on the child's parent first.

This change renders the Compose content into a plain Bitmap up front
(attach, measure, layout, draw, detach, the same technique already
used for MarkerComposable icon bitmaps) and hands the Maps SDK a
fresh, unattached ImageView wrapping that bitmap instead of the live
ComposeView. This keeps the compose-ui 1.10+ fix from #931 (content is
fully rendered before we let go of it) while avoiding the double
parent crash, since the returned view was never attached anywhere.

Verified on a physical device: reproduced the #950 crash on the
previous build, confirmed it is gone after this change, and confirmed
MarkerInfoWindowContent and MarkerInfoWindowComposable content still
render correctly under compose-bom 2026.06.01 (compose-ui 1.10+),
covering the original #913 scenario as well.
@googlemaps-bot

Copy link
Copy Markdown
Contributor

Code Coverage

Overall Project 25.82%

There is no coverage information present for the Files changed

@LoyalAbbas
LoyalAbbas self-requested a review August 6, 2026 04:15

@LoyalAbbas LoyalAbbas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants