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

Error while updating property 'selectionColor' on 0.43.3 in Android #13465

Closed
krailler opened this issue Apr 12, 2017 · 8 comments
Closed

Error while updating property 'selectionColor' on 0.43.3 in Android #13465

krailler opened this issue Apr 12, 2017 · 8 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@krailler
Copy link

krailler commented Apr 12, 2017

Description

When updating to React 0.43.3, when I use the selectionColor property in TextInput on Android, it gives me the following error message. Did something change? In the documentation is still as before.

Error while updating property 'selectionColor' of a view managed by: AndroidTextInput.

This has something to do? ae57b25

Reproduction Steps and Sample Code

<TextInput selectionColor="red" />

Additional Information

  • React Native version: 0.43.3
  • Platform: Android
  • Development Operating System: MacOS
krailler referenced this issue Apr 17, 2017
Summary:
**Motivation**

Customizing the selection color allows to use brand colors in the app. The PR implements a `selectionColor` prop for `Text` component similar to `TextInput`.

**Test plan (required)**

Run UIExplorer example with the changes and verify everything works fine.

![image](https://cloud.githubusercontent.com/assets/1174278/22023258/70197d84-dceb-11e6-8662-2879d78d14d4.png)

cc brentvatne
Closes #11947

Differential Revision: D4430265

fbshipit-source-id: 462f16548d93ab03aadb27d6f12acf90842627ab
krailler referenced this issue Apr 17, 2017
Summary:
This matches the behavior on iOS, there was no way before to change the cursor color per input, it was only possible to change it globally via the theme. Ideally cursor color and selection color would be 2 different props but I think this is better than what we have (and matches iOS).

Sadly there is no api to change it pragmatically (only possible via xml) so this uses reflection and can easily break so it is wrapped in a try catch to avoid crashes. I think it is better to just silently fail in this case. Definetly not super happy about the solution but I think it's worth adding since it is possible to do it natively using xml so it would suck not to be able to do it in RN.

**Test plan**
Tested that the cursor has the same color as before the change when not setting the prop and that it gets the selectionColor color when set.
Closes #12280

Differential Revision: D4571858

Pulled By: astreet

fbshipit-source-id: 7dca2db33a0a4eecb6115b45155549b1265ffbed
@janicduplessis
Copy link
Contributor

Are you able to show more logs of the error? Maybe with adb logcat. Also what version of android and device are you using?

@krailler
Copy link
Author

Thx @janicduplessis for your answer..

Device: Genymotion - Google Nexus 5X (7.0.0 API 24)
Logcat:

04-20 04:05:16.907 1245 1245 E unknown:ViewManager: Error while updating prop selectionColor
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: java.lang.reflect.InvocationTargetException
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at java.lang.reflect.Method.invoke(Native Method)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp(ViewManagersPropertyCache.java:78)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty(ViewManagerPropertyUpdater.java:123)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:42)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:36)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:227)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:152)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(UIViewOperationQueue.java:912)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:884)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:31)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:129)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:107)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:869)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at android.view.Choreographer.doCallbacks(Choreographer.java:683)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at android.view.Choreographer.doFrame(Choreographer.java:616)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at android.os.Handler.handleCallback(Handler.java:751)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at android.os.Handler.dispatchMessage(Handler.java:95)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at android.os.Looper.loop(Looper.java:154)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at android.app.ActivityThread.main(ActivityThread.java:6077)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at java.lang.reflect.Method.invoke(Native Method)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:190)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at android.content.res.Resources.getDrawable(Resources.java:766)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at android.content.Context.getDrawable(Context.java:525)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:26)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:372)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.facebook.react.views.textinput.ReactTextInputManager.setCursorColor(ReactTextInputManager.java:330)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: at com.facebook.react.views.textinput.ReactTextInputManager.setSelectionColor(ReactTextInputManager.java:317)
04-20 04:05:16.907 1245 1245 E unknown:ViewManager: ... 23 more
04-20 04:05:16.908 1245 1245 E unknown:React: Exception in native call
04-20 04:05:16.908 1245 1245 E unknown:React: com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'selectionColor' of a view managed by: AndroidTextInput
04-20 04:05:16.908 1245 1245 E unknown:React: at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp(ViewManagersPropertyCache.java:90)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty(ViewManagerPropertyUpdater.java:123)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:42)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:36)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:227)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:152)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(UIViewOperationQueue.java:912)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:884)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:31)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:129)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:107)
04-20 04:05:16.908 1245 1245 E unknown:React: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:869)
04-20 04:05:16.908 1245 1245 E unknown:React: at android.view.Choreographer.doCallbacks(Choreographer.java:683)
04-20 04:05:16.908 1245 1245 E unknown:React: at android.view.Choreographer.doFrame(Choreographer.java:616)
04-20 04:05:16.908 1245 1245 E unknown:React: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
04-20 04:05:16.908 1245 1245 E unknown:React: at android.os.Handler.handleCallback(Handler.java:751)
04-20 04:05:16.908 1245 1245 E unknown:React: at android.os.Handler.dispatchMessage(Handler.java:95)
04-20 04:05:16.908 1245 1245 E unknown:React: at android.os.Looper.loop(Looper.java:154)
04-20 04:05:16.908 1245 1245 E unknown:React: at android.app.ActivityThread.main(ActivityThread.java:6077)
04-20 04:05:16.908 1245 1245 E unknown:React: at java.lang.reflect.Method.invoke(Native Method)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
04-20 04:05:16.908 1245 1245 E unknown:React: Caused by: java.lang.reflect.InvocationTargetException
04-20 04:05:16.908 1245 1245 E unknown:React: at java.lang.reflect.Method.invoke(Native Method)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp(ViewManagersPropertyCache.java:78)
04-20 04:05:16.908 1245 1245 E unknown:React: ... 21 more
04-20 04:05:16.908 1245 1245 E unknown:React: Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
04-20 04:05:16.908 1245 1245 E unknown:React: at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:190)
04-20 04:05:16.908 1245 1245 E unknown:React: at android.content.res.Resources.getDrawable(Resources.java:766)
04-20 04:05:16.908 1245 1245 E unknown:React: at android.content.Context.getDrawable(Context.java:525)
04-20 04:05:16.908 1245 1245 E unknown:React: at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:26)
04-20 04:05:16.908 1245 1245 E unknown:React: at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:372)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.facebook.react.views.textinput.ReactTextInputManager.setCursorColor(ReactTextInputManager.java:330)
04-20 04:05:16.908 1245 1245 E unknown:React: at com.facebook.react.views.textinput.ReactTextInputManager.setSelectionColor(ReactTextInputManager.java:317)
04-20 04:05:16.908 1245 1245 E unknown:React: ... 23 more

