Skip to content

Android crash due to ArrayIndexOutOfBoundsException in Pool of DynamicFromMap #19141

@alexdeleon

Description

@alexdeleon

I getting this exception every now and then in an Android production App. I have not been able to find a systematic way to reproduce it, but It always occurs while setting some style property of a View. For instance:

Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'paddingTop' 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:154)

By inspecting the code it seems like the object pool in com.facebook.react.bridge.DynamicFromMap is accessed from multiple treads leading to its internal variable mPoolSize become -1 in android.support.v4.util.Pool

The exception is the following:

Caused by java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1
       at android.support.v4.util.Pools$SimplePool.release(Pools.java:120)
       at com.facebook.react.bridge.DynamicFromMap.recycle(DynamicFromMap.java:42)
       at com.facebook.react.uimanager.LayoutShadowNode.setPaddings(LayoutShadowNode.java:612)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:110)
       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.ReactShadowNode.updateProperties(ReactShadowNode.java:273)
       at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:205)
       at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:243)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:363)
       at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
       at com.facebook.react.bridge.queue.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:31)
       at android.os.Looper.loop(Looper.java:154)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
       at java.lang.Thread.run(Thread.java:762)

Environment

Environment:
OS: macOS High Sierra 10.13.4
Node: 8.9.4
Yarn: 1.3.2
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.3 Build version 9E145
Android Studio: 3.1 AI-173.4720617

Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: 0.49.3 => 0.49.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Platform: AndroidAndroid applications.Ran CommandsOne of our bots successfully processed a command.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions