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

Random JSApplicationIllegalArgumentException crashes on Android #21755

Closed
3 tasks done
dgruseck opened this issue Oct 12, 2018 · 37 comments
Closed
3 tasks done

Random JSApplicationIllegalArgumentException crashes on Android #21755

dgruseck opened this issue Oct 12, 2018 · 37 comments
Labels
Bug Platform: Android Android applications. Resolution: Fixed A PR that fixes this issue has been merged. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@dgruseck
Copy link

Environment

React Native Environment Info:
System:
OS: macOS 10.14
CPU: x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Memory: 40.02 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.6.0 - /usr/local/bin/node
Yarn: 1.6.0 - ~/.yarn/bin/yarn
npm: 5.3.0 - /usr/local/bin/npm
Watchman: 4.7.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
Android SDK:
Build Tools: 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.2, 27.0.3
API Levels: 21, 23, 25, 26, 27, 28
IDEs:
Android Studio: 2.2 AI-145.3537739
Xcode: 10.0/10A255 - /usr/bin/xcodebuild
npmPackages:
react: 16.5.0 => 16.5.0
react-native: 0.57.2 => 0.57.2
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 1.3.0
react-native-git-upgrade: 0.2.7

Android build versions:
buildToolsVersion = "27.0.3"
minSdkVersion = 21
compileSdkVersion = 27
targetSdkVersion = 27
supportLibVersion = "27.1.1"

Description

Hi there,
since I upgraded to react native 0.57 I receive some crashes on Android.
It's not reproducable, but If I e.g reload a list over and over again the app crashes at some point (sometimes it takes 100 tries, sometimes only 2 or 3).
The exception is always a JSApplicationIllegalArgumentException.
But with different properties (height, width, paddingHorizontal, ...).
I have no glue where it is coming from, because the crashes also occure on different places in the app.

If you need more information I'm glad to help.

Thanks
David

The stacktrace from sentry looks like this:

java.lang.ClassCastException: Value for fill cannot be cast from ReadableNativeArray to Double
    at com.facebook.react.bridge.ReadableNativeMap.checkInstance(ReadableNativeMap.java:148)
    at com.facebook.react.bridge.ReadableNativeMap.getValue(ReadableNativeMap.java:127)
    at com.facebook.react.bridge.ReadableNativeMap.getDouble(ReadableNativeMap.java:168)
    at com.facebook.react.bridge.DynamicFromMap.asDouble(DynamicFromMap.java:64)
    at com.facebook.react.uimanager.LayoutShadowNode$MutableYogaValue.setFromDynamic(LayoutShadowNode.java:67)
    at com.facebook.react.uimanager.LayoutShadowNode.setHeight(LayoutShadowNode.java:157)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:105)
    at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:157)
    at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:61)
    at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:458)
    at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:295)
    at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:377)
    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:160)
    at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
    at android.os.Looper.loop(Looper.java:164)
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
    at java.lang.Thread.run(Thread.java:764)
java.lang.reflect.InvocationTargetException: null
    at java.lang.reflect.Method.invoke(Method.java)
    at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:105)
    at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:157)
    at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:61)
    at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:458)
    at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:295)
    at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:377)
    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:160)
    at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
    at android.os.Looper.loop(Looper.java:164)
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
    at java.lang.Thread.run(Thread.java:764)
com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'height' in shadow node of type: RCTView
    at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:116)
    at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:157)
    at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:61)
    at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:458)
    at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:295)
    at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:377)
    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:160)
    at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
    at android.os.Looper.loop(Looper.java:164)
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
    at java.lang.Thread.run(Thread.java:764)

Reproducible Demo

@react-native-bot react-native-bot added the Platform: Android Android applications. label Oct 12, 2018
@Kamill90
Copy link

I can confirm. Crashlytics gives us more and more this kind of report since we have upgraded react-native to 0.57
Most common crashes are:
Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException Error while updating property 'marginBottom' in shadow node of type: RCTText

Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException Error while updating property 'bottom' in shadow node of type: RCTView

Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException Error while updating property 'paddingHorizontal' in shadow node of type: RCTView

Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException Error while updating property 'fill' of a view managed by: RNSVGPath

Is there any workaround /solution /planned bugfix for that?

@hey99xx
Copy link

hey99xx commented Oct 17, 2018

There's chance that some of these exceptions will be fixed by #17842 DynamicFromMap threading issue.

software-mansion/react-native-svg#806 which had JSApplicationIllegalArgumentException Error while updating property 'stroke' of a view managed by: RNSVGRect got also fixed after taking the fix above.

#17873 also causes JSApplicationIllegalArgumentException errors but it's a much edgier case, you would have to be running multiple bundles simulatenously.

@Kamill90
Copy link

Any idea when merged #17842 will be in the npm version?

@hey99xx
Copy link

hey99xx commented Oct 18, 2018

@Kamill90 If you think this should go faster you can ping on react-native-community/releases#48 but I'd suggest first trying out locally if this commit will fix your issue.

@hssrrw
Copy link

hssrrw commented Oct 23, 2018

I tried the fix from #17842 and still get these errors in random places.

@Winglonelion
Copy link

Winglonelion commented Oct 24, 2018

did #17842 already in RN 0.57.3? Our project met serveral reports since upgrade RN 0.57.x version.

one more note: This type of crash has outstanding rate in Samsung devices with android 7.0+ than others.

@SandroMachado
Copy link
Contributor

I am facing the same king of issues.

@hssrrw
Copy link

hssrrw commented Oct 24, 2018

@Winglonelion it's not released yet. It's planned for version 0.57.4. You can track it here react-native-community/releases#48 (comment).

@mhkhung
Copy link

mhkhung commented Oct 25, 2018

Any idea if this will be back-ported to older RN releases like 0.55?

@rosskhanas
Copy link

rosskhanas commented Oct 26, 2018

@Winglonelion same thing. Samsung and some LG devices as well after applying the fix.

@SandroMachado
Copy link
Contributor

RN 0.57.4 available.

@rosskhanas
Copy link

#17873 (comment) fix crashes on Samsung and LG phones.

@hramos hramos added the Resolution: Fixed A PR that fixes this issue has been merged. label Dec 14, 2018
@hramos hramos closed this as completed Dec 14, 2018
@hey99xx
Copy link

hey99xx commented Dec 14, 2018

@hramos FYI there's no PR for the comment that's linked #17873 (comment) so "Fixed" label will be misleading. I believe people who say it's fixed are building RN from source and applying this fix on their own.

@hramos
Copy link
Contributor

hramos commented Dec 14, 2018

I closed it based on #17842. I'll re-open, can someone send a PR to address any remaining issues.

@hramos hramos reopened this Dec 14, 2018
@hey99xx
Copy link

hey99xx commented Dec 14, 2018

RN has/had at least 2 distinct thread safety issues that I know of:


One was DynamicFromMap pool that's fixed in #17842.
DynamicFromArray is still not safe but I don't think anyone faced that one yet.


Second is the varargs optimization that was root caused and very well described in #17873 (comment).
The fix I suggested has completely stripped the optimization because I needed it so urgently, so I don't think if I send a PR like what I have at the moment would be accepted.
I guess similarly to the pool PR, a fix using bunch of ThreadLocal<Object[]> instances can be implemented to keep the optimization and still enforce thread safety.

@rqyang-info
Copy link

System:
OS: macOS 10.14.2
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 244.36 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.2.0 - /usr/local/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.4.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
Build Tools: 22.0.1, 23.0.2, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 27.0.0, 27.0.1, 27.0.3, 28.0.3
System Images: android-22 | Android TV Intel x86 Atom
IDEs:
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.6.1 => 16.6.1
react-native: ^0.57.5 => 0.57.8
npmGlobalPackages:
react-native-cli: 2.0.1

In My Android app with react-native to 0.57.5, Crashlytics gives us more and more this kind of report.

@konatess
Copy link

Having basically the same issue, only happening on Android, not iOS. My team is testing both. My problem is reproducible, at least on my device, and only happens with a particular navigation, after a button is pressed. When I dismiss the error on the device, the app completely freezes.

@SujataSwamy
Copy link

Facing same issue. Please help if anyone knows the solution.

I have used
implementation 'com.facebook.react:react-native:+'

It happens only on Android and not on iOS.

Attaching below Firebase crash report:

Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'padding' in shadow node of type: AndroidTextInput
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:113)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58)
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:378)
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289)
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:366)
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:160)
at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
at android.os.Handler.handleCallback(Handler.java:869)
at android.os.Handler.dispatchMessage(Handler.java:101)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:206)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)

Caused by java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Method.java)
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:107)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58)
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:378)
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289)
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:366)
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:160)
at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
at android.os.Handler.handleCallback(Handler.java:869)
at android.os.Handler.dispatchMessage(Handler.java:101)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:206)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)

Caused by java.lang.IllegalStateException: This dynamic value has been recycled
at com.facebook.react.bridge.DynamicFromMap.isNull(DynamicFromMap.java:46)
at com.facebook.react.uimanager.LayoutShadowNode$MutableYogaValue.setFromDynamic(LayoutShadowNode.java:48)
at com.facebook.react.uimanager.LayoutShadowNode.setPaddings(LayoutShadowNode.java:638)
at java.lang.reflect.Method.invoke(Method.java)
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:107)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58)
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:378)
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289)
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:366)
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:160)
at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
at android.os.Handler.handleCallback(Handler.java:869)
at android.os.Handler.dispatchMessage(Handler.java:101)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:206)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)

@hramos hramos removed the Bug Report label Feb 6, 2019
@mhkhung
Copy link

mhkhung commented Feb 13, 2019

It seems to always happen with certain timing on our app startup. So I added 300ms delay with a setTimeout to delay initial rendering and seems to work well.

@rqyang-info
Copy link

rqyang-info commented Mar 1, 2019

It seems to always happen with certain timing on our app startup. So I added 300ms delay with a setTimeout to delay initial rendering and seems to work well.

@mhkhung
How did you added 300ms delay with a setTimeout to delay initial rendering? thanks

@AndreyPatseiko
Copy link

AndreyPatseiko commented Apr 29, 2019

@SujataSwamy was you find solution. I get the same error in RN 0.55. What version RN do you use?

@SujataSwamy
Copy link

@AndreyPatseiko I didnot find any solution. It still crashes app in Android build.

@iagormoraes
Copy link

This error still happens in RN 0.59.1, stack trace below:

