react-native-reanimated: Constant crash when debugging on localhost (iOS only)

When debugging locally on simulator or device, I constantly get this redbox error:

ExceptionsManager.js:84 Exception thrown while executing UI block:
*** -[__NSArrayM setObject:atIndexedSubscript:]: object cannot be nil

Is this a known issue? I’d be happy to look into it, but I wanted to check if anybody was aware of it so far. It makes debugging very difficult.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 36 (13 by maintainers)

Most upvoted comments

Getting somewhere! If I remove the call

[nodesManager operationsBatchDidComplete];

in REAModule.m, the exceptions stop throwing. Looking at the documentation for (void)operationsBatchDidComplete in REANodesManager.m, it doesn’t seem like this call is absolutely necessary, and I’m not noticing any performance issues from the slightly deferred callback.

@kmagiera Would you mind weighing in on this? I can do a PR with the line removed, but it would help to know more about why it’s there and whether there are any conditional checks we could run instead of removing it.

Error was confirmed when I was using setValue() inside PanGestureHandler event callback. It seems like calling setValue() on a very frequent manner does cause this issue. Hopefully this can be addressed in a better form than fixing the .m file.

Here’s a minimal example that can reproduce this issue. It’s clear that this error occurs when calling setValue too quickly. I can also confirm that what @naftalibeder did above also did the trick in suppressing this error from happening.

Example

  useEffect(() => {
    let start = 0
    const interval = setInterval(() => {
        totalTime.setValue(start)
        start++
    }, 1)

    return () => clearInterval(interval)
  }, [])

Versions

  • React Native: 0.61.5
  • React Native Reanimated: 1.7.0

@vnlebaoduy As I mentioned above, you can avoid this during debugging by removing/commenting the line [nodesManager operationsBatchDidComplete] in REAModule.m. This has some unfortunate side effects, but makes debugging tolerable.

You don’t need to, but I put the line inside a preprocessor conditional:

#ifndef DEBUG
[nodesManager operationsBatchDidComplete];
#endif

@chiefchief, could you include the entire code? It’s way easier for us to debug it that way.

the problem was with snapTo, i had snapPoints - [0, value], and tried snap to value, but had to snapTo index, not value

RESOLVED: Problem was with incorrect points, have to add indexes

Well, I’ve encountered a situation where removing that method has a practical impact. Without it, calling setValue() on a node twice in quick succession fails the second time. So in some circumstances the line appears to be necessary.

Any update on this? Still experiencing it regularly.

Thank you all for your comments. From your reports I see that you are experiencing some issues, however from the maintainer perspective most of those comments aren’t really actionable. I’d be happy to take a look if you can post a link to github repo or expo snack which we can use to reproduce the problem.

it still crashes on me in debug mode, even after following what @naftalibeder did

Is there any movement on getting this fixed? Its coming up a bunch for us, and editing the .m file is not really a great solution.

@heyman333 As far as I’ve seen, yes.

@JulianKingman The first argument of call must be an array of animated nodes, it cannot be a string See here

Try call([], () => console.log('done')), or place your animated value inside the []