{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/11524","repository_url":"https://api.github.com/repos/facebook/react-native","labels_url":"https://api.github.com/repos/facebook/react-native/issues/11524/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/11524/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/11524/events","html_url":"https://github.com/facebook/react-native/issues/11524","id":196219126,"number":11524,"title":"[Android]very dangerous thread safe issue","user":{"login":"littlesome","id":7804648,"avatar_url":"https://avatars0.githubusercontent.com/u/7804648?v=3","gravatar_id":"","url":"https://api.github.com/users/littlesome","html_url":"https://github.com/littlesome","followers_url":"https://api.github.com/users/littlesome/followers","following_url":"https://api.github.com/users/littlesome/following{/other_user}","gists_url":"https://api.github.com/users/littlesome/gists{/gist_id}","starred_url":"https://api.github.com/users/littlesome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/littlesome/subscriptions","organizations_url":"https://api.github.com/users/littlesome/orgs","repos_url":"https://api.github.com/users/littlesome/repos","events_url":"https://api.github.com/users/littlesome/events{/privacy}","received_events_url":"https://api.github.com/users/littlesome/received_events","type":"User","site_admin":false},"labels":[{"id":260305031,"url":"https://api.github.com/repos/facebook/react-native/labels/Android","name":"Android","color":"bfe5bf","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-17T12:14:28Z","updated_at":"2017-05-25T21:13:01Z","closed_at":"2017-05-25T21:13:01Z","body":"I got some IllegalViewOperationException from:\r\nUIImplementation.updateView\r\nUIImplementation.setChildren ...\r\n\r\nand I add some log to debug this:\r\n```Java\r\n  protected final void removeShadowNode(ReactShadowNode nodeToRemove) {\r\n    mNativeViewHierarchyOptimizer.handleRemoveNode(nodeToRemove);\r\n    // add log here\r\n    Log.e(\"Remove\", \"tag:\" + nodeToRemove.getReactTag());\r\n    mShadowNodeRegistry.removeNode(nodeToRemove.getReactTag());\r\n    for (int i = nodeToRemove.getChildCount() - 1; i >= 0; i--) {\r\n      removeShadowNode(nodeToRemove.getChildAt(i));\r\n    }\r\n    nodeToRemove.removeAllChildren();\r\n  }\r\n\r\n  public void registerRootView(\r\n      SizeMonitoringFrameLayout rootView,\r\n      int tag,\r\n      int width,\r\n      int height,\r\n      int sizeFlexibility,\r\n      ThemedReactContext context) {\r\n    final ReactShadowNode rootCSSNode = createRootShadowNode();\r\n    rootCSSNode.setReactTag(tag);\r\n    rootCSSNode.setThemedContext(context);\r\n    rootCSSNode.setStyleWidth(width);\r\n    rootCSSNode.setStyleHeight(height);\r\n    rootCSSNode.setSizeFlexibility(sizeFlexibility);\r\n\r\n    // add log here\r\n    Log.e(\"Add\", \"root \" + tag);\r\n    mShadowNodeRegistry.addRootNode(rootCSSNode);\r\n\r\n    // register it within NativeViewHierarchyManager\r\n    mOperationsQueue.addRootView(tag, rootView, context);\r\n  }\r\n\r\n  public void createView(int tag, String className, int rootViewTag, ReadableMap props) {\r\n    ReactShadowNode cssNode = createShadowNode(className);\r\n    ReactShadowNode rootNode = mShadowNodeRegistry.getNode(rootViewTag);\r\n    cssNode.setReactTag(tag);\r\n    cssNode.setViewClassName(className);\r\n    cssNode.setRootNode(rootNode);\r\n    cssNode.setThemedContext(rootNode.getThemedContext());\r\n\r\n    // add log here\r\n    Log.e(\"Add\", \"view:\" + tag);\r\n    mShadowNodeRegistry.addNode(cssNode);\r\n\r\n    ReactStylesDiffMap styles = null;\r\n    if (props != null) {\r\n      styles = new ReactStylesDiffMap(props);\r\n      cssNode.updateProperties(styles);\r\n    }\r\n\r\n    handleCreateView(cssNode, rootViewTag, styles);\r\n  }\r\n\r\n```\r\n\r\nhere is the logcat output:\r\n\r\n```\r\n12-17 19:19:13.774 30602-30753/com.GF.platform E/Add: view:974\r\n12-17 19:19:13.774 30602-30753/com.GF.platform E/Add: view:975\r\n12-17 19:19:13.784 30602-30753/com.GF.platform E/Add: view:976\r\n12-17 19:19:14.245 30602-30753/com.GF.platform E/Add: view:977\r\n12-17 19:19:14.255 30602-30753/com.GF.platform E/Add: view:978\r\n12-17 19:19:14.275 30602-30753/com.GF.platform E/Remove: tag:958\r\n12-17 19:19:14.275 30602-30753/com.GF.platform E/Remove: tag:959\r\n12-17 19:19:14.275 30602-30753/com.GF.platform E/Remove: tag:962\r\n12-17 19:19:14.275 30602-30753/com.GF.platform E/Remove: tag:963\r\n12-17 19:19:14.275 30602-30753/com.GF.platform E/Remove: tag:960\r\n12-17 19:19:14.325 30602-30753/com.GF.platform E/Add: view:979\r\n12-17 19:19:14.345 30602-30753/com.GF.platform E/Add: view:980\r\n12-17 19:19:14.365 30602-30753/com.GF.platform E/Remove: tag:969\r\n12-17 19:19:14.365 30602-30753/com.GF.platform E/Remove: tag:970\r\n12-17 19:19:14.365 30602-30753/com.GF.platform E/Remove: tag:973\r\n12-17 19:19:14.365 30602-30753/com.GF.platform E/Remove: tag:974\r\n12-17 19:19:14.365 30602-30753/com.GF.platform E/Remove: tag:972\r\n12-17 19:19:14.535 30602-30602/com.GF.platform E/Add: root 221\r\n12-17 19:19:14.555 30602-30602/com.GF.platform E/Add: root 231\r\n12-17 19:19:14.555 30602-30602/com.GF.platform E/Add: root 241\r\n12-17 19:19:14.555 30602-30602/com.GF.platform E/Add: root 251\r\n12-17 19:19:14.555 30602-30602/com.GF.platform E/Add: root 261\r\n12-17 19:19:14.565 30602-30602/com.GF.platform E/Add: root 271\r\n12-17 19:19:14.565 30602-30602/com.GF.platform E/Add: root 281\r\n12-17 19:19:14.565 30602-30602/com.GF.platform E/Add: root 291\r\n12-17 19:19:14.565 30602-30602/com.GF.platform E/Add: root 301\r\n12-17 19:19:14.565 30602-30602/com.GF.platform E/Add: root 311\r\n12-17 19:19:14.565 30602-30602/com.GF.platform E/Add: root 321\r\n12-17 19:19:14.575 30602-30602/com.GF.platform E/Add: root 331\r\n12-17 19:19:14.575 30602-30602/com.GF.platform E/Add: root 341\r\n12-17 19:19:14.575 30602-30602/com.GF.platform E/Add: root 351\r\n12-17 19:19:14.575 30602-30753/com.GF.platform E/unknown:React: Exception in native call\r\n                                                                com.facebook.react.uimanager.IllegalViewOperationException: Trying to update non-existent view with tag 980\r\n                                                                    at com.facebook.react.uimanager.UIImplementation.updateView(UIImplementation.java:196)\r\n                                                                    at com.facebook.react.uimanager.UIManagerModule.updateView(UIManagerModule.java:216)\r\n                                                                    at java.lang.reflect.Method.invoke(Native Method)\r\n                                                                    at java.lang.reflect.Method.invoke(Method.java:372)\r\n                                                                    at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:322)\r\n                                                                    at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)\r\n                                                                    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)\r\n                                                                    at android.os.Handler.handleCallback(Handler.java:739)\r\n                                                                    at android.os.Handler.dispatchMessage(Handler.java:95)\r\n                                                                    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)\r\n                                                                    at android.os.Looper.loop(Looper.java:135)\r\n                                                                    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)\r\n                                                                    at java.lang.Thread.run(Thread.java:818)\r\n\r\n\r\n```\r\n\r\nSee view with tag 980 is already added to the registry through thread:30753 (the message queue thread)\r\nand then some root views are created and registered through thread:30602 (the main thread)\r\nthis breaks the registry. In the source of ShadowNodeRegistry there is a TODO\r\n\r\n```Java\r\n  public void addRootNode(ReactShadowNode node) {\r\n    // TODO(6242243): This should be asserted... but UIManagerModule is\r\n    // thread-unsafe and calls this on the wrong thread.\r\n    //mThreadAsserter.assertNow();\r\n    int tag = node.getReactTag();\r\n    mTagsToCSSNodes.put(tag, node);\r\n    mRootTags.put(tag, true);\r\n  }\r\n```\r\n\r\nI think this is an known issue, and this may be very dangerous, when this will be fixed? \r\n\r\n\r\n### Additional Information\r\n\r\n* React Native version: 0.33.0\r\n* Platform: Android\r\n* Operating System: Windows\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/304126260","html_url":"https://github.com/facebook/react-native/issues/11524#issuecomment-304126260","issue_url":"https://api.github.com/repos/facebook/react-native/issues/11524","id":304126260,"user":{"login":"hramos","id":165856,"avatar_url":"https://avatars0.githubusercontent.com/u/165856?v=3","gravatar_id":"","url":"https://api.github.com/users/hramos","html_url":"https://github.com/hramos","followers_url":"https://api.github.com/users/hramos/followers","following_url":"https://api.github.com/users/hramos/following{/other_user}","gists_url":"https://api.github.com/users/hramos/gists{/gist_id}","starred_url":"https://api.github.com/users/hramos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hramos/subscriptions","organizations_url":"https://api.github.com/users/hramos/orgs","repos_url":"https://api.github.com/users/hramos/repos","events_url":"https://api.github.com/users/hramos/events{/privacy}","received_events_url":"https://api.github.com/users/hramos/received_events","type":"User","site_admin":false},"created_at":"2017-05-25T21:13:01Z","updated_at":"2017-05-25T21:13:01Z","body":"We're cutting down on the number of outstanding issues, in order to allow us to focus. I'm closing this issue because it has been open for over 60 days with no activity. If you think it should still be opened let us know why. PRs are always welcome."}}
{"actor":{"display_login":"hramos"}}