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.
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.
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.
How to fix this :'( . i alway see that when debugging
@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
@naftalibeder thanks <3
@naftalibeder this error occurs in debug mode only?
@heyman333 As far as I've seen, yes.
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.
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.
it still crashes on me in debug mode, even after following what @naftalibeder did
Same here
I believe @yolpsoftware found the cause. See https://github.com/kmagiera/react-native-reanimated/issues/397
In my case, it crashes if I'm using setValue inside call callback
I get the same crash when using call inside useCode
useCode(block([
...(otherstuff),
cond(
eq(state, State.END),
call(['done'], txt => console.log(txt)),
),
])
@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 []
Ping @kmagiera
Hi @Hirbod, could you provide some minimal code example that reproduces that, and which react-native and reanimated versions are you using?
Preferably using the template below
--- BUG REPORT ---
## Description
## Steps To Reproduce
1.
2.
## Expected behavior:
## Actual behavior:
## Snack or minimal code example:
<!--
Please provide a Snack ([https://snack.expo.io/](https://snack.expo.io/)) or provide a minimal code example that reproduces the problem.
Here are some tips for providing a minimal example: [https://stackoverflow.com/help/mcve](https://stackoverflow.com/help/mcve).
You can attach screenshots or GIFs as well.
-->
## Versions
<!--
Fill in your Reanimated and React Native versions below
-->
- React Native:
- React Native Reanimated:
I am also encountering this issue. I am not sure what causes it, but I started noticing it more as I used more calls in my code. (I'm using them to hook into different states like: enter, exit animations)
occurred to me too. and yes i am calling .setValue()in call multiple times.
Same here
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.
@kmagiera #397 might be a repro.
@kmagiera Still having this issue. It even crashes the whole Expo app. I have setValue() in a call too.
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.
I am experiencing this while setting value from onLayout callback of a View component to a Animated value object. Like this:
onLayout(event) {
const {nativeEvent: { layout: {x, y, width, height}}} = event
console.log("layout", x, y, width, height)
this.containerHeight.setValue(height)
}
Seeing the same exception in Xcode console.
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.
useEffect(() => {
let start = 0
const interval = setInterval(() => {
totalTime.setValue(start)
start++
}, 1)
return () => clearInterval(interval)
}, [])
Any update on this? Still experiencing it regularly.
Any update on this? Still a problem. When you use setValue, this crash happens all the time.
@ninjz, I wasn't able to repro this by your example, could you describe steps to notice that?
I enabled debugging and ran the app from the Xcode, no redbox, nothing in logs
Tried the repro with react-native-reanimated 1.9.0, 1.7.0 and 1.2.0. Unfortunately, no redbox in either version. Not sure why the repro worked earlier. Could it be caused by a newer version of RN?
@jakub-gonet Thank you for looking into the open bugs! When the error happens again, is there anything I can do to help narrow it down?
Thanks for the followup, anything that helps to debug it is helpful — repros, stack traces, library version (commit which introduced regression if you're able to find it), things like that. Especially repros are really convenient.
We are seeing crashes of the Expo app (running a expo published app) while running animations which have some setValue calls. The Expo app just disappears randomly while running those animations.
Is it possible that this is the same issue?
@jakub-gonet here's a crash log from the Expo app:
https://www.dropbox.com/s/m8vpokbafcse1i5/Exponent%20%2007.06.20%2C%2016-15.crash?dl=0
It seems the crash was triggered by the thread Dispatch queue: com.facebook.ABI36_0_0React.NetworkingQueue. What would we see in the crash log, if the crash was caused by this issue?
Frankly, hard to say. Looking at original issue (-[__NSArrayM setObject:atIndexedSubscript:]: object cannot be nil exception) it's happening when doing something in lines of:
some_array[i] = nil
and the only place where this can be happening is the findNodeByID call in the operator node.
We can't fix it without reproducing it unfortunately.
@chiefchief, could you include the entire code? It's way easier for us to debug it that way.
@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
i reproduced that issue by copying https://github.com/browniefed/react-native-ticker/blob/master/index.tsx to my components and using it as here
import React, { useState, useEffect } from "react";
import { View, StyleSheet } from "react-native";
import Ticker, { Tick } from "./ticker2";
function getRandom(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
const currencies = ["$", "¥", "€"];
const App = () => {
const [state, setState] = useState({
currency: currencies[getRandom(0, 2)],
value: getRandom(0, 100000)
});
useEffect(() => {
setInterval(() => {
setState({
currency: currencies[getRandom(0, 2)],
value: getRandom(0, 100000)
});
}, 500);
}, []);
return (
<View style={styles.container}>
<Ticker textStyle={styles.text}>
<Tick rotateItems={currencies}>{state.currency}</Tick>
{state.value.toLocaleString()}
</Ticker>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
backgroundColor: "#333"
},
text: {
fontSize: 40,
color: "#FFF"
}
});
export default App;
I have the last version of the reanimated 2 and moved file without any changes. And after a few mins or earlier a have got the error. reanimated version: 2.0.0-alpha.7, RN version: 0.63.3

@valin0k this is a pretty big component, could you prepare a smaller repro without external dependencies?
Most helpful comment
Error was confirmed when I was using
setValue()inside PanGestureHandler event callback. It seems like callingsetValue()on a very frequent manner does cause this issue. Hopefully this can be addressed in a better form than fixing the .m file.