Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scene does not work inside LazyColumn #462

Open
EvergreenTree97 opened this issue Apr 9, 2024 · 1 comment
Open

Scene does not work inside LazyColumn #462

EvergreenTree97 opened this issue Apr 9, 2024 · 1 comment
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@EvergreenTree97
Copy link

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?

@ThomasGorisse
Copy link
Contributor

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 ThomasGorisse added bug Something isn't working enhancement New feature or request labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants