SceneView / sceneview-android

SceneView is a 3D and AR Android Composable and View with Google Filament and ARCore. This is a Sceneform replacement in Kotlin
Apache License 2.0
758 stars 151 forks source link

java.lang.IllegalStateException: Calling method on destroyed View when i try to add Scene inised horizontal pager in compose #401

Closed fadiselim closed 1 month ago

fadiselim commented 5 months ago

I am trying to add Scene inside a horizontal pager, but i get this crash when i go back forth in the horizontal pager in compose

java.lang.IllegalStateException: Calling method on destroyed View Here is my code Sample:

    HorizontalPager(state = pagerState) { page ->
        // Our page content
        Box(modifier = Modifier
            .background(Color.DarkGray)
            .fillMaxSize()) {
            Scene(
        )

} Thank you in advance

fadiselim commented 5 months ago

also very important to note same crash happens when activity is destroyed in the backround on Android 14 pixel 7

java.lang.RuntimeException: Unable to destroy activity {com.denglisch/com.denglisch.MainActivity}: java.lang.IllegalStateException: Calling method on destroyed Scene at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5613) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5645) at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:47) at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:180) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8177) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) Caused by: java.lang.IllegalStateException: Calling method on destroyed Scene at com.google.android.filament.Scene.getNativeObject(Scene.java:189) at com.google.android.filament.Scene.removeEntities(Scene.java:146) at io.github.sceneview.SceneView.removeEntities(SceneView.kt:701) at io.github.sceneview.SceneView.removeNode$sceneview_release(SceneView.kt:679) at io.github.sceneview.SceneView$addNode$2.invoke(SceneView.kt:672) at io.github.sceneview.SceneView$addNode$2.invoke(SceneView.kt:672) at io.github.sceneview.node.Node.setChildNodes(Node.kt:351) at io.github.sceneview.node.Node.setParent(Node.kt:335) at io.github.sceneview.node.Node.destroy(Node.kt:1006) at io.github.sceneview.node.CameraNode.destroy(CameraNode.kt:328) at io.github.sceneview.SceneKt$rememberCameraNode$$inlined$rememberNode$1$1.dispose(Effects.kt:497) at androidx.compose.runtime.DisposableEffectImpl.onForgotten(Effects.kt:87) at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:1267) at androidx.compose.runtime.CompositionImpl.dispose(Composition.kt:768) at androidx.compose.ui.platform.WrappedComposition.dispose(Wrapper.android.kt:145) at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:153) at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:322) at androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.kt:273) at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.kt:290) at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.kt:143) at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.kt:126) at androidx.lifecycle.ReportFragment$Companion.dispatch$lifecycle_runtime_release(ReportFragment.kt:190) at androidx.lifecycle.ReportFragment$LifecycleCallbacks.onActivityPreDestroyed(ReportFragment.kt:146) at android.app.Activity.dispatchActivityPreDestroyed(Activity.java:1602) at android.app.Activity.performDestroy(Activity.java:8871) at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1491) at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5600)

github-actions[bot] commented 2 months ago

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] commented 1 month ago

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.