@krailler
Copy link
Author

I'm trying to debug the error..

It's on this line when it stops working.
ae57b25#diff-a1e6ca3a6b1647be95d97e7890bcc11cR330

I do not know very well how it works ... I leave a catch of the debugger in case someone can help ...
image

@krailler
Copy link
Author

This is posible more real message?
captura de pantalla 2017-04-21 a las 13 04 07

@krailler
Copy link
Author

krailler commented Apr 21, 2017

I FOUND BUG!!!!
In my styles.xml I had defined:
<item name="android:textCursorDrawable">@null</item>
I delete it, and now works.

@janicduplessis
Copy link
Contributor

Nice! Thanks for figuring this out :)

@wuguokai
Copy link

@krailler @janicduplessis Thanks for yours!
I got same problem .could you help me make a solution.I thought it is cause by the UIThread but don't konw how to find and fix it.
It is the exception:

12-17 16:03:04.590 27632-27678/com.digitalplatform E/unknown:ViewManager: Error while updating prop onLayout
                                                                          java.lang.IllegalArgumentException: method com.facebook.react.uimanager.LayoutShadowNode.setShouldNotifyOnLayout argument 1 has type boolean, got null
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:105)
                                                                              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:272)
                                                                              at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:197)
                                                                              at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:249)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:363)
                                                                              at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:166)
                                                                              at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
                                                                              at android.os.Handler.handleCallback(Handler.java:754)
                                                                              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:163)
                                                                              at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
                                                                              at java.lang.Thread.run(Thread.java:760)
12-17 16:03:04.591 27632-27678/com.digitalplatform E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
                                                                     Process: com.digitalplatform, PID: 27632
                                                                     com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'onLayout' 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)
                                                                         at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58)
                                                                         at com.facebook.react.uimanager.ReactShadowNode.updateProperties(ReactShadowNode.java:272)
                                                                         at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:197)
                                                                         at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:249)
                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                         at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:363)
                                                                         at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:166)
                                                                         at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
                                                                         at android.os.Handler.handleCallback(Handler.java:754)
                                                                         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:163)
                                                                         at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
                                                                         at java.lang.Thread.run(Thread.java:760)
                                                                      Caused by: java.lang.IllegalArgumentException: method com.facebook.react.uimanager.LayoutShadowNode.setShouldNotifyOnLayout argument 1 has type boolean, got null
                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                         at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:105)
                                                                         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:272) 
                                                                         at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:197) 
                                                                         at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:249) 
                                                                         at java.lang.reflect.Method.invoke(Native Method) 
                                                                         at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:363) 
                                                                         at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:166) 
                                                                         at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
                                                                         at android.os.Handler.handleCallback(Handler.java:754) 
                                                                         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:163) 
                                                                         at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194) 
                                                                         at java.lang.Thread.run(Thread.java:760) 

@wuguokai
Copy link

@krailler @janicduplessis
The problem not only onLayout,sometime it is left ,sometime it is height or flex , weight.....
All is the css prop.
My project is use React-native on android

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants