perf: improve MarkerComposable rendering performance - #881
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
6bec4de to
f9ba7e5
Compare
20cd3ba to
b24b74a
Compare
b24b74a to
bdf161f
Compare
…eView lifecycle Add an interactive performance demonstration for MarkerComposable and polish offscreen rendering lifecycle details on top of googlemaps#881. - Add MarkerComposablePerformanceActivity showcasing 10-75 dynamic markers with 1Hz and 4Hz auto-update stress testing. - Add an explanatory dialog clarifying marker IDs vs live state counters and demo controls. - Ensure pixel-perfect alignment for marker badge typography by disabling font padding and using vector icons. - Delegate setContent dynamically via { currentContent() } in rememberComposeBitmapDescriptor so retained ComposeViews reflect updated state on recomposition. - Set alpha = 0f on retained ComposeViews to prevent offscreen rendering views from appearing in the window root layout.
659044a to
7a57048
Compare
reverted pushing renderComposableToBitmapDescriptor call to IO thread as causing intermittent crash
…eView lifecycle Add an interactive performance demonstration for MarkerComposable and polish offscreen rendering lifecycle details on top of googlemaps#881. - Add MarkerComposablePerformanceActivity showcasing 10-75 dynamic markers with 1Hz and 4Hz auto-update stress testing. - Add an explanatory dialog clarifying marker IDs vs live state counters and demo controls. - Ensure pixel-perfect alignment for marker badge typography by disabling font padding and using vector icons. - Delegate setContent dynamically via { currentContent() } in rememberComposeBitmapDescriptor so retained ComposeViews reflect updated state on recomposition. - Set alpha = 0f on retained ComposeViews to prevent offscreen rendering views from appearing in the window root layout.
7a57048 to
f6c3101
Compare
|
@brucemok8 , I am not convinced about this approach. The ComposeView is now kept alive and attached to host (the window root view) for the entire lifetime of the marker, only removed when the marker leaves composition. Even with setting alpha to 0, views with alpha = 0f are still part of the root's measure/layout pass and are typically still touchable/hit-testable by default in Android. Also, since icon starts null and MarkerImpl is only composed once it's non-null, markers will now pop in a frame or two late instead of appearing immediately. |
|
And another thought: there might be a potential race between content recomposition and bitmap capture. |
Summary
This PR improves the rendering performance of
MarkerComposable, particularly when displaying a larger number of markers with frequently updating content.Changes
ComposeViewinstances instead of creating and disposing them for each render. The view is retained and used to generate updated bitmaps when marker keys change, and disposed only when the marker is removed.rememberComposeBitmapDescriptorto return a nullable type. Callers skip rendering until the bitmap is ready, preventing main thread blocking and allowing markers to appear asynchronously.Impact
These changes significantly reduce UI jank during marker updates. In testing, scenarios with ~25 dynamically updating markers show noticeably smoother performance.