JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.35k stars 1.18k forks source link

CMPViewControllerMisuse error introduced in Compose 1.6.0-beta01 #4188

Closed brendanw closed 10 months ago

brendanw commented 10 months ago

Describe the bug A CMPViewControllerMisuse error is thrown for a case where it wasn't in compose 1.5.11.

'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.'

Affected platforms Select one of the platforms below:

Versions

To Reproduce" You can reproduce the code using the code from the old template on this branch -> https://github.com/brendanw/compose-multiplatform-template/pull/2

  1. Launch an ios app that has a single viewcontroller that is a ComposeUIViewController
  2. From within that ComposeUIViewController call present to present a AVPlayerViewController
  3. turn off the device screen
  4. turn on the device screen
  5. back navigate out of the AVPlayerViewController

Expected behavior No CMPViewControllerMisuse error should be thrown.

Screenshots 2024-01-26 19 38 03

Additional context N/A

elijah-semyonov commented 10 months ago

It's reproduced even without the sending the app to background.

Kashif-E commented 4 months ago

this is still occurring in 1.6.11 and I am able to reproduce this in 1.6.2

ahmedsalemelzeiny commented 3 months ago

this is still occurring on the latest versions, @Kashif-E did you find a solution for it?

elijah-semyonov commented 3 months ago

Please, post a repro, it should have been fixed.

Shamyyoun commented 3 months ago

@ahmedsalemelzeiny @elijah-semyonov Verified it again and it's fixed yeah. The issue was that we were using a view controller wrapper in iOS to avoid disposing the compose view controller (old issue) but no need for it now and after removing it everything is working fine 🥳🥳🥳

okushnikov commented 3 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

omargda commented 2 months ago

Hello, I also ran into the same error while using Kotlin version 1.9.22 and Compose Multiplatform version 1.5.11. Which Compose Multiplatform version was the fix introduced? Is it one compatible with Kotlin version 1.9.22? I'm not currently able to go to a higher Kotlin version. Thanks!