firemaples / EverTranslator

Translate text anytime and everywhere, even you are gaming!
https://play.google.com/store/apps/details?id=tw.firemaples.onscreenocr
GNU General Public License v3.0
140 stars 25 forks source link

[Crashlytics] Exception java.lang.IllegalStateException: Cannot start this animator on a detached view! #434

Closed firemaples closed 8 months ago

firemaples commented 9 months ago

https://console.firebase.google.com/u/0/project/ever-translator/crashlytics/app/android:tw.firemaples.onscreenocr/issues/9ddc5e91ce28839a6fc4e763d7917e4c?versions=4.0.0%20(118)&time=last-twenty-four-hours&sessionEventKey=65C7852C00ED00014F8DABB00F4CD6F2_1912423033284923655

Exception java.lang.IllegalStateException: Cannot start this animator on a detached view!
  at android.graphics.RenderNode.addAnimator (RenderNode.java:1600)
  at android.graphics.animation.RenderNodeAnimator.setTarget (RenderNodeAnimator.java:288)
  at android.graphics.animation.RenderNodeAnimator.setTarget (RenderNodeAnimator.java:277)
  at android.graphics.drawable.RippleForeground.startPending (RippleForeground.java:139)
  at android.graphics.drawable.RippleForeground.drawHardware (RippleForeground.java:168)
  at android.graphics.drawable.RippleForeground.draw (RippleForeground.java:340)
  at android.graphics.drawable.RippleDrawable.drawBackgroundAndRipples (RippleDrawable.java:1232)
  at android.graphics.drawable.RippleDrawable.drawSolid (RippleDrawable.java:860)
  at android.graphics.drawable.RippleDrawable.draw (RippleDrawable.java:842)
  at android.view.View.drawBackground (View.java:25444)
  at android.view.View.draw (View.java:25157)
  at androidx.compose.material.ripple.AndroidRippleIndicationInstance.drawIndication (AndroidRippleIndicationInstance.java:115)
  at androidx.compose.foundation.IndicationModifier.draw (IndicationModifier.java:1)
  at androidx.compose.ui.node.BackwardsCompatNode.draw (BackwardsCompatNode.java:54)
  at androidx.compose.ui.node.LayoutNodeDrawScope.draw-x_KDEd0$ui_release (LayoutNodeDrawScope.java:47)
  at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers (NodeCoordinator.java:77)
  at androidx.compose.ui.node.NodeCoordinator.draw (NodeCoordinator.java:30)
  at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw (LayoutModifierNodeCoordinator.java:11)
  at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers (NodeCoordinator.java:52)
  at androidx.compose.ui.node.NodeCoordinator.draw (NodeCoordinator.java:30)
  at androidx.compose.ui.node.LayoutNode.draw$ui_release (LayoutNode.java:1)
  at androidx.compose.ui.node.InnerNodeCoordinator.performDraw (InnerNodeCoordinator.java:31)
  at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers (NodeCoordinator.java:52)
  at androidx.compose.ui.node.NodeCoordinator.draw (NodeCoordinator.java:30)
  at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw (LayoutModifierNodeCoordinator.java:11)
  at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers (NodeCoordinator.java:52)
  at androidx.compose.ui.node.NodeCoordinator.draw (NodeCoordinator.java:30)
  at androidx.compose.ui.node.LayoutNode.draw$ui_release (LayoutNode.java:1)
  at androidx.compose.ui.node.InnerNodeCoordinator.performDraw (InnerNodeCoordinator.java:31)
  at androidx.compose.ui.node.LayoutNodeDrawScope.drawContent (LayoutNodeDrawScope.java:101)
  at androidx.compose.foundation.Background.draw (Background.java:406)
  at androidx.compose.ui.node.BackwardsCompatNode.draw (BackwardsCompatNode.java:54)
  at androidx.compose.ui.node.LayoutNodeDrawScope.draw-x_KDEd0$ui_release (LayoutNodeDrawScope.java:47)
  at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers (NodeCoordinator.java:77)
  at androidx.compose.ui.node.NodeCoordinator.draw (NodeCoordinator.java:30)
  at androidx.compose.ui.node.LayoutNode.draw$ui_release (LayoutNode.java:1)
  at androidx.compose.ui.node.InnerNodeCoordinator.performDraw (InnerNodeCoordinator.java:31)
  at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers (NodeCoordinator.java:52)
  at androidx.compose.ui.node.NodeCoordinator.access$drawContainedDrawModifiers (NodeCoordinator.java:135)
  at androidx.compose.ui.node.NodeCoordinator$invoke$1.invoke (NodeCoordinator.java:135)
  at androidx.compose.ui.node.NodeCoordinator$invoke$1.invoke (NodeCoordinator.java:138)
  at androidx.compose.runtime.snapshots.Snapshot$Companion.observe (Snapshot.java:64)
  at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke (SnapshotStateObserver.java:201)
  at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke (SnapshotStateObserver.java:150)
  at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations (SnapshotStateKt__DerivedState.kt:43)
  at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations (SnapshotState.kt:43)
  at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads (SnapshotStateObserver.java:117)
  at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release (OwnerSnapshotObserver.java:117)
  at androidx.compose.ui.node.NodeCoordinator.invoke (NodeCoordinator.java:31)
  at androidx.compose.ui.node.NodeCoordinator.invoke (NodeCoordinator.java:31)
  at androidx.compose.ui.platform.RenderNodeApi29.record (RenderNodeApi29.java:41)
  at androidx.compose.ui.platform.RenderNodeLayer.updateDisplayList (RenderNodeLayer.java:44)
  at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw (AndroidComposeView.java:79)
  at android.view.View.draw (View.java:25168)
  at android.view.View.draw (View.java:25037)
  at android.view.ViewGroup.drawChild (ViewGroup.java:4780)
  at android.view.ViewGroup.dispatchDraw (ViewGroup.java:4538)
  at android.view.View.draw (View.java:25168)
  at android.view.ViewRootImpl.drawSoftware (ViewRootImpl.java:6127)
  at android.view.ViewRootImpl.draw (ViewRootImpl.java:6046)
  at android.view.ViewRootImpl.performDraw (ViewRootImpl.java:5662)
  at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:4770)
  at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:3275)
  at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:11257)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1650)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1659)
  at android.view.Choreographer.doCallbacks (Choreographer.java:1129)
  at android.view.Choreographer.doFrame (Choreographer.java:1055)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1622)
  at android.os.Handler.handleCallback (Handler.java:958)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:230)
  at android.os.Looper.loop (Looper.java:319)
  at android.app.ActivityThread.main (ActivityThread.java:8913)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:608)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)
firemaples commented 8 months ago

Try fixing this issue by upgrading the compose version to the latest and avoid reusing the same view https://github.com/firemaples/EverTranslator/pull/445

uomar8 commented 8 months ago

version: 4.0.4 still same error

2024-03-22 05:49:08.186 23542-23542 AndroidRuntime tw.firemaples.onscreenocr_debug E FATAL EXCEPTION: main Process: tw.firemaples.onscreenocr_debug, PID: 23542 java.lang.IllegalStateException: Cannot start this animator on a detached view! at android.graphics.RenderNode.addAnimator(RenderNode.java:1502) at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:316) at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:300) at android.graphics.drawable.RippleForeground.startPending(RippleForeground.java:139) at android.graphics.drawable.RippleForeground.drawHardware(RippleForeground.java:168) at android.graphics.drawable.RippleForeground.draw(RippleForeground.java:340) at android.graphics.drawable.RippleDrawable.drawBackgroundAndRipples(RippleDrawable.java:848) at android.graphics.drawable.RippleDrawable.draw(RippleDrawable.java:679) at android.view.View.drawBackground(View.java:22227) at android.view.View.draw(View.java:21991) at androidx.compose.material.ripple.AndroidRippleIndicationInstance.drawIndication(Ripple.android.kt:192) at androidx.compose.foundation.IndicationModifier.draw(Indication.kt:183) at androidx.compose.ui.node.BackwardsCompatNode.draw(BackwardsCompatNode.kt:349) at androidx.compose.ui.node.LayoutNodeDrawScope.drawDirect-x_KDEd0$ui_release(LayoutNodeDrawScope.kt:105) at androidx.compose.ui.node.LayoutNodeDrawScope.performDraw(LayoutNodeDrawScope.kt:76) at androidx.compose.ui.node.LayoutNodeDrawScope.drawContent(LayoutNodeDrawScope.kt:55) at androidx.compose.foundation.BackgroundNode.draw(Background.kt:159) at androidx.compose.ui.node.LayoutNodeDrawScope.drawDirect-x_KDEd0$ui_release(LayoutNodeDrawScope.kt:105) at androidx.compose.ui.node.LayoutNodeDrawScope.draw-x_KDEd0$ui_release(LayoutNodeDrawScope.kt:86) at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:364) at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:176) at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:361) at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353) at androidx.compose.ui.node.LayoutNode.draw$ui_release(LayoutNode.kt:926) at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174) at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:361) at androidx.compose.ui.node.NodeCoordinator.access$drawContainedDrawModifiers(NodeCoordinator.kt:54) at androidx.compose.ui.node.NodeCoordinator$drawBlock$1$1.invoke(NodeCoordinator.kt:383) at androidx.compose.ui.node.NodeCoordinator$drawBlock$1$1.invoke(NodeCoordinator.kt:382) at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2303) at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:500) at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256) at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133) at androidx.compose.ui.node.NodeCoordinator$drawBlock$1.invoke(NodeCoordinator.kt:382) at androidx.compose.ui.node.NodeCoordinator$drawBlock$1.invoke(NodeCoordinator.kt:380) at androidx.compose.ui.platform.RenderNodeApi29.record(RenderNodeApi29.android.kt:209) at androidx.compose.ui.platform.RenderNodeLayer.updateDisplayList(RenderNodeLayer.android.kt:335) at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:1236) at android.view.View.draw(View.java:22002) at android.view.View.draw(View.java:21868) at android.view.ViewGroup.drawChild(ViewGroup.java:4639) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4386) at android.view.View.draw(View.java:22002) at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:4469) at android.view.ViewRootImpl.draw(ViewRootImpl.java:4367) 2024-03-22 05:49:08.186 23542-23542 AndroidRuntime tw.firemaples.onscreenocr_debug E at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4147) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3407) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2188) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8918) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1280) at android.view.Choreographer.doCallbacks(Choreographer.java:1019) at android.view.Choreographer.doFrame(Choreographer.java:911) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1248) at android.os.Handler.handleCallback(Handler.java:900) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:219) at android.app.ActivityThread.main(ActivityThread.java:8676) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109) 2024-03-22 05:49:08.315 23542-23542 Process tw.firemaples.onscreenocr_debug I Sending signal. PID: 23542 SIG: 9 2024-03-22 05:49:08.380 1536-2056 InputDispatcher system_server E channel 'cc57613 tw.firemaples.onscreenocr_debug (server)' ~ Channel is unrecoverably broken and will be disposed! 2024-03-22 05:49:08.402 1536-2056 InputDispatcher system_server E channel 'adabf66 tw.firemaples.onscreenocr_debug (server)' ~ Channel is unrecoverably broken and will be disposed! ---------------------------- PROCESS STARTED (28736) for package tw.firemaples.onscreenocr_debug ----------------------------

firemaples commented 8 months ago

Hi @uomar8 Do you have the reproduce steps? I tried Pixel 3/7/8 and Note 8 and couldn't reproduce this issue. πŸ˜…

This issue needs to be fixed before releasing the production version. The main flow is already refactored, I will start working on the enhancement from you after this issue is fixed.

uomar8 commented 8 months ago

Hi @uomar8 Do you have the reproduce steps? I tried Pixel 3/7/8 and Note 8 and couldn't reproduce this issue. πŸ˜…

This issue needs to be fixed before releasing the production version. The main flow is already refactored, I will start working on the enhancement from you after this issue is fixed.

I don't have the steps because it happens randomly

This is a video how it crush, I hope it could help

https://github.com/firemaples/EverTranslator/assets/7046347/48d4bd3e-3c5f-44fd-83c2-cbc149c8f733

firemaples commented 8 months ago

Does it always happen after pressing the translation button and before displaying the result window? πŸ€”

uomar8 commented 8 months ago

Does it always happen after pressing the translation button and before displaying the result window? πŸ€”

It never happened after pressing the translation button or before displaying the result window πŸ‘

It happened after closing the result windows by clicking outside the window ( sometimes it close the window and sometimes it crush the app)

firemaples commented 8 months ago

It happened after closing the result windows by clicking outside the window ( sometimes it close the window and sometimes it crush the app)

Thanks for explaining the situation clearly. πŸ‘

Currently, this crash mainly happens on Samsung, Huawei, and Xiaomi with Android 10, 13, 14 I don't have the above devices πŸ˜… Let me try to reproduce it on emulators first. πŸ™‡β€β™‚οΈ

firemaples commented 8 months ago

Hi @uomar8, When I'm trying to reproduce this on my local side, could you try this fix https://github.com/firemaples/EverTranslator/pull/447 when you have time? Thank you!πŸ™‡β€β™‚οΈ

The issue is caused by the running ripple effect after the view is destroyed. I removed the ripple effect from the result view's background.

uomar8 commented 8 months ago

Hi @uomar8, When I'm trying to reproduce this on my local side, could you try this fix #447 when you have time? Thank you!πŸ™‡β€β™‚οΈ

The issue is caused by the running ripple effect after the view is destroyed. I removed the ripple effect from the result view's background.

Fixed πŸ‘πŸ‘πŸ‘ I tried it multiple, it works

It can be closed now

firemaples commented 8 months ago

Thank you, let me introduce the fix to a new release!