Skip to content

fix: Android Fabric marker content view not measured/laid out#63

Open
dacoto wants to merge 3 commits intolugg:mainfrom
dacoto:copilot/fix-luggmarkerview-issue-61
Open

fix: Android Fabric marker content view not measured/laid out#63
dacoto wants to merge 3 commits intolugg:mainfrom
dacoto:copilot/fix-luggmarkerview-issue-61

Conversation

@dacoto
Copy link
Copy Markdown
Contributor

@dacoto dacoto commented Mar 27, 2026

Summary

Fixes custom marker views rendering incorrectly or not at all when using React Native's New Architecture (Fabric) on Android. In Fabric, contentView was never attached to the view hierarchy, so Fabric skipped measure/layout passes on it and its children entirely.

The fix lazily attaches contentView to the real view hierarchy via super.addView() on the first non-callout child addition. To avoid visually rendering it in the wrong position, translationX is set to -10000f (off-screen); this does not affect createContentBitmap(), which draws in the view's own coordinate space.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Test Plan

  • Verify that custom marker views render correctly on Android when using the New Architecture (Fabric).
  • Confirm that markers also render correctly with the legacy architecture (Paper) to avoid regressions.
  • Check that callout views are unaffected.
  • Confirm contentView is not visually rendered at an unexpected position on screen.

Screenshots / Videos

Checklist

  • I tested on iOS
  • I tested on Android
  • I tested on Web
  • I updated the documentation (if needed)

Copilot AI and others added 3 commits March 27, 2026 23:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 27, 2026 23:37
@dacoto dacoto changed the title Copilot/fix luggmarkerview issue 61 Fix Android Fabric (New Architecture) marker content view not measured/laid out Mar 27, 2026
@dacoto dacoto changed the title Fix Android Fabric (New Architecture) marker content view not measured/laid out fix: Android Fabric marker content view not measured/laid out Mar 27, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes Android (React Native New Architecture/Fabric) custom marker views that weren’t being measured/la[id] out because the marker’s contentView was never attached to the native view hierarchy.

Changes:

  • Add ensureContentViewAttached() to lazily attach contentView to the view hierarchy.
  • Offset the attached contentView off-screen via a large negative translationX.
  • Invoke ensureContentViewAttached() when adding non-callout children.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +180 to +188
// Add contentView to the hierarchy so Fabric triggers measure/layout,
// but push it offscreen so it is never visually rendered on the map.
// createContentBitmap() calls contentView.draw(canvas) which draws
// relative to the view's own coordinate space, unaffected by translation.
contentView.translationX = OFFSCREEN_TRANSLATION_X
super.addView(contentView, 0, ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
))
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

contentView.translationX is set to an off-screen value, but createContentBitmap() calls contentView.draw(canvas), which applies the view's transform matrix (including translation) during drawing. This will shift the drawn content off the bitmap (often producing a blank/incorrect marker icon). Consider avoiding transforms for the off-screen hiding, or temporarily resetting/restoring translationX/translationY around bitmap rendering so rasterized markers render correctly.

Copilot uses AI. Check for mistakes.
@dacoto
Copy link
Copy Markdown
Contributor Author

dacoto commented Mar 27, 2026

Closes #61

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.

3 participants