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

Cannot add new property '__reanimatedHostObjectRef' #66

Closed
baronha opened this issue Dec 31, 2021 · 42 comments
Closed

Cannot add new property '__reanimatedHostObjectRef' #66

baronha opened this issue Dec 31, 2021 · 42 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@baronha
Copy link

baronha commented Dec 31, 2021

Simulator Screen Shot - iPhone 12 Pro Max - 2021-12-31 at 14 22 02

When I pass the data returned from the API I get an error: Cannot add new property '__reanimatedHostObjectRef'

@dohooo
Copy link
Owner

dohooo commented Dec 31, 2021

Interesting. I'll try

@dohooo
Copy link
Owner

dohooo commented Dec 31, 2021

Are there any examples that can be replicated?

@dohooo
Copy link
Owner

dohooo commented Dec 31, 2021

Hi? Look forward to solving your problem, but I need an example.

@dohooo
Copy link
Owner

dohooo commented Jan 1, 2022

If there is Demo, I will reopen it.

@dohooo dohooo closed this as completed Jan 1, 2022
@Wuyialex
Copy link

i have same issue with reaniamted@2.3.0-beta4

@dohooo
Copy link
Owner

dohooo commented Jan 15, 2022

i have same issue with reaniamted@2.3.0-beta4

Are there any examples that can be replicated?

@dohooo dohooo reopened this Jan 15, 2022
@Wuyialex
Copy link

i have same issue with reaniamted@2.3.0-beta4

Are there any examples that can be replicated?

i have same issue with reaniamted@2.3.0-beta4

Are there any examples that can be replicated?

I'm sorry. It doesn't seem to have anything to do with the reanimated version. It seems to happen in a specific layout situation, so I'm looking for the cause

@Wuyialex
Copy link

i have same issue with reaniamted@2.3.0-beta4

Are there any examples that can be replicated?

The component that caused the error is as follows.
image

@Wuyialex
Copy link

i have same issue with reaniamted@2.3.0-beta4

Are there any examples that can be replicated?

The component that caused the error is as follows. image

In my opinion, this problem seems to occur when a specific type of object is included in the data array. For example, if you put [1,2,3] in data, no error occurs.

@Wuyialex
Copy link

i have same issue with reaniamted@2.3.0-beta4

Are there any examples that can be replicated?

The component that caused the error is as follows. image

In my opinion, this problem seems to occur when a specific type of object is included in the data array. For example, if you put [1,2,3] in data, no error occurs.

I found the cause. This error occurs when JSX is included in the item object of data.

image

@baronha
Copy link
Author

baronha commented Jan 16, 2022

I used a very bad solution but can fix this for now and wait for later releases:

data={JSON.parse(JSON.stringfy(data)}

@dohooo
Copy link
Owner

dohooo commented Jan 16, 2022

Can you give me a repo to reproduce? I've tried many times and I still can't reproduce your problem.

@dohooo
Copy link
Owner

dohooo commented Jan 16, 2022

Can you give me a repo to reproduce? I've tried many times and I still can't reproduce your problem.

@baronha @Wuyialex

@c0nsoleg
Copy link

c0nsoleg commented Jan 22, 2022

@dohooo I am currently struggling with this error as well but I wasn't able to reproduce it outside my app. I have large array of objects where are other objects and arrays nested in each other but I am not quite sure if it is causing an error. When I am passing this object from my component props (data is fetched from api) to Carousel then I am getting an error but if I stringify it copy from console and put it instead then everything works fine (that's why baronha solution works).

@dohooo
Copy link
Owner

dohooo commented Jan 22, 2022

@dohooo I am currently struggling with this error as well but I wasn't able to reproduce it outside my app. I have large array of objects where are other objects and arrays nested in each other but I am not quite sure if it is causing an error. When I am passing this object from my component props (data is fetched from api) to Carousel then I am getting an error but if I stringify it copy from console and put it instead then everything works fine (that's why baronha solution works).

Show me a copy of your real data? it can be fake.

@c0nsoleg
Copy link

@dohooo Here it is

[
  {
    "object": {
      "name": "category-name",
      "color": "#F97316",
      "iconUrl": "https://via.placeholder.com/300.png"
    },
    "primary": [
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "PRIMARY",
          "object2": {
            "name": "category-name",
            "color": "#F97316",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "PRIMARY",
          "object2": {
            "name": "category-name",
            "color": "#F97316",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "PRIMARY",
          "object2": {
            "name": "category-name",
            "color": "#F97316",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      }
    ],
    "secondary": [
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#F97316",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#F97316",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#F97316",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#F97316",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      }
    ]
  },
  {
    "category": {
      "name": "category-name",
      "color": "#6366F1",
      "iconUrl": "https://via.placeholder.com/300.png"
    },
    "primary": [
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "PRIMARY",
          "object2": {
            "name": "category-name",
            "color": "#6366F1",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "PRIMARY",
          "object2": {
            "name": "category-name",
            "color": "#6366F1",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "PRIMARY",
          "object2": {
            "name": "category-name",
            "color": "#6366F1",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      }
    ],
    "secondary": [
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#6366F1",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#6366F1",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#6366F1",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#6366F1",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      }
    ]
  },
  {
    "category": {
      "name": "category-name",
      "color": "#4ade80",
      "iconUrl": "https://via.placeholder.com/300.png"
    },
    "primary": [
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "PRIMARY",
          "object2": {
            "name": "category-name",
            "color": "#4ade80",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "PRIMARY",
          "object2": {
            "name": "category-name",
            "color": "#4ade80",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "PRIMARY",
          "object2": {
            "name": "category-name",
            "color": "#4ade80",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      }
    ],
    "secondary": [
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#4ade80",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#4ade80",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#4ade80",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#4ade80",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      }
    ]
  },
  {
    "category": {
      "name": "category-name",
      "color": "#67E8F9",
      "iconUrl": "https://via.placeholder.com/300.png"
    },
    "primary": [
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "PRIMARY",
          "object2": {
            "name": "category-name",
            "color": "#67E8F9",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "PRIMARY",
          "object2": {
            "name": "category-name",
            "color": "#67E8F9",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "PRIMARY",
          "object2": {
            "name": "category-name",
            "color": "#67E8F9",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      }
    ],
    "secondary": [
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#67E8F9",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#67E8F9",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#67E8F9",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      },
      {
        "id": "some-string-ids",
        "number1": 1,
        "number2": 0,
        "object": {
          "name": "some-object-name",
          "type": "SECONDARY",
          "object2": {
            "name": "category-name",
            "color": "#67E8F9",
            "iconUrl": "https://via.placeholder.com/300.png"
          }
        }
      }
    ]
  }
]

@dohooo
Copy link
Owner

dohooo commented Jan 22, 2022

@c0nsoleg I may find the problem. Can you try it with me? Discord is here.

@dohooo
Copy link
Owner

dohooo commented Jan 22, 2022

https://discord.gg/KsXRuDs43y

@dohooo dohooo added the help wanted Extra attention is needed label Jan 23, 2022
@dohooo
Copy link
Owner

dohooo commented Jan 23, 2022

@dohooo dohooo pinned this issue Jan 23, 2022
@dohooo
Copy link
Owner

dohooo commented Jan 23, 2022

I don't think I can fix it any time soon because I really can't reproduce it. If someone can provide me with a stable repo, I'll try again, but I think I'll put it on hold... I'll pin this issue

@braandl
Copy link
Contributor

braandl commented Jan 24, 2022

Hm, I seldomly saw the same issue, but I did not have the time to investigate yet. Since the crash is in the native part of reanimated2, it could also be a ra2 bug? Also for me it only happend on android.

@dohooo
Copy link
Owner

dohooo commented Jan 25, 2022

Hm, I seldomly saw the same issue, but I did not have the time to investigate yet. Since the crash is in the native part of reanimated2, it could also be a ra2 bug? Also for me it only happend on android.

I also think it might be a bug in RA2

@anhquan291
Copy link

anhquan291 commented Jan 26, 2022

Simulator Screen Shot - iPhone 12 - 2022-01-26 at 21 22 22
This one happens when I use an array from redux. Temporary solution:
data={JSON.parse(JSON.stringify(data))}

@dohooo
Copy link
Owner

dohooo commented Jan 26, 2022

It seems that the reason is that the value we passed in was modified? We cut the association by “parser”. But how do we know what has been modified

@Saad-Bashar
Copy link

Thanks for the awesome library! However, I am having the same issue with data coming from API (Redux) :(

@anhquan291
Copy link

Thanks for the awesome library! However, I am having the same issue with data coming from API (Redux) :(

@Saad-Bashar use it
data={JSON.parse(JSON.stringify(data))}

@dohooo
Copy link
Owner

dohooo commented Feb 14, 2022

react-native-reanimated@2.4.0 was released. Did it fix this issue? Can anyone tell me about it

@braandl
Copy link
Contributor

braandl commented Feb 14, 2022

No, I'm sorry, the issue is still the same.

The Issue is still the same, but is now in line 38 instead of 28, probably due to code changes in reanimated.

@dohooo
Copy link
Owner

dohooo commented Feb 14, 2022

No, I'm sorry, the issue is still the same.

The Issue is still the same, but is now in line 38 instead of 28, probably due to code changes in reanimated.

That's an important clue. Maybe it's showing that it's not Carousel?

@braandl
Copy link
Contributor

braandl commented Feb 14, 2022

Hm, I am not 100% sure. Either that, or it is somehow used in an unsupported way. I have now an setup where I can directly reproduce this on Android, I'll investigate asap.

@braandl
Copy link
Contributor

braandl commented Feb 15, 2022

The issue happens like following:

When you assign data to the Carousel (in the data Props) and bind the exact same objects to another View.
When you then send the Object to any native Component, the Carousel will produce this exact error.

When you create a deep-copy before sending it to the native Module, e.g. by using

const myCopy = Object.assign({}, originalObject);

it will not crash anymore.

So apparently the RN Module Bridge does (maybe freeze?) the Object and therefore ruins it for Reanimated2.

My conclusion is, that this is a Reanimated2 issue, since it should check the Object's State and handle it properly, if the Object is e.g. frozen (or whatever it is, I did not dig into the bridge yet).

@dohooo
Copy link
Owner

dohooo commented Feb 15, 2022

The issue happens like following:

When you assign data to the Carousel (in the data Props) and bind the exact same objects to another View.

When you then send the Object to any native Component, the Carousel will produce this exact error.

When you create a deep-copy before sending it to the native Module, e.g. by using

const myCopy = Object.assign({}, originalObject);

it will not crash anymore.

So apparently the RN Module Bridge does (maybe freeze?) the Object and therefore ruins it for Reanimated2.

My conclusion is, that this is a Reanimated2 issue, since it should check the Object's State and handle it properly, if the Object is e.g. frozen (or whatever it is, I did not dig into the bridge yet).

Cool!The first thanks for your efforts!
It would be better if there is a repository that can reproduce this problem.

@yairopro
Copy link

software-mansion/react-native-reanimated#1517 (comment)

I made the repo

@dohooo
Copy link
Owner

dohooo commented Mar 25, 2022

The latest progress

KusStar added a commit to ncuhome/react-native-reanimated-carousel that referenced this issue Mar 29, 2022
KusStar added a commit to ncuhome/react-native-reanimated-carousel that referenced this issue Mar 30, 2022
@KusStar
Copy link
Contributor

KusStar commented Mar 30, 2022

We figured out that data used in reanimated hooks like useDerivedValue and useAnimatedReaction only access length, maybe we can move it to outside, instead of passing the whole data to reanimated worklet: ncuhome@7e46016

Do you think this will work?

@dohooo
Copy link
Owner

dohooo commented Mar 30, 2022

We figured out that data used in reanimated hooks like useDerivedValue and useAnimatedReaction only access length, maybe we can move it to outside, instead of passing the whole data to reanimated worklet: ncuhome@7e46016

Do you think this will work?

Wow, An interesting solutions. But I did't to try it, Dit you try it with above question? This does seem to have something to do with Redux, Can you reproduce the problem and test it?

@KusStar
Copy link
Contributor

KusStar commented Mar 30, 2022

We figured out that data used in reanimated hooks like useDerivedValue and useAnimatedReaction only access length, maybe we can move it to outside, instead of passing the whole data to reanimated worklet: ncuhome@7e46016
Do you think this will work?

Wow, An interesting solutions. But I did't to try it, Dit you try it with above question? This does seem to have something to do with Redux, Can you reproduce the problem and test it?

We use immer in our app, the same like Redux Toolkit does.
When passing data produced by immer to ReanimatedCarousel, will ocur the error.
But if we move length accessing outside like ncuhome@7e46016, the error fixed.
But we have not test totally, maybe there still are some edge cases we didn't test out.

@dohooo
Copy link
Owner

dohooo commented Mar 30, 2022

We figured out that data used in reanimated hooks like useDerivedValue and useAnimatedReaction only access length, maybe we can move it to outside, instead of passing the whole data to reanimated worklet: ncuhome@7e46016
Do you think this will work?

Wow, An interesting solutions. But I did't to try it, Dit you try it with above question? This does seem to have something to do with Redux, Can you reproduce the problem and test it?

We use immer in our app, the same like Redux Toolkit does. When passing data produced by immer to ReanimatedCarousel, will ocur the error. But if we move length accessing outside like ncuhome@7e46016, the error fixed. But we have not test totally, maybe there still are some edge cases we didn't test out.

Cool, Submit a PR and I'll release a beta version later and then ask everyone to give it a try

KusStar added a commit to ncuhome/react-native-reanimated-carousel that referenced this issue Mar 30, 2022
@dohooo dohooo self-assigned this Mar 30, 2022
@dohooo
Copy link
Owner

dohooo commented Mar 30, 2022

Try this!~ 🍺

yarn add react-native-reanimated-carousel@2.3.3-beta.1

@dohooo
Copy link
Owner

dohooo commented Mar 30, 2022

I will release the official version if the problem is fixed. @baronha @anhquan291 @KusStar @yairopro @braandl @Wuyialex @c0nsoleg

@dohooo
Copy link
Owner

dohooo commented Apr 3, 2022

It looks fine, I have released the official version, 2.3.3.

@dohooo dohooo closed this as completed Apr 3, 2022
@dohooo dohooo unpinned this issue Apr 4, 2022
@kosbog
Copy link

kosbog commented Oct 25, 2022

Faced with this issue in v3.1.1
This fix helps data={JSON.parse(JSON.stringify(data))}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants