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.26k stars 1.18k forks source link

Camera issue in webview iOS #3791

Closed ssvaghasiya closed 1 year ago

ssvaghasiya commented 1 year ago

When i open camera and close camera in webview webview close automatically

example video: https://github.com/JetBrains/compose-multiplatform/assets/49331161/2ef4381a-c8cb-46ff-a552-42269ed37aec

ssvaghasiya commented 1 year ago

any solution? and also it's working fine with 1.5.0-beta01 version

it's not working with latest version

elijah-semyonov commented 1 year ago

Not for now. As a workaround you could use a native UIViewController presented modally called on LocalUIViewController.current with web view inside.

ssvaghasiya commented 1 year ago

how to use any reference or please provide some detail explanation with example

elijah-semyonov commented 1 year ago

Could you be more specific about what you struggle to figure out in particular?

ssvaghasiya commented 1 year ago

Could you be more specific about what you struggle to figure out in particular?

When camera open from webview don't go back so any solution with example related to compose multiplatform.

elijah-semyonov commented 1 year ago

It goes back, because ComposeScene is destroyed, and hence interop view is also destroyed. In order for web view not to get destroyed, you could present a native UIViewController with that web view and wire in the callbacks.

Have a look at this code to have a better idea how to do it. https://github.com/JetBrains/compose-multiplatform-core/blob/jb-main/compose/mpp/demo/src/uikitMain/kotlin/NativePopupExample.kt

To persist your state (navigation route, for example) across ComposeScene reconstructions, store it outside of the composition.

ssvaghasiya commented 1 year ago

It goes back, because ComposeScene is destroyed, and hence interop view is also destroyed. In order for web view not to get destroyed, you could present a native UIViewController with that web view and wire in the callbacks.

Have a look at this code to have a better idea how to do it. https://github.com/JetBrains/compose-multiplatform-core/blob/jb-main/compose/mpp/demo/src/uikitMain/kotlin/NativePopupExample.kt

To persist your state (navigation route, for example) across ComposeScene reconstructions, store it outside of the composition.

so how it's working with 1.5.0-beta01 version?

elijah-semyonov commented 1 year ago

Because the interop view (web view in your case) was erroneously still in the uikit hierarchy, which was a bug of beta01: https://github.com/JetBrains/compose-multiplatform/issues/3749

ssvaghasiya commented 1 year ago

Because the interop view (web view in your case) was erroneously still in the uikit hierarchy, which was a bug of beta01: #3749

Below is my current code so what solution apply to resolve the issue? https://gist.github.com/ssvaghasiya/d69f12b1987b7a775ee08e63ca4e0264

ssvaghasiya commented 1 year ago

Hello @elijah-semyonov please provide solution for above code

elijah-semyonov commented 1 year ago

I suggested a solution and an example in https://github.com/JetBrains/compose-multiplatform/issues/3791#issuecomment-1753038883 . It's up to you to figure it out. If it's still not clear, discuss it with fellow community members in the Kotlin Slack.

ssvaghasiya commented 1 year ago

I suggested a solution and an example in #3791 (comment) . It's up to you to figure it out. If it's still not clear, discuss it with fellow community members in the Kotlin Slack.

issue resolved in upcoming release?

okushnikov commented 2 months ago

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