JSApplicationIllegalArgumentException
Error while updating property 'height' in shadow node of type: RCTView
com.facebook.react.uimanager.au$j in a
com.facebook.react.uimanager.as$a in a
com.facebook.react.uimanager.as in a
com.facebook.react.uimanager.x in a
com.facebook.react.uimanager.aj in a
com.facebook.react.uimanager.UIManagerModule in updateView
java.lang.reflect.Method in invoke
com.facebook.react.bridge.JavaMethodWrapper in invoke
com.facebook.react.bridge.JavaModuleWrapper in invoke
com.facebook.react.bridge.queue.NativeRunnable in run
android.os.Handler in handleCallback at line 751
android.os.Handler in dispatchMessage at line 95
com.facebook.react.bridge.queue.MessageQueueThreadHandler in dispatchMessage
android.os.Looper in loop at line 154
com.facebook.react.bridge.queue.MessageQueueThreadImpl$4 in run
java.lang.Thread in run at line 762
InvocationTargetException
java.lang.reflect.Method in invoke
com.facebook.react.uimanager.au$j in a
com.facebook.react.uimanager.as$a in a
com.facebook.react.uimanager.as in a
com.facebook.react.uimanager.x in a
com.facebook.react.uimanager.aj in a
com.facebook.react.uimanager.UIManagerModule in updateView
java.lang.reflect.Method in invoke
com.facebook.react.bridge.JavaMethodWrapper in invoke
com.facebook.react.bridge.JavaModuleWrapper in invoke
com.facebook.react.bridge.queue.NativeRunnable in run
android.os.Handler in handleCallback at line 751
android.os.Handler in dispatchMessage at line 95
com.facebook.react.bridge.queue.MessageQueueThreadHandler in dispatchMessage
android.os.Looper in loop at line 154
com.facebook.react.bridge.queue.MessageQueueThreadImpl$4 in run
java.lang.Thread in run at line 762
ClassCastException
Value for height cannot be cast from ReadableNativeMap to Double
com.facebook.react.bridge.ReadableNativeMap in checkInstance
com.facebook.react.bridge.ReadableNativeMap in getValue
com.facebook.react.bridge.ReadableNativeMap in getDouble
com.facebook.react.bridge.DynamicFromMap in asDouble
com.facebook.react.uimanager.h$a in a
com.facebook.react.uimanager.h in setHeight
java.lang.reflect.Method in invoke
com.facebook.react.uimanager.au$j in a
com.facebook.react.uimanager.as$a in a
com.facebook.react.uimanager.as in a
com.facebook.react.uimanager.x in a
com.facebook.react.uimanager.aj in a
com.facebook.react.uimanager.UIManagerModule in updateView
java.lang.reflect.Method in invoke
com.facebook.react.bridge.JavaMethodWrapper in invoke
com.facebook.react.bridge.JavaModuleWrapper in invoke
com.facebook.react.bridge.queue.NativeRunnable in run
android.os.Handler in handleCallback at line 751
android.os.Handler in dispatchMessage at line 95
com.facebook.react.bridge.queue.MessageQueueThreadHandler in dispatchMessage
android.os.Looper in loop at line 154
com.facebook.react.bridge.queue.MessageQueueThreadImpl$4 in run
java.lang.Thread in run at line 762

@AndreyPatseiko
Copy link

Like said @mhkhung I added simple delay into run application, and for now I don't getting crash in first time start application. But I getted crashes on other screens just when they start rendering.
I don't think adding delay on all screens it's good solution.
I use RN 0.55.

image

@sebqq
Copy link

sebqq commented Jun 19, 2019

Anything new about this issue? My error logs are getting blaoted from this type of crashes... It only happens on Samsung devices. What can I do to prevent this issue from happening?

@mhkhung
Copy link

mhkhung commented Jun 25, 2019

I found the best way to fix this is patch your old RN before building. You can't easily fork RN as it needs some kind of build step..

Create a patch file and apply the patch before build with a command inside package.json
$ cat DynamicFromMap.patch

--- node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/DynamicFromMap.jav2018-11-28 15:32:26.000000000 -0500
+++ node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/DynamicFromMap_new.java	2019-06-24 14:15:12.000000000 -0400
@@ -9,13 +9,18 @@
 
 import javax.annotation.Nullable;
 
-import android.support.v4.util.Pools;
+import android.support.v4.util.Pools.SimplePool;
 
 /**
  * Implementation of Dynamic wrapping a ReadableMap.
  */
 public class DynamicFromMap implements Dynamic {
-  private static final Pools.SimplePool<DynamicFromMap> sPool = new Pools.SimplePool<>(10);
+  private static final ThreadLocal<SimplePool<DynamicFromMap>> sPool = new ThreadLocal<SimplePool<DynamicFromMap>>() {
+    @Override
+    protected SimplePool<DynamicFromMap> initialValue() {
+      return new SimplePool<>(10);
+    }
+  };
 
   private @Nullable ReadableMap mMap;
   private @Nullable String mName;
@@ -24,7 +29,7 @@
   private DynamicFromMap() {}
 
   public static DynamicFromMap create(ReadableMap map, String name) {
-    DynamicFromMap dynamic = sPool.acquire();
+    DynamicFromMap dynamic = sPool.get().acquire();
     if (dynamic == null) {
       dynamic = new DynamicFromMap();
     }
@@ -37,7 +42,7 @@
   public void recycle() {
     mMap = null;
     mName = null;
-    sPool.release(this);
+    sPool.get().release(this);
   }
 
   @Override

I run patch.. (you need || true so it doesn't fail when the patch is already applied during build)

"patch:android":  "cd node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge && (patch -N -i ../../../../../../../../../../src/scripts/DynamicFromMap.patch || true) && cd -"

I have also created another patch for FrameBasedAnimationDriver crash issue the same way based on https://github.com/facebook/react-native/pull/19808/files

@bigggge
Copy link

bigggge commented Jul 23, 2019

This error still happens in RN 0.59.8 and it only happens on Samsung S7 & S7 edge

# OS Version: 7.0
# Device: Galaxy S7 Edge
# RAM Free: 38.4%
# Disk Free: 3.8%

#0. Crashed: main
       at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp + 95(ViewManagersPropertyCache.java:95)
       at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty + 132(ViewManagerPropertyUpdater.java:132)
       at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps + 51(ViewManagerPropertyUpdater.java:51)
       at com.facebook.react.uimanager.ViewManager.updateProperties + 37(ViewManager.java:37)
       at com.facebook.react.uimanager.NativeViewHierarchyManager.updateProperties + 136(NativeViewHierarchyManager.java:136)
       at com.facebook.react.uimanager.UIViewOperationQueue$UpdatePropertiesOperation.execute + 95(UIViewOperationQueue.java:95)
       at com.facebook.react.uimanager.UIViewOperationQueue$1.run + 917(UIViewOperationQueue.java:917)
       at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches + 1025(UIViewOperationQueue.java:1025)
       at com.facebook.react.uimanager.UIViewOperationQueue.access$2600 + 46(UIViewOperationQueue.java:46)
       at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded + 1085(UIViewOperationQueue.java:1085)
       at com.facebook.react.uimanager.GuardedFrameCallback.doFrame + 29(GuardedFrameCallback.java:29)
       at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame + 166(ReactChoreographer.java:166)
       at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame + 84(ChoreographerCompat.java:84)
       at android.view.Choreographer$CallbackRecord.run + 925(Choreographer.java:925)
       at android.view.Choreographer.doCallbacks + 702(Choreographer.java:702)
       at android.view.Choreographer.doFrame + 635(Choreographer.java:635)
       at android.view.Choreographer$FrameDisplayEventReceiver.run + 913(Choreographer.java:913)
       at android.os.Handler.handleCallback + 751(Handler.java:751)
       at android.os.Handler.dispatchMessage + 95(Handler.java:95)
       at android.os.Looper.loop + 154(Looper.java:154)
       at android.app.ActivityThread.main + 6692(ActivityThread.java:6692)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 1468(ZygoteInit.java:1468)
       at com.android.internal.os.ZygoteInit.main + 1358(ZygoteInit.java:1358)

--

Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'opacity' of a view managed by: RCTView
       at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp + 95(ViewManagersPropertyCache.java:95)
       at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty + 132(ViewManagerPropertyUpdater.java:132)
       at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps + 51(ViewManagerPropertyUpdater.java:51)
       at com.facebook.react.uimanager.ViewManager.updateProperties + 37(ViewManager.java:37)
       at com.facebook.react.uimanager.NativeViewHierarchyManager.updateProperties + 136(NativeViewHierarchyManager.java:136)
       at com.facebook.react.uimanager.UIViewOperationQueue$UpdatePropertiesOperation.execute + 95(UIViewOperationQueue.java:95)
       at com.facebook.react.uimanager.UIViewOperationQueue$1.run + 917(UIViewOperationQueue.java:917)
       at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches + 1025(UIViewOperationQueue.java:1025)
       at com.facebook.react.uimanager.UIViewOperationQueue.access$2600 + 46(UIViewOperationQueue.java:46)
       at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded + 1085(UIViewOperationQueue.java:1085)
       at com.facebook.react.uimanager.GuardedFrameCallback.doFrame + 29(GuardedFrameCallback.java:29)
       at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame + 166(ReactChoreographer.java:166)
       at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame + 84(ChoreographerCompat.java:84)
       at android.view.Choreographer$CallbackRecord.run + 925(Choreographer.java:925)
       at android.view.Choreographer.doCallbacks + 702(Choreographer.java:702)
       at android.view.Choreographer.doFrame + 635(Choreographer.java:635)
       at android.view.Choreographer$FrameDisplayEventReceiver.run + 913(Choreographer.java:913)
       at android.os.Handler.handleCallback + 751(Handler.java:751)
       at android.os.Handler.dispatchMessage + 95(Handler.java:95)
       at android.os.Looper.loop + 154(Looper.java:154)
       at android.app.ActivityThread.main + 6692(ActivityThread.java:6692)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 1468(ZygoteInit.java:1468)
       at com.android.internal.os.ZygoteInit.main + 1358(ZygoteInit.java:1358)

Caused by java.lang.ClassCastException: Value for opacity cannot be cast from ReadableNativeMap to Double
       at com.facebook.react.bridge.ReadableNativeMap.checkInstance + 150(ReadableNativeMap.java:150)
       at com.facebook.react.bridge.ReadableNativeMap.getValue + 129(ReadableNativeMap.java:129)
       at com.facebook.react.bridge.ReadableNativeMap.getDouble + 170(ReadableNativeMap.java:170)
       at com.facebook.react.uimanager.ReactStylesDiffMap.getFloat + 62(ReactStylesDiffMap.java:62)
       at com.facebook.react.uimanager.ViewManagersPropertyCache$FloatPropSetter.extractProperty + 210(ViewManagersPropertyCache.java:210)
       at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp + 82(ViewManagersPropertyCache.java:82)
       at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty + 132(ViewManagerPropertyUpdater.java:132)
       at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps + 51(ViewManagerPropertyUpdater.java:51)
       at com.facebook.react.uimanager.ViewManager.updateProperties + 37(ViewManager.java:37)
       at com.facebook.react.uimanager.NativeViewHierarchyManager.updateProperties + 136(NativeViewHierarchyManager.java:136)
       at com.facebook.react.uimanager.UIViewOperationQueue$UpdatePropertiesOperation.execute + 95(UIViewOperationQueue.java:95)
       at com.facebook.react.uimanager.UIViewOperationQueue$1.run + 917(UIViewOperationQueue.java:917)
       at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches + 1025(UIViewOperationQueue.java:1025)
       at com.facebook.react.uimanager.UIViewOperationQueue.access$2600 + 46(UIViewOperationQueue.java:46)
       at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded + 1085(UIViewOperationQueue.java:1085)
       at com.facebook.react.uimanager.GuardedFrameCallback.doFrame + 29(GuardedFrameCallback.java:29)
       at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame + 166(ReactChoreographer.java:166)
       at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame + 84(ChoreographerCompat.java:84)
       at android.view.Choreographer$CallbackRecord.run + 925(Choreographer.java:925)
       at android.view.Choreographer.doCallbacks + 702(Choreographer.java:702)
       at android.view.Choreographer.doFrame + 635(Choreographer.java:635)
       at android.view.Choreographer$FrameDisplayEventReceiver.run + 913(Choreographer.java:913)
       at android.os.Handler.handleCallback + 751(Handler.java:751)
       at android.os.Handler.dispatchMessage + 95(Handler.java:95)
       at android.os.Looper.loop + 154(Looper.java:154)
       at android.app.ActivityThread.main + 6692(ActivityThread.java:6692)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 1468(ZygoteInit.java:1468)
       at com.android.internal.os.ZygoteInit.main + 1358(ZygoteInit.java:1358)

#0. Crashed: main
       at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp + 95(ViewManagersPropertyCache.java:95)
       at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty + 132(ViewManagerPropertyUpdater.java:132)
       at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps + 51(ViewManagerPropertyUpdater.java:51)
       at com.facebook.react.uimanager.ViewManager.updateProperties + 37(ViewManager.java:37)
       at com.facebook.react.uimanager.NativeViewHierarchyManager.updateProperties + 136(NativeViewHierarchyManager.java:136)
       at com.facebook.react.uimanager.UIViewOperationQueue$UpdatePropertiesOperation.execute + 95(UIViewOperationQueue.java:95)
       at com.facebook.react.uimanager.UIViewOperationQueue$1.run + 917(UIViewOperationQueue.java:917)
       at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches + 1025(UIViewOperationQueue.java:1025)
       at com.facebook.react.uimanager.UIViewOperationQueue.access$2600 + 46(UIViewOperationQueue.java:46)
       at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded + 1085(UIViewOperationQueue.java:1085)
       at com.facebook.react.uimanager.GuardedFrameCallback.doFrame + 29(GuardedFrameCallback.java:29)
       at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame + 166(ReactChoreographer.java:166)
       at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame + 84(ChoreographerCompat.java:84)
       at android.view.Choreographer$CallbackRecord.run + 925(Choreographer.java:925)
       at android.view.Choreographer.doCallbacks + 702(Choreographer.java:702)
       at android.view.Choreographer.doFrame + 635(Choreographer.java:635)
       at android.view.Choreographer$FrameDisplayEventReceiver.run + 913(Choreographer.java:913)
       at android.os.Handler.handleCallback + 751(Handler.java:751)
       at android.os.Handler.dispatchMessage + 95(Handler.java:95)
       at android.os.Looper.loop + 154(Looper.java:154)
       at android.app.ActivityThread.main + 6692(ActivityThread.java:6692)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 1468(ZygoteInit.java:1468)
       at com.android.internal.os.ZygoteInit.main + 1358(ZygoteInit.java:1358)

@sebqq
Copy link

sebqq commented Jul 23, 2019

@bigggge Hello there! I suggest you to upgrade react-native version to at least 0.59.10! This version contains newer version of JSC which is preventing from exactly these errors in your app.

@prof18
Copy link

prof18 commented Jul 25, 2019

If you are integrating the React Native app into an existing native app, make sure that you are using a single instance of ReactInstanceManager, not multiple ones (as stated in the doc). After using a single instance for all the screens these kinds of crashes are gone.

A ReactInstanceManager can be shared by multiple activities and/or fragments. You will want to make your own ReactFragment or ReactActivity and have a singleton holder that holds a ReactInstanceManager. When you need the ReactInstanceManager (e.g., to hook up the ReactInstanceManager to the lifecycle of those Activities or Fragments) use the one provided by the singleton.

@tsdmrfth
Copy link

eventing from exactly these errors

@sinodko In last version of our application i upgraded RN version to 0.59.10 and still this error occurs

@ph-teven
Copy link

ph-teven commented Aug 1, 2019

@prof18 Thank you for this!

@RenderCoder
Copy link

If you are integrating the React Native app into an existing native app, make sure that you are using a single instance of ReactInstanceManager, not multiple ones (as stated in the doc). After using a single instance for all the screens these kinds of crashes are gone.

A ReactInstanceManager can be shared by multiple activities and/or fragments. You will want to make your own ReactFragment or ReactActivity and have a singleton holder that holds a ReactInstanceManager. When you need the ReactInstanceManager (e.g., to hook up the ReactInstanceManager to the lifecycle of those Activities or Fragments) use the one provided by the singleton.

In some case, I need multiple activities run many react native project in one application. How can I use on ReactInstanceManager?

@RenderCoder
Copy link

In my use case, I found that Android device only support update one react native render when a huge count of data coming from remote server (at least 100ms one message, and need to do complex computing and render). If I start render multiple react native project at the same time, it would easy occurs this error.

@HarikaSabbella
Copy link

HarikaSabbella commented Sep 6, 2019

We are seeing a lot of these crashes in Android and are on RN 59.10. Are there any plans to fix this soon?

@mengai123
Copy link

I have the same problem on android.

react-native version: 0.44.3

errror log:

[ { "brandName": "魅族", "failMsg": "// CRASH: com.trc.mall (pid 17247) Short Msg: java.lang.IllegalStateException Long Msg: java.lang.IllegalStateException: Already in the pool! Build Label: Meizu/MeizuE3_CN/MeizuE3:7.1.1/NGI77B/1555904595:user/release-keys Build Changelist: 1555904595 Build Time: 1559102560000 com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'right' in shadow node of type: RCTView com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(TbsSdkJava:111) com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(TbsSdkJava:148) com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(TbsSdkJava:52) com.facebook.react.uimanager.ReactShadowNode.updateProperties(TbsSdkJava:265) com.facebook.react.uimanager.UIImplementation.createView(TbsSdkJava:197) com.facebook.react.uimanager.UIManagerModule.createView(TbsSdkJava:246) java.lang.reflect.Method.invoke(Native Method) com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(TbsSdkJava:368) com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(TbsSdkJava:138) com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) android.os.Handler.handleCallback(Handler.java:751) android.os.Handler.dispatchMessage(Handler.java:95) com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(TbsSdkJava:31) android.os.Looper.loop(Looper.java:154) com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(TbsSdkJava:208) java.lang.Thread.run(Thread.java:761) Caused by: java.lang.reflect.InvocationTargetException java.lang.reflect.Method.invoke(Native Method) com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(TbsSdkJava:105) \t... 15 more Caused by: java.lang.IllegalStateException: Already in the pool! android.support.v4.util.Pools$SimplePool.release(TbsSdkJava:117) com.facebook.react.bridge.DynamicFromMap.recycle(TbsSdkJava:42) com.facebook.react.uimanager.LayoutShadowNode.setPositionValues(TbsSdkJava:651) \t... 17 more \n", "modelName": "MeizuE3_CN", "osVersion": "Flyme 7.3.0.0A" }, { "brandName": "魅族", "failMsg": "// CRASH: com.trc.mall (pid 31698) Short Msg: java.lang.IllegalArgumentException Long Msg: java.lang.IllegalArgumentException: method com.facebook.react.uimanager.LayoutShadowNode.setFlex argument 1 has type float, got null Build Label: Meizu/meizu_16thPlus_CN/16thPlus:8.1.0/OPM1.171019.026/1554749351:user/release-keys Build Changelist: 1554749351 Build Time: 1561099390000 com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'flex' in shadow node of type: RCTView com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(TbsSdkJava:111) com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(TbsSdkJava:148) com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(TbsSdkJava:52) com.facebook.react.uimanager.ReactShadowNode.updateProperties(TbsSdkJava:265) com.facebook.react.uimanager.UIImplementation.createView(TbsSdkJava:197) com.facebook.react.uimanager.UIManagerModule.createView(TbsSdkJava:246) java.lang.reflect.Method.invoke(Native Method) com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(TbsSdkJava:368) com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(TbsSdkJava:138) com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) android.os.Handler.handleCallback(Handler.java:790) android.os.Handler.dispatchMessage(Handler.java:99) com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(TbsSdkJava:31) android.os.Looper.loop(Looper.java:164) com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(TbsSdkJava:208) java.lang.Thread.run(Thread.java:764) Caused by: java.lang.IllegalArgumentException: method com.facebook.react.uimanager.LayoutShadowNode.setFlex argument 1 has type float, got null java.lang.reflect.Method.invoke(Native Method) com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(TbsSdkJava:100) \t... 15 more \n", "modelName": "meizu_16thPlus_CN", "osVersion": "Flyme 7.3.0.0A" } ]

@stale
Copy link

stale bot commented Dec 29, 2019

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. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 29, 2019
@stale
Copy link

stale bot commented Jan 5, 2020

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.

@stale stale bot closed this as completed Jan 5, 2020
@facebook facebook locked as resolved and limited conversation to collaborators Jan 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Resolution: Fixed A PR that fixes this issue has been merged. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests