question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Native crash when using an undefined Animated.Value in a debug node

See original GitHub issue

When setting the value of an Animated.Value object to null or undefined and then using it in a debug statement in an Animated.Code block, we get a native exception that crashes the app.

Reproducible demo:


import React, {Fragment} from 'react';
import {
  SafeAreaView,
  Text,
  TouchableOpacity,
} from 'react-native';

import Animated from 'react-native-reanimated';
const {
  set,
  block,
  debug,
} = Animated;

const node = new Animated.Value(0);

const App = () => {
  return (
    <Fragment>
      <Animated.Code>
        {() => block([debug('node value: ', node)])}
      </Animated.Code>
      <SafeAreaView>
        <TouchableOpacity
          onPress={() => node.setValue(undefined)}    // setValue(null) will throw a different exception
          style={{padding: 20}}
        >
          <Text>Click Me</Text>
        </TouchableOpacity>
      </SafeAreaView>
    </Fragment>
  );
};

export default App;

This error can be quite difficult to find in a complex animation, since there is no indication about what the problem is. If it is intended that an error is thrown on an undefined Value, then a better error message would be very useful.

The exact error is on line 21 of REAJSCallNode.m:

[error][tid:main][RCTUIManager.m:1133] Exception thrown while executing UI block: *** -[__NSArrayM setObject:atIndexedSubscript:]: object cannot be nil

In the case of setting the Value to null, we get a JS exception: Unhandled JS Exception: Cannot read property '__isProxy' of null.

Here are the versions used:

"react": "16.8.6",
"react-native": "0.60.5",
"react-native-reanimated": "1.2.0"

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Sevendayecommented, Oct 5, 2020
this.position = new Animated.ValueXY();

onPanResponderMove: (event, gesture) => { this.position.setValue({ x: gesture.dx, y: 0}) },

Even if you only use x, you must put y to 0 so that they are not undefined It should have default values if not initialized.

0reactions
jakub-gonetcommented, Aug 31, 2020

@marqroldan, could you please provide some minimal code example reproducing this crash?

Read more comments on GitHub >

github_iconTop Results From Across the Web

App Crashing due to animation in release mode
They are working fine in debug mode but app is crashing due to it in release or production mode build.
Read more >
Drawer Navigator | React Navigation
The progress object is a Reanimated Node if you're using Reanimated 1 (see useLegacyImplementation ), otherwise a SharedValue . It represents the animated...
Read more >
react-native-maps - npm
Start using react-native-maps in your project by running `npm i ... The MapView can accept an AnimatedRegion value as its region prop.
Read more >
Using Hermes - React Native
This will compile JavaScript to bytecode during build time which will improve your app's startup speed on device. Debugging JS on Hermes using...
Read more >
Safari Technology Preview Release Notes - Apple Developer
Fixed a crash clicking on Safari App Extension toolbar items ... Changed to use native datetime-local input for changing expires value in cookie...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found