Hi all. Since moving to Compose KMP 1.6, I've star...
# compose-ios
s
Hi all. Since moving to Compose KMP 1.6, I've started having a crash:
Copy code
exceptionWithName:@"CMPViewControllerMisuse"
                                           reason:@"CMPViewController shouldn't be reused after completely removed from hierarchy, because it's logically marked as Destroyed. You must create a new CMPViewController and use it instead."
I have a Compose view inside a
LazyVStack
. It looks like the
ComposeUIViewController
, which is in a disposed state, is being reused by the SwiftUI system. I'm wondering if my use case is not supported since I can't find any way where my own code is holding on to the CMPViewController. Has anyone here used a Compose view inside a LazyVStack?
a
Hi! For now, you need to maintain a permanent child-parent connection to keep ComposeUIViewController alive. LazyVStack deletes the view controller from the hierarchy, so the Compose content behind it is deallocated. The reason for this decision was to reduce the number of memory leaks and to reduce the memory overhead. I created the issue to think about this decision again - all updates will be there.
s
Ok thanks for clarifying. For the lazy list we're lucky and can use a VStack instead. We have the same issue with a preview of an item in a reorderable list, seem we'll need a different workaround there. I'll keep an eye on the ticket 👍