react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

[Android] The app crashes Unable to update properties for view tag XX. com.facebook.react.uimanager.IllegalViewOperationException: ViewManager for tag 75 could not be found.

Open SarojnetObjex opened this issue 1 year ago • 7 comments

`Unable to update properties for view tag 75 com.facebook.react.uimanager.IllegalViewOperationException: ViewManager for tag 75 could not be found.

                                                                                                	at com.facebook.react.uimanager.NativeViewHierarchyManager.resolveViewManager(NativeViewHierarchyManager.java:111)
                                                                                                	at com.facebook.react.uimanager.NativeViewHierarchyManager.updateProperties(NativeViewHierarchyManager.java:138)
                                                                                                	at com.facebook.react.uimanager.UIImplementation.synchronouslyUpdateViewOnUIThread(UIImplementation.java:306)
                                                                                                	at com.swmansion.reanimated.NodesManager.updateProps(NodesManager.java:589)
                                                                                                	at com.swmansion.reanimated.NativeProxy.updateProps(NativeProxy.java:185)
                                                                                                	at com.swmansion.reanimated.NativeProxy$AnimationFrameCallback.onAnimationFrame(Native Method)
                                                                                                	at com.swmansion.reanimated.NodesManager.onAnimationFrame(NodesManager.java:274)
                                                                                                	at com.swmansion.reanimated.NodesManager.access$000(NodesManager.java:68)
                                                                                                	at com.swmansion.reanimated.NodesManager$1.doFrameGuarded(NodesManager.java:173)
                                                                                                	at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
                                                                                                	at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
                                                                                                	at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
                                                                                                	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1299)
                                                                                                	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1309)
                                                                                                	at android.view.Choreographer.doCallbacks(Choreographer.java:923)
                                                                                                	at android.view.Choreographer.doFrame(Choreographer.java:847)
                                                                                                	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1283)
                                                                                                	at android.os.Handler.handleCallback(Handler.java:942)
                                                                                                	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                	at android.os.Looper.loopOnce(Looper.java:226)
                                                                                                	at android.os.Looper.loop(Looper.java:313)
                                                                                                	at android.app.ActivityThread.main(ActivityThread.java:8747)
                                                                                                	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
                                                                                                	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)`

Package.Json:-

{ "react-native": "0.67.5", "react-native-reanimated": "2.17.0", "react-native-vision-camera": "2.15.4", }

SarojnetObjex avatar May 30 '23 13:05 SarojnetObjex

Hey! 👋

It looks like you've omitted a few important sections from the issue template.

Please complete Description, Steps to reproduce, Snack or a link to a repository, Reanimated version, React Native version and Platforms sections.

github-actions[bot] avatar May 30 '23 13:05 github-actions[bot]

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

github-actions[bot] avatar May 30 '23 13:05 github-actions[bot]

same issue. It appears to be related to the Splash Screen, as Reanimated does not function properly beneath it.

fwon avatar Jun 01 '23 10:06 fwon

For me this happens when I open a @gorhom BottomSheet.

danieldunderfelt avatar Sep 29 '23 08:09 danieldunderfelt

I'm experiencing this on Android after upgrading from 3.3.0 to 3.5.4.

mrbrentkelly avatar Oct 03 '23 19:10 mrbrentkelly

i get this issue when render list item with animated each item(FlashList). Both Debug and Release build. rn: 0.72.4 reanimated: 3.5.4

ngocle2497 avatar Oct 11 '23 08:10 ngocle2497

For me this happens when I open a @gorhom BottomSheet.

Have you been able to solve this problem?

thomas-rx avatar Mar 07 '24 16:03 thomas-rx

@thomas-rx I haven't looked at this in a while, but it's probably not solved. I'll have to look into it.

danieldunderfelt avatar Mar 11 '24 07:03 danieldunderfelt

@thomas-rx I haven't looked at this in a while, but it's probably not solved. I'll have to look into it.

Yes I fixed the problem on #5767.

thomas-rx avatar Mar 11 '24 08:03 thomas-rx

@thomas-rx I haven't looked at this in a while, but it's probably not solved. I'll have to look into it.

Yes I fixed the problem on #5767.

I saw that the library developers are not in a hurry to merge your pull request, maybe you have a patch solution for patch-package?

forchello avatar Mar 25 '24 19:03 forchello

@thomas-rx I haven't looked at this in a while, but it's probably not solved. I'll have to look into it.

Yes I fixed the problem on #5767.

I saw that the library developers are not in a hurry to merge your pull request, maybe you have a patch solution for patch-package?

Sadly, I fixed my version with this patch:

diff --git a/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java b/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java
index 5db6885..ba2f7b8 100644
--- a/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java
+++ b/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java
@@ -344,6 +344,20 @@ public class NodesManager implements EventDispatcherListener {
   }
 
   public void updateProps(int viewTag, Map<String, Object> props) {
+    /*
+     * This is a temporary fix intended to address an issue where updates to properties
+     * are attempted on views that may not exist or have been removed. This scenario can
+     * occur in fast-changing UI environments where components are frequently added or
+     * removed, leading to potential inconsistencies or errors when attempting to update
+     * views based on outdated references
+     */
+    try {
+      View view = mUIManager.resolveView(viewTag);
+      if (view == null) return;
+    } catch (IllegalViewOperationException e) {
+      return;
+    }
+
     // TODO: update PropsNode to use this method instead of its own way of updating props
     boolean hasUIProps = false;
     boolean hasNativeProps = false;

thomas-rx avatar Mar 25 '24 21:03 thomas-rx

Fixed with https://github.com/software-mansion/react-native-reanimated/pull/5767, changes will be available in the next release - 3.12.0

piaskowyk avatar May 13 '24 08:05 piaskowyk

I'm facing this issue even with the above patch when using sharedTransitionTag on Android:

  com.facebook.react.uimanager.NativeViewHierarchyManager.resolveView(NativeViewHierarchyManager.java:102)
  com.swmansion.reanimated.layoutReanimation.SharedTransitionManager.getSharedElementsForCurrentTransition(SharedTransitionManager.java:274)
  com.swmansion.reanimated.layoutReanimation.SharedTransitionManager.prepareSharedTransition(SharedTransitionManager.java:185)
  com.swmansion.reanimated.layoutReanimation.SharedTransitionManager.tryStartSharedTransitionForViews(SharedTransitionManager.java:217)
  com.swmansion.reanimated.layoutReanimation.SharedTransitionManager.-$$Nest$mtryStartSharedTransitionForViews(Unknown Source:0)
  com.swmansion.reanimated.layoutReanimation.SharedTransitionManager$TopWillAppearListener.onEventDispatch(SharedTransitionManager.java:61)
  com.facebook.react.uimanager.events.EventDispatcherImpl.dispatchEvent(EventDispatcherImpl.java:119)
  com.swmansion.rnscreens.ScreenFragment.dispatchLifecycleEvent(ScreenFragment.kt:208)
  com.swmansion.rnscreens.ScreenFragment.dispatchOnWillAppear(ScreenFragment.kt:174)
  com.swmansion.rnscreens.ScreenFragment.dispatchViewAnimationEvent$lambda$8(ScreenFragment.kt:283)
  com.swmansion.rnscreens.ScreenFragment.$r8$lambda$e3DvdjYVJOQVAi0SEvjs2RGsN10(Unknown Source:0)
  com.swmansion.rnscreens.ScreenFragment$$ExternalSyntheticLambda0.run(Unknown Source:4)
  android.os.Handler.handleCallback(Handler.java:958)
  android.os.Handler.dispatchMessage(Handler.java:99)
  android.os.Looper.loopOnce(Looper.java:205)
  android.os.Looper.loop(Looper.java:294)
  android.app.ActivityThread.main(ActivityThread.java:8177)
  java.lang.reflect.Method.invoke(Native Method)
  com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

But I've added a patch with similar logic to the above that seems to work for now. This issue probably needs to be addressed at a higher level though.

index 4e22542..b7a4509 100644
--- a/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java
+++ b/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java
@@ -270,12 +270,21 @@ public class SharedTransitionManager {
         continue;
       }
       View viewSource, viewTarget;
-      if (addedNewScreen) {
-        viewSource = reanimatedNativeHierarchyManager.resolveView(targetViewTag);
-        viewTarget = sharedView;
-      } else {
-        viewSource = sharedView;
-        viewTarget = reanimatedNativeHierarchyManager.resolveView(targetViewTag);
+      // https://github.com/software-mansion/react-native-reanimated/issues/4505
+      try {
+        if (addedNewScreen) {
+          viewSource = reanimatedNativeHierarchyManager.resolveView(targetViewTag);
+          viewTarget = sharedView;
+        } else {
+          viewSource = sharedView;
+          viewTarget = reanimatedNativeHierarchyManager.resolveView(targetViewTag);
+        }
+
+        if (viewSource == null) {
+          continue;
+        }
+      } catch (IllegalViewOperationException e) {
+        continue;
       }
       if (bothAreRemoved) {
         // case for nested stack

tsalama avatar May 13 '24 17:05 tsalama

Fixed with #5767, changes will be available in the next release - 3.12.0

Seems that the error persists

"react-native-reanimated": "^3.13.0-rc.2",
"react-native": "0.74.3",
          Fatal Exception: com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 88239
       at com.facebook.react.uimanager.UIImplementation.setChildren(UIImplementation.java:439)
       at com.facebook.react.uimanager.UIManagerModule.setChildren(UIManagerModule.java:490)
       at com.facebook.react.uimanager.ReanimatedUIManager.setChildren(ReanimatedUIManager.java:90)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
       at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:146)
       at com.facebook.jni.NativeRunnable.run(NativeRunnable.java)
       at android.os.Handler.handleCallback(Handler.java:751)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
       at android.os.Looper.loop(Looper.java:154)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:233)
       at java.lang.Thread.run(Thread.java:761)
        

sanduluca avatar Aug 13 '24 16:08 sanduluca