sceneview-android icon indicating copy to clipboard operation
sceneview-android copied to clipboard

Scene does not work inside LazyColumn

Open evergreentree97 opened this issue 1 year ago • 1 comments

dependenceis : "io.github.sceneview:sceneview:2.0.3"

exceptions:

java.lang.IllegalStateException: Calling method on destroyed View at com.google.android.filament
.View.getNativeObject(View.java:1229)
     at com.google.android.filament.View.setScene(View.java:210)
    at io.github.sceneview.SceneView.setScene(SceneView.kt:249)
    at io.github.sceneview.SceneKt$Scene$4.invoke(Scene.kt:220)
    at io.github.sceneview.SceneKt$Scene$4.invoke(Scene.kt:190)

The Scene Composable exists inside the LazyColumn, and after scrolling to the bottom, the following error occurs when you return to the item with Scene Composable. It seems to be a problem caused by the creation and destruction of items by necessity inside LazyColumn, but we can't control LazyColumn.

Therefore, it is being solved temporarily using the following method. But I don't think it's a good way

AndroidView(
        modifier = Modifier,
        factory = { context ->
            object : FrameLayout(context).apply {
                layoutParams = ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT
                )
                addView(
                    SceneView()
                ),
       onRelease = { _ ->
            sceneView?.destroy()
        }
)

Is there a way to do it?

evergreentree97 avatar Apr 09 '24 07:04 evergreentree97

Very interresting subject. I have to admit that I never tested it. Would you share your code somewhere on GitHub so we can check the destroying/dispose behaviour with LazyColumn?

ThomasGorisse avatar May 13 '24 13:05 ThomasGorisse

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Aug 12 '24 05:08 github-actions[bot]

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

github-actions[bot] avatar Aug 20 '24 05:08 github-actions[bot]