Is there a way yet to correctly prevent re-initial...
# compose
a
Is there a way yet to correctly prevent re-initialization of an expensive AndroidView in compose? Such as for these situations: • LazyColumn/LazyVerticalPager with AndroidView (say with ExoPlayer Views) ◦ Seems weird that it is not able to recycle Android View instances like a RecyclerView, it seems to expensive when your items have AndroidView. ◦ Would I need to implement my own recycled view pool? • Switching destinations in the NavHost (Say Google Maps View with other destinations) I tried saving the MapsView instance in a singleton in the official maps-compose sample, though it’s still not seamless like in the Production Google Maps App. [Demo in Thread]
It’s still reloading the tiles even though things are cached
a
I have a similar use case, i currently put the
MapView
in a Background
composable
/`(parent)NavHost` and use an inner
NavHost
for other screens to prevent the re-initilaization
z
Could you file a bug for this? I think it should Just Work, or maybe there’s some missing wiring somewhere. Please post a link here when filed.
a
For me, specifically one of the issue was https://issuetracker.google.com/issues/206656068
a
I could file something but I'm not sure which one you think should just work. Is it the fact that we should retain all View instances that are in the navigation backstack? Or perhaps you are referring to the lazycolumn or the google maps wrapper itself...
z
Lazy lists should recycle both compositions and layout nodes where possible, so I would expect them to recycle child android views as well. If they're not, that seems like a bug to me.
a
Got it, so it's specifically about the lazy list. (Actually my use case vertical pager, maybe lazy list works). Let me try to make a sample